xunge/DecIR huggingface dataset:
/* Type definitions */
typedef int /*<<< orphan*/ val;

/* Variables and functions */
int knapSack(int, int *, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int val[] = {60, 100, 120};
  int wt[] = {10, 20, 30};
  int W = 50;
  int n = sizeof(val) / sizeof(val[0]);
  printf("%d", knapSack(W, wt, val, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec2(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xec0(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x32,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x1c(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <knapSack@plt>
mov    %eax,%esi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0xede(%rip),%eax
mov    %eax,0x20(%rsp)
mov    0xecb(%rip),%rax
mov    %rax,0x18(%rsp)
mov    0xed4(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xec1(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    $0x32,%edi
mov    $0x3,%ecx
call   1040 <knapSack@plt>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.val = [3 x i32] [i32 60, i32 100, i32 120]
@__const.main.wt = [3 x i32] [i32 10, i32 20, i32 30]
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [3 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [3 x i32]* %2 to i8*
%7 = bitcast [3 x i32]* %3 to i8*
store i32 50, i32* %4
store i32 3, i32* %5
%8 = load i32, i32* %4
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %5
%12 = call i32 @knapSack(i32 %8, i32* %9, i32* %10, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.val = [3 x i32] [i32 60, i32 100, i32 120]
@__const.main.wt = [3 x i32] [i32 10, i32 20, i32 30]
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%7 = call i32 @knapSack(i32 50, i32* %5, i32* %6, i32 3)
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void UI_usage() {
  printf("Usage: tmsnc [OPTION(s)]\n"
         "TMSNC is a textbased MSN client with an NCurses interface\n\n"
         "OPTION can be one or more of the following:\n"
         "-h               print this help\n"
         "-l <username>    specify your username\n"
         "-u               check wether a newer version of TMSNC is available "
         "or not\n"
         "-i <status>      set initial status where <status> is 'online', "
         "'away', 'brb',\n"
         "                 'busy', 'idle', 'phone', 'lunch' or 'hidden'.\n"
         "-v               display version information\n\n"
         "Please report bugs to sanoi[at]freeshell.org\n");
}


x86 assembly (clang, -O0):
<UI_usage>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_usage>:
lea    0xee9(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [509 x i8] c"Usage: tmsnc [OPTION(s)]\0ATMSNC is a textbased MSN client with an NCurses interface\0A\0AOPTION can be one or more of the following:\0A-h print this help\0A-l <username> specify your username\0A-u check wether a newer version of TMSNC is available or not\0A-i <status> set initial status where <status> is 'online', 'away', 'brb',\0A 'busy', 'idle', 'phone', 'lunch' or 'hidden'.\0A-v display version information\0A\0APlease report bugs to sanoi[at]freeshell.org\0A\00"
define void @UI_usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([509 x i8], [509 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [508 x i8] c"Usage: tmsnc [OPTION(s)]\0ATMSNC is a textbased MSN client with an NCurses interface\0A\0AOPTION can be one or more of the following:\0A-h print this help\0A-l <username> specify your username\0A-u check wether a newer version of TMSNC is available or not\0A-i <status> set initial status where <status> is 'online', 'away', 'brb',\0A 'busy', 'idle', 'phone', 'lunch' or 'hidden'.\0A-v display version information\0A\0APlease report bugs to sanoi[at]freeshell.org\00"
define void @UI_usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([508 x i8], [508 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ doMouse();
int main(int argc, char *argv[]) {
  doMouse();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <doMouse@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <doMouse@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @doMouse()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @doMouse()
ret i32 0
}
double fibonacci(double p) {
  if (p <= 2.0)
    return 1.0;
  else
    return (fibonacci(p - 1.0) + fibonacci(p - 2.0));
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1142 <fibonacci+0x32>
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1184 <fibonacci+0x74>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb9(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fibonacci@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe96(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fibonacci@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
movsd  0xee8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1161 <fibonacci+0x51>
movsd  0xee2(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <fibonacci@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xec7(%rip),%xmm0
call   1030 <fibonacci@plt>
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0xe97(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @fibonacci(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 2.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store double 1.000000e+00, double* %2
br label %15
7: ; preds = %1
%8 = load double, double* %3
%9 = fsub double %8, 1.000000e+00
%10 = call double @fibonacci(double %9)
%11 = load double, double* %3
%12 = fsub double %11, 2.000000e+00
%13 = call double @fibonacci(double %12)
%14 = fadd double %10, %13
store double %14, double* %2
br label %15
15: ; preds = %7, %6
%16 = load double, double* %2
ret double %16
}

LLVM IR (-O2):
define double @fibonacci(double %0) {
%2 = fcmp ugt double %0, 2.000000e+00
br i1 %2, label %5, label %3
3: ; preds = %1, %5
%4 = phi double [ %10, %5 ], [ 1.000000e+00, %1 ]
ret double %4
5: ; preds = %1
%6 = fadd double %0, -1.000000e+00
%7 = tail call double @fibonacci(double %6)
%8 = fadd double %0, -2.000000e+00
%9 = tail call double @fibonacci(double %8)
%10 = fadd double %7, %9
br label %3
}
/* Type definitions */
typedef scalar_t__ int32_t;

/* Variables and functions */
double __attribute__((pcs("aapcs"))) __aeabi_i2d(int32_t x) { return (float)x; }


x86 assembly (clang, -O0):
<__aeabi_i2d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cvtsi2ssq -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<__aeabi_i2d>:
cvtsi2ss %rdi,%xmm0
cvtss2sd %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @__aeabi_i2d(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = sitofp i64 %3 to float
%5 = fpext float %4 to double
ret double %5
}

LLVM IR (-O2):
define double @__aeabi_i2d(i64 %0) {
%2 = sitofp i64 %0 to float
%3 = fpext float %2 to double
ret double %3
}
/* Variables and functions */
int getpid();
int idris2_getPID() { return getpid(); }


x86 assembly (clang, -O0):
<idris2_getPID>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <getpid@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<idris2_getPID>:
xor    %eax,%eax
jmp    1030 <getpid@plt>

LLVM IR (-O0):
define i32 @idris2_getPID() {
%1 = call i32 (...) @getpid()
ret i32 %1
}

LLVM IR (-O2):
define i32 @idris2_getPID() {
%1 = tail call i32 (...) @getpid()
ret i32 %1
}
/* Variables and functions */
int cont_craps(int);
int throw_dice();
int play_craps() {
  int sum_dice;
  sum_dice = throw_dice();
  switch (sum_dice) {
  case 7:
  case 11:
    return 1;
  case 2:
  case 3:
  case 12:
    return 0;
  }
  return cont_craps(sum_dice);
}


x86 assembly (clang, -O0):
<play_craps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <throw_dice@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1188 <play_craps+0x68>
jmp    1149 <play_craps+0x29>
mov    -0xc(%rbp),%eax
sub    $0x7,%eax
je     117c <play_craps+0x5c>
jmp    115a <play_craps+0x3a>
mov    -0xc(%rbp),%eax
sub    $0xb,%eax
je     117c <play_craps+0x5c>
jmp    116b <play_craps+0x4b>
mov    -0xc(%rbp),%eax
sub    $0xc,%eax
je     1188 <play_craps+0x68>
jmp    1194 <play_craps+0x74>
movl   $0x1,-0x4(%rbp)
jmp    119f <play_craps+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    119f <play_craps+0x7f>
mov    -0x8(%rbp),%edi
call   1030 <cont_craps@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_craps>:
push   %rax
xor    %eax,%eax
call   1040 <throw_dice@plt>
lea    -0x2(%rax),%ecx
cmp    $0xb,%ecx
jae    113a <play_craps+0x1a>
mov    $0x623,%edx
bt     %ecx,%edx
jb     1142 <play_craps+0x22>
mov    %eax,%edi
pop    %rax
jmp    1030 <cont_craps@plt>
movslq %ecx,%rax
lea    0xeb4(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @play_craps() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @throw_dice()
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %7 [
i32 7, label %5
i32 11, label %5
i32 2, label %6
i32 3, label %6
i32 12, label %6
]
5: ; preds = %0, %0
store i32 1, i32* %1
br label %10
6: ; preds = %0, %0, %0
store i32 0, i32* %1
br label %10
7: ; preds = %0
%8 = load i32, i32* %2
%9 = call i32 @cont_craps(i32 %8)
store i32 %9, i32* %1
br label %10
10: ; preds = %7, %6, %5
%11 = load i32, i32* %1
ret i32 %11
}

LLVM IR (-O2):
@switch.table.play_craps = [11 x i32] [i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0]
define i32 @play_craps() {
%1 = tail call i32 (...) @throw_dice()
%2 = add i32 %1, -2
%3 = icmp ult i32 %2, 11
br i1 %3, label %6, label %4
4: ; preds = %6, %0
%5 = tail call i32 @cont_craps(i32 %1)
br label %15
6: ; preds = %0
%7 = trunc i32 %2 to i16
%8 = lshr i16 1571, %7
%9 = and i16 %8, 1
%10 = icmp eq i16 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %6
%12 = sext i32 %2 to i64
%13 = getelementptr inbounds [11 x i32], [11 x i32]* @switch.table.play_craps, i64 0, i64 %12
%14 = load i32, i32* %13
br label %15
15: ; preds = %11, %4
%16 = phi i32 [ %5, %4 ], [ %14, %11 ]
ret i32 %16
}
/* Variables and functions */
char *strrchr(char const *, char);
char *basename(const char *file) {
  char *fn = strrchr(file, '/');
  return fn ? fn + 1 : (char *)file;
}


x86 assembly (clang, -O0):
<basename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114a <basename+0x3a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1152 <basename+0x42>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basename>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @basename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strrchr(i8* %4, i8 signext 47)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 1
br label %13
11: ; preds = %1
%12 = load i8*, i8** %2
br label %13
13: ; preds = %11, %8
%14 = phi i8* [ %10, %8 ], [ %12, %11 ]
ret i8* %14
}

LLVM IR (-O2):
define i8* @basename(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = icmp eq i8* %2, null
%4 = getelementptr inbounds i8, i8* %2, i64 1
%5 = select i1 %3, i8* %0, i8* %4
ret i8* %5
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *xstrdup(const char *s) {
  char *cpy = NULL;
  if (s) {
    if (!(cpy = strdup(s))) {
      fprintf(stderr, "out of memory\n");
      exit(1);
    }
  }
  return cpy;
}


x86 assembly (clang, -O0):
<xstrdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118a <xstrdup+0x5a>
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1185 <xstrdup+0x55>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    118a <xstrdup+0x5a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xstrdup>:
push   %rax
test   %rdi,%rdi
je     1142 <xstrdup+0x12>
call   1050 <strdup@plt>
test   %rax,%rax
je     1146 <xstrdup+0x16>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"out of memory\0A\00"
define i8* @xstrdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %6
br label %15
15: ; preds = %14, %1
%16 = load i8*, i8** %3
ret i8* %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"out of memory\0A\00"
define noalias i8* @xstrdup(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = tail call i8* @strdup(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3, %1
%11 = phi i8* [ %4, %3 ], [ null, %1 ]
ret i8* %11
}
void RTLogFlags(void) {}


x86 assembly (clang, -O0):
<RTLogFlags>:
push   %rbp
mov    %rsp,%rbp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RTLogFlags>:
ret

LLVM IR (-O0):
define void @RTLogFlags() {
ret void
}

LLVM IR (-O2):
define void @RTLogFlags() {
ret void
}
void funcWhile(int a) {
  char c = 'a';
  int i = 0;
  while (!(i < a)) {
    ++c;
    if (c == 'c') {
      continue;
    }
    if (c == 'z') {
      break;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<funcWhile>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movb   $0x61,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
setl   %al
xor    $0xff,%al
test   $0x1,%al
jne    112a <funcWhile+0x2a>
jmp    1164 <funcWhile+0x64>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x63,%eax
jne    1144 <funcWhile+0x44>
jmp    1112 <funcWhile+0x12>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jne    1156 <funcWhile+0x56>
jmp    1164 <funcWhile+0x64>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1112 <funcWhile+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<funcWhile>:
test   %edi,%edi
jg     1124 <funcWhile+0x24>
mov    $0x61,%cl
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
mov    $0x63,%cl
cmp    $0x62,%al
je     1110 <funcWhile+0x10>
cmp    $0x79,%al
je     1124 <funcWhile+0x24>
add    $0x1,%al
mov    %eax,%ecx
test   %edi,%edi
jle    1110 <funcWhile+0x10>
ret

LLVM IR (-O0):
define void @funcWhile(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i32 %0, i32* %2
store i8 97, i8* %3
store i32 0, i32* %4
br label %5
5: ; preds = %22, %16, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
%9 = xor i1 %8, true
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = load i8, i8* %3
%12 = add i8 %11, 1
store i8 %12, i8* %3
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 99
br i1 %15, label %16, label %17
16: ; preds = %10
br label %5
17: ; preds = %10
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 122
br i1 %20, label %21, label %22
21: ; preds = %17
br label %25
22: ; preds = %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %5
25: ; preds = %21, %5
ret void
}

LLVM IR (-O2):
define void @funcWhile(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %9, label %3
3: ; preds = %1, %5
%4 = phi i8 [ %6, %5 ], [ 97, %1 ]
switch i8 %4, label %7 [
i8 98, label %5
i8 121, label %9
]
5: ; preds = %3, %7
%6 = phi i8 [ 99, %3 ], [ %8, %7 ]
br label %3
7: ; preds = %3
%8 = add i8 %4, 1
br i1 %2, label %9, label %5
9: ; preds = %7, %3, %1
ret void
}
int count_arguments(char *line) {
  int count = 0;
  while (*line) {
    if (' ' == *line) {
      count++;
    }
    line++;
  }
  count++;
  return count;
}


x86 assembly (clang, -O0):
<count_arguments>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     114a <count_arguments+0x4a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jne    1139 <count_arguments+0x39>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <count_arguments+0xf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_arguments>:
xor    %eax,%eax
jmp    1117 <count_arguments+0x17>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%eax
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x20,%cl
je     1110 <count_arguments+0x10>
test   %cl,%cl
jne    1113 <count_arguments+0x13>
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @count_arguments(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 32, %11
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %8
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
br label %4
19: ; preds = %4
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @count_arguments(i8* nocapture %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ %0, %1 ], [ %10, %8 ]
%4 = phi i32 [ 0, %1 ], [ %9, %8 ]
%5 = load i8, i8* %3
switch i8 %5, label %8 [
i8 0, label %11
i8 32, label %6
]
6: ; preds = %2
%7 = add nsw i32 %4, 1
br label %8
8: ; preds = %2, %6
%9 = phi i32 [ %7, %6 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %2
%12 = add nsw i32 %4, 1
ret i32 %12
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int david_sum(int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  uint32_t n1, n2, x;
  n1 = 5;
  n2 = 7;
  x = david_sum(n1, n2);
  printf("The sum of %d and %d is %d\n", n1, n2, x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <david_sum@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x5,%edi
mov    $0x7,%esi
call   1030 <david_sum@plt>
lea    0xec9(%rip),%rdi
mov    $0x5,%esi
mov    $0x7,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"The sum of %d and %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store i32 7, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 @david_sum(i32 %5, i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"The sum of %d and %d is %d\0A\00"
define i32 @main() {
%1 = tail call i32 @david_sum(i32 5, i32 7)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 5, i32 7, i32 %1)
ret i32 0
}
void ToLowercase(char *str) {
  while (*str) {
    if ((*str >= 'A') && (*str <= 'Z')) {
      *str = *str + ('a' - 'A');
    }
    str++;
  }
}


x86 assembly (clang, -O0):
<ToLowercase>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1158 <ToLowercase+0x58>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1147 <ToLowercase+0x47>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     1147 <ToLowercase+0x47>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0x20,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <ToLowercase+0x8>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ToLowercase>:
mov    (%rdi),%al
test   %al,%al
je     112a <ToLowercase+0x2a>
add    $0x1,%rdi
jmp    111b <ToLowercase+0x1b>
nopl   0x0(%rax)
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
je     112a <ToLowercase+0x2a>
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     1110 <ToLowercase+0x10>
add    $0x20,%al
mov    %al,-0x1(%rdi)
jmp    1110 <ToLowercase+0x10>
ret

LLVM IR (-O0):
define void @ToLowercase(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %24, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp sge i32 %10, 65
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp sle i32 %15, 90
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, 32
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %2
store i8 %22, i8* %23
br label %24
24: ; preds = %17, %12, %7
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %3
27: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @ToLowercase(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %11
%5 = phi i8 [ %13, %11 ], [ %2, %1 ]
%6 = phi i8* [ %12, %11 ], [ %0, %1 ]
%7 = add i8 %5, -65
%8 = icmp ult i8 %7, 26
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = add nuw nsw i8 %5, 32
store i8 %10, i8* %6
br label %11
11: ; preds = %9, %4
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %11, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char buffer[7] = "foobar\n";
  write(1, buffer, 7);
  char buffer2[2] = {'\0', '\n'};
  write(1, buffer2, 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xed5(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xb(%rbp),%rsi
mov    $0x1,%edi
mov    $0x7,%edx
call   1030 <write@plt>
mov    0xeb1(%rip),%ax
mov    %ax,-0xd(%rbp)
lea    -0xd(%rbp),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0xa726162,0x13(%rsp)
0a
movl   $0x626f6f66,0x10(%rsp)
62
lea    0x10(%rsp),%rsi
mov    $0x1,%edi
mov    $0x7,%edx
call   1030 <write@plt>
movw   $0xa00,0xe(%rsp)
lea    0xe(%rsp),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.buffer = [7 x i8] c"foobar\0A"
@__const.main.buffer2 = [2 x i8] c"\00\0A"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca [2 x i8]
store i32 0, i32* %1
%4 = bitcast [7 x i8]* %2 to i8*
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%6 = call i32 @write(i32 1, i8* %5, i32 7)
%7 = bitcast [2 x i8]* %3 to i8*
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%9 = call i32 @write(i32 1, i8* %8, i32 2)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buffer = [7 x i8] c"foobar\0A"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca i16
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%4 = call i32 @write(i32 1, i8* %3, i32 7)
%5 = bitcast i16* %2 to i8*
store i16 2560, i16* %2
%6 = call i32 @write(i32 1, i8* %5, i32 2)
ret i32 0
}
/* Variables and functions */
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, const char *argv[]) {
  char s1[] = "abc";
  char *str = (char *)malloc(strlen(s1) + 1);
  strcpy(str, s1);
  printf("%s", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea4(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x636261,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s1 = [4 x i8] c"abc\00"
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [4 x i8]* %6 to i8*
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i64 @malloc(i64 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 6513249, i32* %3
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = tail call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @strcpy(i8* %8, i8* %4)
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i32 0
}
f(i) int i;
{ return i; }


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
mov    %edi,%eax
ret

LLVM IR (-O0):
define i32 @f(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
ret i32 %3
}

LLVM IR (-O2):
define i32 @f(i32 returned %0) {
ret i32 %0
}
/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *int_to_string(int i) {
  static char buffer[256];
  snprintf(buffer, 255, "%d", i);
  return buffer;
}


x86 assembly (clang, -O0):
<int_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
lea    0x2f1b(%rip),%rdi
mov    $0xff,%esi
lea    0xecf(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2f03(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_to_string>:
push   %rbx
mov    %edi,%ecx
lea    0x2f26(%rip),%rbx
lea    0xedf(%rip),%rdx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@int_to_string.buffer = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @int_to_string(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @int_to_string.buffer, i64 0, i64 0), i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @int_to_string.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@int_to_string.buffer = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @int_to_string(i32 %0) {
%2 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @int_to_string.buffer, i64 0, i64 0), i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @int_to_string.buffer, i64 0, i64 0)
}
void func3() {
  int x;
  int y;
  x = 0;
  x = 1;
  y = 1;
  y = 2;
}


x86 assembly (clang, -O0):
<func3>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0x8(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<func3>:
ret

LLVM IR (-O0):
define void @func3() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %1
store i32 1, i32* %2
store i32 2, i32* %2
ret void
}

LLVM IR (-O2):
define void @func3() {
ret void
}
void coerce(long x, short z) {
  int *y = (int *)x;
  *y = z;
}


x86 assembly (clang, -O0):
<coerce>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movswl -0xa(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<coerce>:
mov    %esi,(%rdi)
ret

LLVM IR (-O0):
define void @coerce(i64 %0, i16 signext %1) {
%3 = alloca i64
%4 = alloca i16
%5 = alloca i32*
store i64 %0, i64* %3
store i16 %1, i16* %4
%6 = load i64, i64* %3
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %5
%8 = load i16, i16* %4
%9 = sext i16 %8 to i32
%10 = load i32*, i32** %5
store i32 %9, i32* %10
ret void
}

LLVM IR (-O2):
define void @coerce(i64 %0, i16 signext %1) {
%3 = inttoptr i64 %0 to i32*
%4 = sext i16 %1 to i32
store i32 %4, i32* %3
ret void
}
/* Variables and functions */
scalar_t__ memset(void *, int /*<<< orphan*/, int);
int ZeroMemory(void *ptr, int size) {
  if (memset(ptr, 0, size) < 0)
    return -1;
  else
    return 1;
}


x86 assembly (clang, -O0):
<ZeroMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
cmp    $0x0,%rax
jge    1143 <ZeroMemory+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    114a <ZeroMemory+0x3a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZeroMemory>:
push   %rax
mov    %esi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
xor    %ecx,%ecx
test   %rax,%rax
setns  %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @ZeroMemory(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = load i32, i32* %5
%8 = call i64 @memset(i8* %6, i32 0, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %12
11: ; preds = %2
store i32 1, i32* %3
br label %12
12: ; preds = %11, %10
%13 = load i32, i32* %3
ret i32 %13
}

LLVM IR (-O2):
define i32 @ZeroMemory(i8* %0, i32 %1) {
%3 = tail call i64 @memset(i8* %0, i32 0, i32 %1)
%4 = icmp slt i64 %3, 0
%5 = select i1 %4, i32 -1, i32 1
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ interchange(int *, int *);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int x = 5, y = 10;
  printf("Originally x = %d and y = %d\n", x, y);
  interchange(&x, &y);
  printf("Now x = %d and y = %d\n", x, y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <interchange@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x5,0x4(%rsp)
movl   $0xa,(%rsp)
lea    0xec9(%rip),%rdi
mov    $0x5,%esi
mov    $0xa,%edx
call   1030 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <interchange@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Originally x = %d and y = %d\0A\00"
@.str.1 = [23 x i8] c"Now x = %d and y = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store i32 10, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = call i32 @interchange(i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Originally x = %d and y = %d\0A\00"
@.str.1 = [23 x i8] c"Now x = %d and y = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 5, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 10, i32* %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 5, i32 10)
%6 = call i32 @interchange(i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ func5(int, int);
main() {
  int z = 32;
  int y = 44;
  const char *foo1 = "Test";
  func5(3, 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x20,-0x4(%rbp)
movl   $0x2c,-0x8(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x3,%edi
mov    $0x5,%esi
call   1030 <func5@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
mov    $0x5,%esi
call   1030 <func5@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Test\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 32, i32* %1
store i32 44, i32* %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = call i32 @func5(i32 3, i32 5)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @func5(i32 3, i32 5)
ret i32 0
}
int islower(int c) {
  if (c >= 'a' && c <= 'z')
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<islower>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x61,-0x8(%rbp)
jl     1127 <islower+0x27>
cmpl   $0x7a,-0x8(%rbp)
jg     1127 <islower+0x27>
movl   $0x1,-0x4(%rbp)
jmp    112e <islower+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<islower>:
add    $0xffffff9f,%edi
xor    %eax,%eax
cmp    $0x1a,%edi
setb   %al
ret

LLVM IR (-O0):
define i32 @islower(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 97
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 122
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %2
br label %11
10: ; preds = %6, %1
store i32 0, i32* %2
br label %11
11: ; preds = %10, %9
%12 = load i32, i32* %2
ret i32 %12
}

LLVM IR (-O2):
define i32 @islower(i32 %0) {
%2 = add i32 %0, -97
%3 = icmp ult i32 %2, 26
%4 = zext i1 %3 to i32
ret i32 %4
}
unsigned long b_get_argc() {
  unsigned long tlong;
  asm volatile("call 0x00100138" : "=a"(tlong));
  return tlong;
}


x86 assembly (clang, -O0):
<b_get_argc>:
push   %rbp
mov    %rsp,%rbp
call   100138 <completed.0+0xfc118>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_get_argc>:
call   100138 <completed.0+0xfc118>
ret

LLVM IR (-O0):
define i64 @b_get_argc() {
%1 = alloca i64
%2 = call i64 asm sideeffect "call 0x00100138", "={ax},~{dirflag},~{fpsr},~{flags}"()
store i64 %2, i64* %1
%3 = load i64, i64* %1
ret i64 %3
}

LLVM IR (-O2):
define i64 @b_get_argc() {
%1 = tail call i64 asm sideeffect "call 0x00100138", "={ax},~{dirflag},~{fpsr},~{flags}"()
ret i64 %1
}
void delay_1ms(unsigned int DelayTime) {
  unsigned int x;
  for (x = 0; x < DelayTime; x++) {
  }
}


x86 assembly (clang, -O0):
<delay_1ms>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    112d <delay_1ms+0x2d>
jmp    111f <delay_1ms+0x1f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    110e <delay_1ms+0xe>
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay_1ms>:
ret

LLVM IR (-O0):
define void @delay_1ms(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp ult i32 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
br label %9
9: ; preds = %8
%10 = load i32, i32* %3
%11 = add i32 %10, 1
store i32 %11, i32* %3
br label %4
12: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @delay_1ms(i32 %0) {
ret void
}
void normalizeHeadingInline(int *heading) {
  while (heading < 0)
    *heading += 360;
  *heading = *heading % 360;
}


x86 assembly (clang, -O0):
<normalizeHeadingInline>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jae    1126 <normalizeHeadingInline+0x26>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x168,%ecx
mov    %ecx,(%rax)
jmp    1108 <normalizeHeadingInline+0x8>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
mov    %edx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalizeHeadingInline>:
movslq (%rdi),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x8,%ecx
add    %edx,%ecx
imul   $0x168,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @normalizeHeadingInline(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
br label %3
3: ; preds = %6, %1
%4 = load i32*, i32** %2
%5 = icmp ult i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32*, i32** %2
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 360
store i32 %9, i32* %7
br label %3
10: ; preds = %3
%11 = load i32*, i32** %2
%12 = load i32, i32* %11
%13 = srem i32 %12, 360
%14 = load i32*, i32** %2
store i32 %13, i32* %14
ret void
}

LLVM IR (-O2):
define void @normalizeHeadingInline(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = srem i32 %2, 360
store i32 %3, i32* %0
ret void
}
/* Variables and functions */
int /*<<< orphan*/ GPIO_SET_GPCLR(int);
int /*<<< orphan*/ GPIO_SET_GPSET(int);
void blink_GPIO16(void) {
  static int lit16 = 0;
  if (lit16) {
    GPIO_SET_GPSET(16);
    lit16 = 0;
  } else {
    GPIO_SET_GPCLR(16);
    lit16 = 1;
  }
}


x86 assembly (clang, -O0):
<blink_GPIO16>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2f09(%rip)
je     114a <blink_GPIO16+0x2a>
mov    $0x10,%edi
call   1040 <GPIO_SET_GPSET@plt>
movl   $0x0,0x2eef(%rip)
jmp    115e <blink_GPIO16+0x3e>
mov    $0x10,%edi
call   1030 <GPIO_SET_GPCLR@plt>
movl   $0x1,0x2ed6(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<blink_GPIO16>:
push   %rbx
mov    0x2f0d(%rip),%bl
mov    $0x10,%edi
cmp    $0x1,%bl
jne    1138 <blink_GPIO16+0x18>
call   1040 <GPIO_SET_GPSET@plt>
jmp    113d <blink_GPIO16+0x1d>
call   1030 <GPIO_SET_GPCLR@plt>
xor    $0x1,%bl
mov    %bl,0x2eee(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@blink_GPIO16.lit16 = internal global i32 0
define void @blink_GPIO16() {
%1 = load i32, i32* @blink_GPIO16.lit16
%2 = icmp ne i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @GPIO_SET_GPSET(i32 16)
store i32 0, i32* @blink_GPIO16.lit16
br label %7
5: ; preds = %0
%6 = call i32 @GPIO_SET_GPCLR(i32 16)
store i32 1, i32* @blink_GPIO16.lit16
br label %7
7: ; preds = %5, %3
ret void
}

LLVM IR (-O2):
@blink_GPIO16.lit16 = internal unnamed_addr global i1 false
define void @blink_GPIO16() {
%1 = load i1, i1* @blink_GPIO16.lit16
br i1 %1, label %2, label %4
2: ; preds = %0
%3 = tail call i32 @GPIO_SET_GPSET(i32 16)
br label %6
4: ; preds = %0
%5 = tail call i32 @GPIO_SET_GPCLR(i32 16)
br label %6
6: ; preds = %4, %2
%7 = xor i1 %1, true
store i1 %7, i1* @blink_GPIO16.lit16
ret void
}
f(j) int j;
{ return ++j > 0; }


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
mov    %edi,%eax
not    %eax
shr    $0x1f,%eax
ret

LLVM IR (-O0):
define i32 @f(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 1
store i32 %4, i32* %2
%5 = icmp sgt i32 %4, 0
%6 = zext i1 %5 to i32
ret i32 %6
}

LLVM IR (-O2):
define i32 @f(i32 %0) {
%2 = xor i32 %0, -1
%3 = lshr i32 %2, 31
ret i32 %3
}
void advance_column() {}


x86 assembly (clang, -O0):
<advance_column>:
push   %rbp
mov    %rsp,%rbp
pop    %rbp
ret

x86 assembly (clang, -O2):
<advance_column>:
ret

LLVM IR (-O0):
define void @advance_column() {
ret void
}

LLVM IR (-O2):
define void @advance_column() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void bar2() { printf("bar2()\n"); }


x86 assembly (clang, -O0):
<bar2>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar2>:
lea    0xee9(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"bar2()\0A\00"
define void @bar2() {
%1 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [7 x i8] c"bar2()\00"
define void @bar2() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int strlen(const char *str) {
  int length = 0;
  while (*str != '\0') {
    str++;
    length++;
  }
  return length;
}


x86 assembly (clang, -O0):
<strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1139 <strlen+0x39>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <strlen+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlen>:
cmpb   $0x0,(%rdi)
je     111c <strlen+0x1c>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,0x1(%rdi,%rax,1)
lea    0x1(%rax),%rax
jne    1110 <strlen+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @strlen(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %2
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %4
14: ; preds = %4
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
define i32 @strlen(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ 0, %1 ]
%6 = phi i8* [ %7, %4 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = add nuw nsw i32 %5, 1
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4, %1
%12 = phi i32 [ 0, %1 ], [ %8, %4 ]
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ choose(int);
int /*<<< orphan*/ orientation_correct();
void navigateMaze(int ldm) {
  orientation_correct();
  choose(ldm);
  return;
}


x86 assembly (clang, -O0):
<navigateMaze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <orientation_correct@plt>
mov    -0x4(%rbp),%edi
call   1030 <choose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<navigateMaze>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <orientation_correct@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <choose@plt>

LLVM IR (-O0):
define void @navigateMaze(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @orientation_correct()
%4 = load i32, i32* %2
%5 = call i32 @choose(i32 %4)
ret void
}

LLVM IR (-O2):
define void @navigateMaze(i32 %0) {
%2 = tail call i32 (...) @orientation_correct()
%3 = tail call i32 @choose(i32 %0)
ret void
}