xunge/DecIR huggingface dataset:
/* Variables and functions */
int *f(int *);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int main(int argc, char *argv[]) {
  int *p = malloc(100);
  p = f(p);
  free(p);
  return p == 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    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <f@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%rdi
call   1040 <f@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
test   %rbx,%rbx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* @malloc(i32 100)
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = call i32* @f(i32* %8)
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = call i32 @free(i32* %10)
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
%14 = zext i1 %13 to i32
ret i32 %14
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 100)
%4 = tail call i32* @f(i32* %3)
%5 = tail call i32 @free(i32* %4)
%6 = icmp eq i32* %4, null
%7 = zext i1 %6 to i32
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ idle_hook_fptr();
void rtos_idle_loop(void) {
  while (1) {
    idle_hook_fptr();
  }
}


x86 assembly (clang, -O0):
<rtos_idle_loop>:
push   %rbp
mov    %rsp,%rbp
jmp    1119 <rtos_idle_loop+0x9>
mov    $0x0,%al
call   1030 <idle_hook_fptr@plt>
jmp    1119 <rtos_idle_loop+0x9>

x86 assembly (clang, -O2):
<rtos_idle_loop>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <idle_hook_fptr@plt>
jmp    1120 <rtos_idle_loop+0x10>

LLVM IR (-O0):
define void @rtos_idle_loop() {
br label %1
1: ; preds = %0, %1
%2 = call i32 (...) @idle_hook_fptr()
br label %1
}

