title: How to extract information from the llvm metadata
body: <p>I have the following piece of code:</p>
  
  <pre><code> int main(int argc, char *argv[])
      {
          int a = 2;
          int b = 5;
          int soma = a + b;
     //...}
  </code></pre>
  
  <p>The resulting llvm bitcode is:</p>
  
  <pre><code>       define i32 @main(i32 %argc, i8** %argv) #0 {
          entry:
            ...
            %a = alloca i32, align 4
            %b = alloca i32, align 4
            %soma = alloca i32, align 4
            ...
            call void @llvm.dbg.declare(metadata !{i32* %a}, metadata !15), !dbg !16
            store i32 2, i32* %a, align 4, !dbg !16
            call void @llvm.dbg.declare(metadata !{i32* %b}, metadata !17), !dbg !18
            store i32 5, i32* %b, align 4, !dbg !18
            call void @llvm.dbg.declare(metadata !{i32* %soma}, metadata !19), !dbg !20
            %0 = load i32* %a, align 4, !dbg !20
            %1 = load i32* %b, align 4, !dbg !20
            %add = add nsw i32 %0, %1, !dbg !20
            store i32 %add, i32* %soma, align 4, !dbg !20
            ...       
            !1 = metadata !{i32 0}
            !2 = metadata !{metadata !3}
            ...
            !15 = metadata !{i32 786688, metadata !3, metadata !"a", metadata !4, i32 6, metadata !7, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 6]
  !16 = metadata !{i32 6, i32 0, metadata !3, null}
  !17 = metadata !{i32 786688, metadata !3, metadata !"b", metadata !4, i32 7, metadata !7, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [b] [line 7]
  !18 = metadata !{i32 7, i32 0, metadata !3, null}
  !19 = metadata !{i32 786688, metadata !3, metadata !"soma", metadata !4, i32 8, metadata !7, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [soma] [line 8]
  !20 = metadata !{i32 8, i32 0, metadata !3, null}
  </code></pre>
  
  <p>From the bitcode I need to get the following text:</p>
  
  <pre><code>a = 2
  b = 5
  soma = a + b
  </code></pre>
  
  <p>My doubt is how to extract the information I need from the metadata (dgb)??
  Right now I only have the name of the instructions <code>I-&gt; getName ()</code> and the name of the operands with <code>valueOp Value * = I-&gt; getOperand (i); valueOp-&gt; getName (). Str ();</code>
  The metadata is very extensive. How do I get this information from the metadata?</p>