title: How to convert LLVM IR br back to a while loop
body: <p>I am wondering how to do sort of transpilation of source to source using LLVM at a high level. Given that LLVM converts while loops to using <code>br</code> and the like, I am wondering how to then take that specific IR chunk and convert it <em>back</em> to a while loop in a language such as JavaScript.</p>
  
  <pre><code>C while loop -&gt; LLVM IR -&gt; JavaScript while loop
  </code></pre>
  
  <p><a href="https://thenewstack.io/javascript-transpilers-need-know/" rel="nofollow noreferrer">This article</a> suggests that Emscripten converts LLVM code to JavaScript, so it probably handles this somewhere.</p>
  
  <p>I'm wondering just the general strategy for converting it, if there is one. It seems a bit tricky from a distance, figuring out the statements to piece together a while loop from IR.</p>