LLVM IR (-O2):
define void @rtos_idle_loop() {
br label %1
1: ; preds = %0, %1
%2 = tail call i32 (...) @idle_hook_fptr()
br label %1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print(int a) {
  if (a == -1) {
    return;
  } else {
    printf("%d\n", a);
    a--;
    print(a);
  }
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    113a <print+0x1a>
jmp    115a <print+0x3a>
mov    -0x4(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %r14
push   %rbx
push   %rax
cmp    $0xffffffff,%edi
je     113f <print+0x2f>
mov    %edi,%ebx
lea    0xede(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jb     1130 <print+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @print(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %6
5: ; preds = %1
br label %12
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, -1
store i32 %10, i32* %2
%11 = load i32, i32* %2
br label %12
12: ; preds = %5, %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @print(i32 %0) {
%2 = icmp eq i32 %0, -1
br i1 %2, label %8, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %6, %3 ], [ %0, %1 ]
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = add nsw i32 %4, -1
%7 = icmp eq i32 %4, 0
br i1 %7, label %8, label %3
8: ; preds = %3, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ outb(int, int);
void send_pic_eoi(unsigned char irq) {
  if (irq > 7)
    outb(0xA0, 0x20);
  outb(0x20, 0x20);
}


x86 assembly (clang, -O0):
<send_pic_eoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x7,%eax
jle    113a <send_pic_eoi+0x2a>
mov    $0xa0,%edi
mov    $0x20,%esi
call   1030 <outb@plt>
mov    $0x20,%esi
mov    %esi,%edi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_pic_eoi>:
cmp    $0x8,%dil
jb     112a <send_pic_eoi+0x1a>
push   %rax
mov    $0xa0,%edi
mov    $0x20,%esi
call   1030 <outb@plt>
add    $0x8,%rsp
mov    $0x20,%edi
mov    $0x20,%esi
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @send_pic_eoi(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = icmp sgt i32 %4, 7
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @outb(i32 160, i32 32)
br label %8
8: ; preds = %6, %1
%9 = call i32 @outb(i32 32, i32 32)
ret void
}

LLVM IR (-O2):
define void @send_pic_eoi(i8 zeroext %0) {
%2 = icmp ugt i8 %0, 7
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @outb(i32 160, i32 32)
br label %5
5: ; preds = %3, %1
%6 = tail call i32 @outb(i32 32, i32 32)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ l6480_send_cmd(int, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
void l6480_cmd_resetdevice(void) {
  l6480_send_cmd(0xC0, 1, 0, 0);
  return;
}


x86 assembly (clang, -O0):
<l6480_cmd_resetdevice>:
push   %rbp
mov    %rsp,%rbp
mov    $0xc0,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <l6480_send_cmd@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<l6480_cmd_resetdevice>:
mov    $0xc0,%edi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
jmp    1030 <l6480_send_cmd@plt>

LLVM IR (-O0):
define void @l6480_cmd_resetdevice() {
%1 = call i32 @l6480_send_cmd(i32 192, i32 1, i32 0, i32 0)
ret void
}

LLVM IR (-O2):
define void @l6480_cmd_resetdevice() {
%1 = tail call i32 @l6480_send_cmd(i32 192, i32 1, i32 0, i32 0)
ret void
}
/* Type definitions */
struct matrix {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ glLoadIdentity();
int /*<<< orphan*/ glMultMatrixf(float *);
int /*<<< orphan*/ mat_to_opengl(float *, struct matrix const *);
void set_opengl_matrix(const struct matrix *m) {
  static float fm[16];
  glLoadIdentity();
  mat_to_opengl(fm, m);
  glMultMatrixf(fm);
}


x86 assembly (clang, -O0):
<set_opengl_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <glLoadIdentity@plt>
mov    -0x8(%rbp),%rsi
lea    0x2f02(%rip),%rdi
call   1030 <mat_to_opengl@plt>
lea    0x2ef6(%rip),%rdi
call   1050 <glMultMatrixf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_opengl_matrix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <glLoadIdentity@plt>
lea    0x2f0b(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mat_to_opengl@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <glMultMatrixf@plt>

LLVM IR (-O0):
%struct.matrix = type { i32 }
@set_opengl_matrix.fm = internal global [16 x float] zeroinitializer
define void @set_opengl_matrix(%struct.matrix* %0) {
%2 = alloca %struct.matrix*
store %struct.matrix* %0, %struct.matrix** %2
%3 = call i32 (...) @glLoadIdentity()
%4 = load %struct.matrix*, %struct.matrix** %2
%5 = call i32 @mat_to_opengl(float* getelementptr inbounds ([16 x float], [16 x float]* @set_opengl_matrix.fm, i64 0, i64 0), %struct.matrix* %4)
%6 = call i32 @glMultMatrixf(float* getelementptr inbounds ([16 x float], [16 x float]* @set_opengl_matrix.fm, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.matrix = type { i32 }
@set_opengl_matrix.fm = internal global [16 x float] zeroinitializer
define void @set_opengl_matrix(%struct.matrix* %0) {
%2 = tail call i32 (...) @glLoadIdentity()
%3 = tail call i32 @mat_to_opengl(float* getelementptr inbounds ([16 x float], [16 x float]* @set_opengl_matrix.fm, i64 0, i64 0), %struct.matrix* %0)
%4 = tail call i32 @glMultMatrixf(float* getelementptr inbounds ([16 x float], [16 x float]* @set_opengl_matrix.fm, i64 0, i64 0))
ret void
}
/* Variables and functions */
int EINVAL;
__attribute__((visibility("default"))) int sd_bus_try_close(void *bus) {
  return -EINVAL;
}


x86 assembly (clang, -O0):
<sd_bus_try_close>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    0x2ecf(%rip),%rcx
sub    (%rcx),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_bus_try_close>:
mov    0x2ed9(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
ret

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @sd_bus_try_close(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @EINVAL
%4 = sub nsw i32 0, %3
ret i32 %4
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @sd_bus_try_close(i8* nocapture readnone %0) {
%2 = load i32, i32* @EINVAL
%3 = sub nsw i32 0, %2
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  unsigned char t[4];
  t[0] = -1;
  t[1] = -1;
  t[2] = -1;
  t[3] = -1;
  unsigned char *z1 = t;
  void *z2 = z1;
  unsigned int *pi = z2;
  if (*pi == -1) {
    printf("UNSAFE\n");
    goto ERROR;
  }
  printf("SAFE\n");
  return (0);
ERROR:
  return (-1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0xff,-0x8(%rbp)
movb   $0xff,-0x7(%rbp)
movb   $0xff,-0x6(%rbp)
movb   $0xff,-0x5(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1165 <main+0x55>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    117d <main+0x6d>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1184 <main+0x74>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"UNSAFE\0A\00"
@.str.1 = [6 x i8] c"SAFE\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i32 0, i32* %1
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
store i8 -1, i8* %6
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
store i8 -1, i8* %7
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
store i8 -1, i8* %8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
store i8 -1, i8* %9
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
store i8* %10, i8** %3
%11 = load i8*, i8** %3
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %22
21: ; preds = %17
store i32 -1, i32* %1
br label %22
22: ; preds = %21, %19
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@str = [7 x i8] c"UNSAFE\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret i32 -1
}
int modulo(int a, int b) {
  while (a >= b) {
    a = a - b;
  }
  return a;
}


x86 assembly (clang, -O0):
<modulo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1124 <modulo+0x24>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    110a <modulo+0xa>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<modulo>:
mov    %edi,%eax
add    %esi,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    %esi,%eax
cmp    %esi,%eax
jge    1110 <modulo+0x10>
ret

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

LLVM IR (-O2):
define i32 @modulo(i32 %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ %0, %2 ], [ %6, %3 ]
%5 = icmp slt i32 %4, %1
%6 = sub nsw i32 %4, %1
br i1 %5, label %7, label %3
7: ; preds = %3
ret i32 %4
}
/* Variables and functions */
double deg2rad(int /*<<< orphan*/);
int /*<<< orphan*/ hour2deg(double);
double hour2rad(double x) { return deg2rad(hour2deg(x)); }


x86 assembly (clang, -O0):
<hour2rad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <hour2deg@plt>
mov    %eax,%edi
call   1040 <deg2rad@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hour2rad>:
push   %rax
call   1030 <hour2deg@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <deg2rad@plt>

LLVM IR (-O0):
define double @hour2rad(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call i32 @hour2deg(double %3)
%5 = call double @deg2rad(i32 %4)
ret double %5
}

LLVM IR (-O2):
define double @hour2rad(double %0) {
%2 = tail call i32 @hour2deg(double %0)
%3 = tail call double @deg2rad(i32 %2)
ret double %3
}
int video_init() { return (!0); }


x86 assembly (clang, -O0):
<video_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<video_init>:
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @video_init() {
ret i32 1
}

LLVM IR (-O2):
define i32 @video_init() {
ret i32 1
}
void foo484() {}


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

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

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

LLVM IR (-O2):
define void @foo484() {
ret void
}
int test_imm_97int16_mem(short *val) {
  return ((*val) & (0x97 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_97int16_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movswl (%rax),%edx
and    $0x97,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_97int16_mem>:
testb  $0x97,(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_97int16_mem(i16* %0) {
%2 = alloca i16*
store i16* %0, i16** %2
%3 = load i16*, i16** %2
%4 = load i16, i16* %3
%5 = sext i16 %4 to i32
%6 = and i32 %5, 151
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i32 -20, i32 -40
ret i32 %9
}

LLVM IR (-O2):
define i32 @test_imm_97int16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, 151
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int close(int);
int closeI2CBus(int *bus) {
  if (*bus)
    return close(*bus);
  else
    return 2;
}


x86 assembly (clang, -O0):
<closeI2CBus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     113c <closeI2CBus+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <close@plt>
mov    %eax,-0x4(%rbp)
jmp    1143 <closeI2CBus+0x33>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeI2CBus>:
mov    (%rdi),%edi
test   %edi,%edi
je     111b <closeI2CBus+0xb>
jmp    1030 <close@plt>
mov    $0x2,%eax
ret

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

LLVM IR (-O2):
define i32 @closeI2CBus(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @close(i32 %2)
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ %5, %4 ], [ 2, %1 ]
ret i32 %7
}
/* Type definitions */
typedef int /*<<< orphan*/ coin;

/* Variables and functions */
int /*<<< orphan*/ FindMinCoin(int, int *, int);
int main() {
  int Money = 6;
  int coin[] = {2, 3, 5};
  int length = sizeof(coin) / sizeof(coin[0]);
  FindMinCoin(Money, coin, length);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x6,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <FindMinCoin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xeee(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xedb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0x6,%edi
mov    $0x3,%edx
call   1030 <FindMinCoin@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.coin = [3 x i32] [i32 2, i32 3, i32 5]
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
store i32 6, i32* %1
%4 = bitcast [3 x i32]* %2 to i8*
store i32 3, i32* %3
%5 = load i32, i32* %1
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @FindMinCoin(i32 %5, i32* %6, i32 %7)
ret i32 0
}

LLVM IR (-O2):
@__const.main.coin = [3 x i32] [i32 2, i32 3, i32 5]
define i32 @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 @FindMinCoin(i32 6, i32* %3, i32 3)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ fatal_error(char *, size_t);
void *realloc(void *, size_t);
void *xrealloc(void *ptr, size_t size) {
  void *p = realloc(ptr, size);
  if (!p)
    fatal_error("Out of memory: tried to reallocate %zu bytes", size);
  return p;
}


x86 assembly (clang, -O0):
<xrealloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115c <xrealloc+0x3c>
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1030 <fatal_error@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrealloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1040 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1143 <xrealloc+0x23>
lea    0xec5(%rip),%rdi
mov    %r14,%rsi
call   1030 <fatal_error@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Out of memory: tried to reallocate %zu bytes\00"
define i8* @xrealloc(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = load i64, i64* %4
%8 = call i8* @realloc(i8* %6, i64 %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i64, i64* %4
%13 = call i32 @fatal_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %14
14: ; preds = %11, %2
%15 = load i8*, i8** %5
ret i8* %15
}

LLVM IR (-O2):
@.str = [45 x i8] c"Out of memory: tried to reallocate %zu bytes\00"
define noalias i8* @xrealloc(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @realloc(i8* %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fatal_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %1)
br label %7
7: ; preds = %5, %2
ret i8* %3
}
/* Variables and functions */
int /*<<< orphan*/ HplAtm128GeneralIOPinP__16__IO__clr();
void OscilloscopeC__IOC0__clr(void) { HplAtm128GeneralIOPinP__16__IO__clr(); }


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

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

LLVM IR (-O0):
define void @OscilloscopeC__IOC0__clr() {
%1 = call i32 (...) @HplAtm128GeneralIOPinP__16__IO__clr()
ret void
}

LLVM IR (-O2):
define void @OscilloscopeC__IOC0__clr() {
%1 = tail call i32 (...) @HplAtm128GeneralIOPinP__16__IO__clr()
ret void
}
/* Variables and functions */
int passw();
int /*<<< orphan*/ printf(char *);
int main(void) {
  if (passw() == 1) {
    printf("login ok!");
  } else {
    printf("login failed!\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <passw@plt>
cmp    $0x1,%eax
jne    1150 <main+0x30>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
jmp    115c <main+0x3c>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <passw@plt>
cmp    $0x1,%eax
jne    114b <main+0x1b>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
jmp    1157 <main+0x27>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"login ok!\00"
@.str.1 = [15 x i8] c"login failed!\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @passw()
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = load i32, i32* %1
ret i32 %9
}

LLVM IR (-O2):
@.str = [10 x i8] c"login ok!\00"
@str = [14 x i8] c"login failed!\00"
define i32 @main() {
%1 = tail call i32 (...) @passw()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
ret i32 0
}
/* Variables and functions */
unsigned int strlen(const char *str) {
  unsigned int i = 0;
  while (str[i])
    i++;
  return i;
}


x86 assembly (clang, -O0):
<strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpb   $0x0,(%rax,%rcx,1)
je     112e <strlen+0x2e>
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>:
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x0,(%rdi,%rax,1)
jne    1110 <strlen+0x10>
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 = %11, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* %3
%13 = add 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) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ 0, %1 ], [ %8, %2 ]
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = add i32 %3, 1
br i1 %7, label %9, label %2
9: ; preds = %2
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
void xfree(void *p) {
  if (p) {
    free(p);
    p = NULL;
  }
}


x86 assembly (clang, -O0):
<xfree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1138 <xfree+0x28>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfree>:
test   %rdi,%rdi
je     111a <xfree+0xa>
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
define void @xfree(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 @free(i8* %6)
store i8* null, i8** %2
br label %8
8: ; preds = %5, %1
ret void
}

LLVM IR (-O2):
define void @xfree(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @free(i8* %0)
br label %5
5: ; preds = %3, %1
ret void
}
/* Type definitions */
struct passwd {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct passwd *fgetpwent(int /*<<< orphan*/ *);
struct passwd *get_cuftpd_passwd(int /*<<< orphan*/ *);
struct passwd *get_passwd(FILE *fp, int ftpd) {
  struct passwd *buf;
  if (ftpd == 0x02) {
    buf = get_cuftpd_passwd(fp);
  } else {
    buf = fgetpwent(fp);
  }
  return buf;
}


x86 assembly (clang, -O0):
<get_passwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    114b <get_passwd+0x2b>
mov    -0x8(%rbp),%rdi
call   1040 <get_cuftpd_passwd@plt>
mov    %rax,-0x18(%rbp)
jmp    1158 <get_passwd+0x38>
mov    -0x8(%rbp),%rdi
call   1030 <fgetpwent@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_passwd>:
cmp    $0x2,%esi
jne    112a <get_passwd+0xa>
jmp    1040 <get_cuftpd_passwd@plt>
jmp    1030 <fgetpwent@plt>

LLVM IR (-O0):
%struct.passwd = type { i32 }
define %struct.passwd* @get_passwd(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.passwd*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32*, i32** %3
%10 = call %struct.passwd* @get_cuftpd_passwd(i32* %9)
store %struct.passwd* %10, %struct.passwd** %5
br label %14
11: ; preds = %2
%12 = load i32*, i32** %3
%13 = call %struct.passwd* @fgetpwent(i32* %12)
store %struct.passwd* %13, %struct.passwd** %5
br label %14
14: ; preds = %11, %8
%15 = load %struct.passwd*, %struct.passwd** %5
ret %struct.passwd* %15
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
define %struct.passwd* @get_passwd(i32* %0, i32 %1) {
%3 = icmp eq i32 %1, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call %struct.passwd* @get_cuftpd_passwd(i32* %0)
br label %8
6: ; preds = %2
%7 = tail call %struct.passwd* @fgetpwent(i32* %0)
br label %8
8: ; preds = %6, %4
%9 = phi %struct.passwd* [ %5, %4 ], [ %7, %6 ]
ret %struct.passwd* %9
}
void RAND_screen(void) {}


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

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

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

LLVM IR (-O2):
define void @RAND_screen() {
ret void
}
/* Variables and functions */
scalar_t__ xmalloc(int);
void memleak_xmalloc() {
  char *p = (char *)xmalloc(10);
  p[9] = 0;
}


x86 assembly (clang, -O0):
<memleak_xmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xa,%edi
call   1030 <xmalloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,0x9(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memleak_xmalloc>:
push   %rax
mov    $0xa,%edi
call   1030 <xmalloc@plt>
movb   $0x0,0x9(%rax)
pop    %rax
ret

LLVM IR (-O0):
define void @memleak_xmalloc() {
%1 = alloca i8*
%2 = call i64 @xmalloc(i32 10)
%3 = inttoptr i64 %2 to i8*
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8, i8* %4, i64 9
store i8 0, i8* %5
ret void
}

LLVM IR (-O2):
define void @memleak_xmalloc() {
%1 = tail call i64 @xmalloc(i32 10)
%2 = inttoptr i64 %1 to i8*
%3 = getelementptr inbounds i8, i8* %2, i64 9
store i8 0, i8* %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ k_flip();
void k_finish(void) { k_flip(); }


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

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

LLVM IR (-O0):
define void @k_finish() {
%1 = call i32 (...) @k_flip()
ret void
}

LLVM IR (-O2):
define void @k_finish() {
%1 = tail call i32 (...) @k_flip()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ read_int_ref(int *);
void interprocedural_read_in_callee_bad() {
  int x;
  read_int_ref(&x);
}


x86 assembly (clang, -O0):
<interprocedural_read_in_callee_bad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1030 <read_int_ref@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interprocedural_read_in_callee_bad>:
push   %rax
lea    0x4(%rsp),%rdi
call   1030 <read_int_ref@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @interprocedural_read_in_callee_bad() {
%1 = alloca i32
%2 = call i32 @read_int_ref(i32* %1)
ret void
}

LLVM IR (-O2):
define void @interprocedural_read_in_callee_bad() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @read_int_ref(i32* %1)
ret void
}
/* Type definitions */
typedef int uint64_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t bitScan_fun_uint64_t(uint64_t x) {
  uint32_t r = 64;
  while (x) {
    --r;
    x >>= 1;
  }
  return r;
}


x86 assembly (clang, -O0):
<bitScan_fun_uint64_t>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x40,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112f <bitScan_fun_uint64_t+0x2f>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110e <bitScan_fun_uint64_t+0xe>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitScan_fun_uint64_t>:
mov    $0x40,%eax
test   %edi,%edi
je     111c <bitScan_fun_uint64_t+0x1c>
mov    %edi,%ecx
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%eax
sar    %ecx
cmp    $0x1,%edi
mov    %ecx,%edi
ja     1110 <bitScan_fun_uint64_t+0x10>
ret

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

LLVM IR (-O2):
define i32 @bitScan_fun_uint64_t(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %9, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %6, %3 ], [ 64, %1 ]
%5 = phi i32 [ %7, %3 ], [ %0, %1 ]
%6 = add nsw i32 %4, -1
%7 = ashr i32 %5, 1
%8 = icmp ult i32 %5, 2
br i1 %8, label %9, label %3
9: ; preds = %3, %1
%10 = phi i32 [ 64, %1 ], [ %6, %3 ]
ret i32 %10
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
void TimerPrescaleMatchSet(uint32_t ui32Base, uint32_t ui32Timer,
                           uint32_t ui32Value) {
  ;

  ;
  ;
  if (ui32Timer & 0x000000FF) {
    (*((volatile unsigned long *)(ui32Base + 0x00000040))) = ui32Value;
  }
  if (ui32Timer & 0x0000FF00) {
    (*((volatile unsigned long *)(ui32Base + 0x00000044))) = ui32Value;
  }
}


x86 assembly (clang, -O0):
<TimerPrescaleMatchSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
cmp    $0x0,%eax
je     112d <TimerPrescaleMatchSet+0x2d>
movslq -0xc(%rbp),%rcx
mov    -0x4(%rbp),%eax
add    $0x40,%eax
cltq
mov    %rcx,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff00,%eax
cmp    $0x0,%eax
je     114d <TimerPrescaleMatchSet+0x4d>
movslq -0xc(%rbp),%rcx
mov    -0x4(%rbp),%eax
add    $0x44,%eax
cltq
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleMatchSet>:
movslq %edx,%rax
movslq %edi,%rcx
test   %sil,%sil
je     110f <TimerPrescaleMatchSet+0xf>
mov    %rax,0x40(%rcx)
test   $0xff00,%esi
je     111b <TimerPrescaleMatchSet+0x1b>
mov    %rax,0x44(%rcx)
ret

LLVM IR (-O0):
define void @TimerPrescaleMatchSet(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = and i32 %7, 255
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 64
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i64*
store volatile i64 %12, i64* %16
br label %17
17: ; preds = %10, %3
%18 = load i32, i32* %5
%19 = and i32 %18, 65280
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 68
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i64*
store volatile i64 %23, i64* %27
br label %28
28: ; preds = %21, %17
ret void
}

LLVM IR (-O2):
define void @TimerPrescaleMatchSet(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %1, 255
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = sext i32 %2 to i64
%8 = add nsw i32 %0, 64
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i64*
store volatile i64 %7, i64* %10
br label %11
11: ; preds = %6, %3
%12 = and i32 %1, 65280
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = sext i32 %2 to i64
%16 = add nsw i32 %0, 68
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i64*
store volatile i64 %15, i64* %18
br label %19
19: ; preds = %14, %11
ret void
}
void rotr(int *a, int *b, int *c) {
  int n = *a;
  *a = *c;
  *c = *b;
  *b = n;
}


x86 assembly (clang, -O0):
<rotr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotr>:
mov    (%rdi),%eax
mov    (%rdx),%ecx
mov    %ecx,(%rdi)
mov    (%rsi),%ecx
mov    %ecx,(%rdx)
mov    %eax,(%rsi)
ret

LLVM IR (-O0):
define void @rotr(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
store i32 %9, i32* %7
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = load i32*, i32** %4
store i32 %11, i32* %12
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = load i32*, i32** %6
store i32 %14, i32* %15
%16 = load i32, i32* %7
%17 = load i32*, i32** %5
store i32 %16, i32* %17
ret void
}

LLVM IR (-O2):
define void @rotr(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = load i32, i32* %0
%5 = load i32, i32* %2
store i32 %5, i32* %0
%6 = load i32, i32* %1
store i32 %6, i32* %2
store i32 %4, i32* %1
ret void
}
void f(char *u) {}


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

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

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

LLVM IR (-O2):
define void @f(i8* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ outb(int, int);
void timer_init() {
  outb(0x43, 0x34);
  outb(0x40, 0xA9);
  outb(0x40, 0x4);
}


x86 assembly (clang, -O0):
<timer_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x43,%edi
mov    $0x34,%esi
call   1030 <outb@plt>
mov    $0x40,%edi
mov    $0xa9,%esi
call   1030 <outb@plt>
mov    $0x40,%edi
mov    $0x4,%esi
call   1030 <outb@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<timer_init>:
push   %rax
mov    $0x43,%edi
mov    $0x34,%esi
call   1030 <outb@plt>
mov    $0x40,%edi
mov    $0xa9,%esi
call   1030 <outb@plt>
mov    $0x40,%edi
mov    $0x4,%esi
pop    %rax
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @timer_init() {
%1 = call i32 @outb(i32 67, i32 52)
%2 = call i32 @outb(i32 64, i32 169)
%3 = call i32 @outb(i32 64, i32 4)
ret void
}

LLVM IR (-O2):
define void @timer_init() {
%1 = tail call i32 @outb(i32 67, i32 52)
%2 = tail call i32 @outb(i32 64, i32 169)
%3 = tail call i32 @outb(i32 64, i32 4)
ret void
}
/* Variables and functions */
int t(int);
int f(int i) {
  int result;
  result = t(i);
  if (result)
    return result;
  return 0;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <t@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     113b <f+0x2b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1142 <f+0x32>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
jmp    1030 <t@plt>

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

LLVM IR (-O2):
define i32 @f(i32 %0) {
%2 = tail call i32 @t(i32 %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ init_getbits();
void decode_start_lzs() { init_getbits(); }


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

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

LLVM IR (-O0):
define void @decode_start_lzs() {
%1 = call i32 (...) @init_getbits()
ret void
}

LLVM IR (-O2):
define void @decode_start_lzs() {
%1 = tail call i32 (...) @init_getbits()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ prepare_signal_handler();
void signal_handler(int signal) {
  switch (signal) {
  default:
    break;
  }
  prepare_signal_handler();
}


x86 assembly (clang, -O0):
<signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
jmp    1120 <signal_handler+0x10>
mov    $0x0,%al
call   1030 <prepare_signal_handler@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @signal_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %4 [
]
4: ; preds = %1
br label %5
5: ; preds = %4
%6 = call i32 (...) @prepare_signal_handler()
ret void
}

LLVM IR (-O2):
define void @signal_handler(i32 %0) {
%2 = tail call i32 (...) @prepare_signal_handler()
ret void
}
unsigned realhash(char *string2hash, int tablesize) {
  int hash;
  for (hash = 0; *string2hash != '\0'; string2hash++) {
    hash = (64 * hash + *string2hash) % tablesize;
  }
  return hash;
}


x86 assembly (clang, -O0):
<realhash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1149 <realhash+0x49>
mov    -0x10(%rbp),%eax
shl    $0x6,%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1112 <realhash+0x12>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<realhash>:
mov    (%rdi),%al
test   %al,%al
je     112b <realhash+0x2b>
add    $0x1,%rdi
xor    %edx,%edx
nopl   0x0(%rax)
movsbl %al,%eax
shl    $0x6,%edx
add    %eax,%edx
mov    %edx,%eax
cltd
idiv   %esi
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
jne    1110 <realhash+0x10>
mov    %edx,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @realhash(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %14, %5 ], [ %3, %2 ]
%7 = phi i32 [ %12, %5 ], [ 0, %2 ]
%8 = phi i8* [ %13, %5 ], [ %0, %2 ]
%9 = sext i8 %6 to i32
%10 = shl nsw i32 %7, 6
%11 = add nsw i32 %10, %9
%12 = srem i32 %11, %1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %2
%17 = phi i32 [ 0, %2 ], [ %12, %5 ]
ret i32 %17
}
void TIM2_IRQHandler() {}


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

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

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

LLVM IR (-O2):
define void @TIM2_IRQHandler() {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ munmap(void *, int /*<<< orphan*/);
void unmap_file(void *mapping, uint64_t len) {
  if (mapping)
    munmap(mapping, len);
}


x86 assembly (clang, -O0):
<unmap_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1136 <unmap_file+0x26>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <munmap@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unmap_file>:
test   %rdi,%rdi
je     111a <unmap_file+0xa>
jmp    1030 <munmap@plt>
ret

LLVM IR (-O0):
define void @unmap_file(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @munmap(i8* %8, i32 %9)
br label %11
11: ; preds = %7, %2
ret void
}

LLVM IR (-O2):
define void @unmap_file(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @munmap(i8* %0, i32 %1)
br label %6
6: ; preds = %4, %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _npop_frame(int);
void _npop_handler(int n) { _npop_frame(n); }


x86 assembly (clang, -O0):
<_npop_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <_npop_frame@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_npop_handler>:
jmp    1030 <_npop_frame@plt>

LLVM IR (-O0):
define void @_npop_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @_npop_frame(i32 %3)
ret void
}

LLVM IR (-O2):
define void @_npop_handler(i32 %0) {
%2 = tail call i32 @_npop_frame(i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ foobar(int);
int main() {
  foobar(20);
  return 0;
}


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

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

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @foobar(i32 20)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @foobar(i32 20)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void prompt() {
  printf("]> ");
  fflush(stdout);
  return;
}


x86 assembly (clang, -O0):
<prompt>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"]> \00"
@stdout = global i32 0
define void @prompt() {
%1 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @stdout
%3 = call i32 @fflush(i32 %2)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"]> \00"
@stdout = global i32 0
define void @prompt() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @stdout
%3 = tail call i32 @fflush(i32 %2)
ret void
}
int countWord(char *s) {
  int i = 1;
  while (*s != '\0') {
    if (*s >= 'A' && *s <= 'Z')
      i++;
    s++;
  }
  return i;
}


x86 assembly (clang, -O0):
<countWord>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1159 <countWord+0x59>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1148 <countWord+0x48>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     1148 <countWord+0x48>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <countWord+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<countWord>:
mov    (%rdi),%cl
test   %cl,%cl
je     1125 <countWord+0x25>
add    $0x1,%rdi
mov    $0x1,%eax
nop
add    $0xbf,%cl
cmp    $0x1a,%cl
adc    $0x0,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1110 <countWord+0x10>
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @countWord(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
br label %4
4: ; preds = %22, %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 %25
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 65
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sle i32 %17, 90
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %14, %9
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
br label %4
25: ; preds = %4
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @countWord(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %13, %4 ], [ %2, %1 ]
%6 = phi i32 [ %11, %4 ], [ 1, %1 ]
%7 = phi i8* [ %12, %4 ], [ %0, %1 ]
%8 = add i8 %5, -65
%9 = icmp ult i8 %8, 26
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %6, %10
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4, %1
%16 = phi i32 [ 1, %1 ], [ %11, %4 ]
ret i32 %16
}