xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ a_fun();
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("hello, it is main\n\r");
  a_fun();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <a_fun@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <a_fun@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"hello, it is main\0A\0D\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @a_fun()
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"hello, it is main\0A\0D\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @a_fun()
ret i32 0
}
int findElement(int array[], int n, int key) {
  int i;
  for (i = 0; i < n; ++i) {
    if (array[i] == key) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<findElement>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1153 <findElement+0x53>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
jne    1140 <findElement+0x40>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115a <findElement+0x5a>
jmp    1145 <findElement+0x45>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1115 <findElement+0x15>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<findElement>:
mov    $0xffffffff,%eax
test   %esi,%esi
jle    111e <findElement+0x1e>
mov    %esi,%esi
xor    %ecx,%ecx
nopl   (%rax)
cmp    %edx,(%rdi,%rcx,4)
je     111f <findElement+0x1f>
add    $0x1,%rcx
cmp    %rcx,%rsi
jne    1110 <findElement+0x10>
ret
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @findElement(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %12
%8 = phi i64 [ 0, %5 ], [ %13, %12 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, %2
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %17, label %7
15: ; preds = %7
%16 = trunc i64 %8 to i32
br label %17
17: ; preds = %12, %15, %3
%18 = phi i32 [ -1, %3 ], [ %16, %15 ], [ -1, %12 ]
ret i32 %18
}
/* Type definitions */
typedef int uint32_t;
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ mpz_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set_si(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
void mpz_set_max_int(mpz_t z, uint32_t k) {
  assert(k >= 1);
  mpz_set_si(z, 1);
  mpz_mul_2exp(z, z, k - 1);
  mpz_sub_ui(z, z, 1);
}


x86 assembly (clang, -O0):
<mpz_set_max_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <mpz_set_si@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1050 <mpz_mul_2exp@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpz_sub_ui@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_set_max_int>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
test   %esi,%esi
setg   %dil
call   1040 <assert@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <mpz_set_si@plt>
add    $0xffffffff,%ebx
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <mpz_mul_2exp@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <mpz_sub_ui@plt>

LLVM IR (-O0):
define void @mpz_set_max_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sge i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %3
%10 = call i32 @mpz_set_si(i32 %9, i32 1)
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 @mpz_mul_2exp(i32 %11, i32 %12, i32 %14)
%16 = load i32, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @mpz_sub_ui(i32 %16, i32 %17, i32 1)
ret void
}

LLVM IR (-O2):
define void @mpz_set_max_int(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @mpz_set_si(i32 %0, i32 1)
%7 = add nsw i32 %1, -1
%8 = tail call i32 @mpz_mul_2exp(i32 %0, i32 %0, i32 %7)
%9 = tail call i32 @mpz_sub_ui(i32 %0, i32 %0, i32 1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void emit_help(void) {
  fputs("Usage: myat [-C dir] YYYY-MM-DD [HH:MM]\n"
        "       myat [-C dir] HH:MM      (assumes today)\n",
        stderr);
  exit(EX_USAGE);
}


x86 assembly (clang, -O0):
<emit_help>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
lea    0xecc(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<emit_help>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
lea    0xecf(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [89 x i8] c"Usage: myat [-C dir] YYYY-MM-DD [HH:MM]\0A myat [-C dir] HH:MM (assumes today)\0A\00"
@stderr = global i32 0
@EX_USAGE = global i32 0
define void @emit_help() {
%1 = load i32, i32* @stderr
%2 = call i32 @fputs(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @EX_USAGE
%4 = call i32 @exit(i32 %3)
unreachable
}

LLVM IR (-O2):
@.str = [89 x i8] c"Usage: myat [-C dir] YYYY-MM-DD [HH:MM]\0A myat [-C dir] HH:MM (assumes today)\0A\00"
@stderr = global i32 0
@EX_USAGE = global i32 0
define void @emit_help() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fputs(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @EX_USAGE
%4 = tail call i32 @exit(i32 %3)
unreachable
}
void music_newplaylist(void) {}


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

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

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

LLVM IR (-O2):
define void @music_newplaylist() {
ret void
}
int exponen(m)
int m;
{
  int i, ex;
  ex = 1;
  for (i = 0; i < m; i++)
    ex <<= 1;
  return (ex);
}


x86 assembly (clang, -O0):
<exponen>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1138 <exponen+0x38>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1115 <exponen+0x15>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<exponen>:
test   %edi,%edi
jle    1118 <exponen+0x18>
lea    -0x1(%rdi),%eax
mov    %edi,%ecx
and    $0x7,%ecx
cmp    $0x7,%eax
jae    111e <exponen+0x1e>
mov    $0x1,%eax
jmp    1138 <exponen+0x38>
mov    $0x1,%eax
ret
and    $0xfffffff8,%edi
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
shl    $0x8,%eax
add    $0xfffffff8,%edi
jne    1130 <exponen+0x30>
test   %ecx,%ecx
je     1147 <exponen+0x47>
nopl   0x0(%rax)
add    %eax,%eax
add    $0xffffffff,%ecx
jne    1140 <exponen+0x40>
ret

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

LLVM IR (-O2):
define i32 @exponen(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %25
3: ; preds = %1
%4 = add i32 %0, -1
%5 = and i32 %0, 7
%6 = icmp ult i32 %4, 7
br i1 %6, label %15, label %7
7: ; preds = %3
%8 = and i32 %0, -8
br label %9
9: ; preds = %9, %7
%10 = phi i32 [ 1, %7 ], [ %12, %9 ]
%11 = phi i32 [ 0, %7 ], [ %13, %9 ]
%12 = shl i32 %10, 8
%13 = add i32 %11, 8
%14 = icmp eq i32 %13, %8
br i1 %14, label %15, label %9
15: ; preds = %9, %3
%16 = phi i32 [ undef, %3 ], [ %12, %9 ]
%17 = phi i32 [ 1, %3 ], [ %12, %9 ]
%18 = icmp eq i32 %5, 0
br i1 %18, label %25, label %19
19: ; preds = %15, %19
%20 = phi i32 [ %22, %19 ], [ %17, %15 ]
%21 = phi i32 [ %23, %19 ], [ 0, %15 ]
%22 = shl i32 %20, 1
%23 = add i32 %21, 1
%24 = icmp eq i32 %23, %5
br i1 %24, label %25, label %19
25: ; preds = %15, %19, %1
%26 = phi i32 [ 1, %1 ], [ %16, %15 ], [ %22, %19 ]
ret i32 %26
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
int /*<<< orphan*/ sleep(int);
void writer(const char *message, int count, FILE *stream) {
  for (; count > 0; count--) {
    fprintf(stream, "%s\n", message);
    fflush(stream);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<writer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1182 <writer+0x52>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <writer+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1178 <writer+0x48>
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
add    $0x1,%ebp
lea    0xeb3(%rip),%r15
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1150 <writer+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @writer(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
br label %7
7: ; preds = %17, %3
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32*, i32** %6
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %6
%15 = call i32 @fflush(i32* %14)
%16 = call i32 @sleep(i32 1)
br label %17
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, -1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @writer(i8* %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i32 [ %10, %5 ], [ %1, %3 ]
%7 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @fflush(i32* %2)
%9 = tail call i32 @sleep(i32 1)
%10 = add nsw i32 %6, -1
%11 = icmp ugt i32 %6, 1
br i1 %11, label %5, label %12
12: ; preds = %5, %3
ret void
}
void CLI_Prompt(void) {}


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

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

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

LLVM IR (-O2):
define void @CLI_Prompt() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ bar();
int /*<<< orphan*/ baz();
int /*<<< orphan*/ foo();
void test(int i) {
  switch (i) {
  case 1:
    foo();
    break;
  case 2:
    bar();
    break;
  default:
    break;
  }
  switch (i) {
  case 1:
    foo();
    break;
  case 2:
    baz();
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     1160 <test+0x30>
jmp    114f <test+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     116c <test+0x3c>
jmp    1178 <test+0x48>
mov    $0x0,%al
call   1050 <foo@plt>
jmp    117d <test+0x4d>
mov    $0x0,%al
call   1040 <bar@plt>
jmp    117d <test+0x4d>
jmp    117d <test+0x4d>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11a2 <test+0x72>
jmp    1191 <test+0x61>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11ae <test+0x7e>
jmp    11ba <test+0x8a>
mov    $0x0,%al
call   1050 <foo@plt>
jmp    11bf <test+0x8f>
mov    $0x0,%al
call   1030 <baz@plt>
jmp    11bf <test+0x8f>
jmp    11bf <test+0x8f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rax
cmp    $0x2,%edi
je     114a <test+0x1a>
cmp    $0x1,%edi
jne    1159 <test+0x29>
xor    %eax,%eax
call   1050 <foo@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <foo@plt>
xor    %eax,%eax
call   1040 <bar@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <baz@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @test(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %8 [
i32 1, label %4
i32 2, label %6
]
4: ; preds = %1
%5 = call i32 (...) @foo()
br label %9
6: ; preds = %1
%7 = call i32 (...) @bar()
br label %9
8: ; preds = %1
br label %9
9: ; preds = %8, %6, %4
%10 = load i32, i32* %2
switch i32 %10, label %15 [
i32 1, label %11
i32 2, label %13
]
11: ; preds = %9
%12 = call i32 (...) @foo()
br label %16
13: ; preds = %9
%14 = call i32 (...) @baz()
br label %16
15: ; preds = %9
br label %16
16: ; preds = %15, %13, %11
ret void
}

LLVM IR (-O2):
define void @test(i32 %0) {
switch i32 %0, label %8 [
i32 1, label %2
i32 2, label %5
]
2: ; preds = %1
%3 = tail call i32 (...) @foo()
%4 = tail call i32 (...) @foo()
br label %8
5: ; preds = %1
%6 = tail call i32 (...) @bar()
%7 = tail call i32 (...) @baz()
br label %8
8: ; preds = %1, %5, %2
ret void
}
int hamming_weight(int v) {
  v = v - ((v >> 1) & 0x55555555);
  v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
  return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


x86 assembly (clang, -O0):
<hamming_weight>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
and    $0x55555555,%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x33333333,%eax
mov    -0x4(%rbp),%ecx
sar    $0x2,%ecx
and    $0x33333333,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x4,%ecx
add    %ecx,%eax
and    $0xf0f0f0f,%eax
imul   $0x1010101,%eax,%eax
sar    $0x18,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming_weight>:
mov    %edi,%eax
shr    %eax
and    $0x55555555,%eax
sub    %eax,%edi
mov    %edi,%eax
and    $0x33333333,%eax
shr    $0x2,%edi
and    $0x33333333,%edi
add    %eax,%edi
mov    %edi,%eax
shr    $0x4,%eax
add    %edi,%eax
and    $0xf0f0f0f,%eax
imul   $0x1010101,%eax,%eax
shr    $0x18,%eax
ret

LLVM IR (-O0):
define i32 @hamming_weight(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = ashr i32 %4, 1
%6 = and i32 %5, 1431655765
%7 = sub nsw i32 %3, %6
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = and i32 %8, 858993459
%10 = load i32, i32* %2
%11 = ashr i32 %10, 2
%12 = and i32 %11, 858993459
%13 = add nsw i32 %9, %12
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = load i32, i32* %2
%16 = ashr i32 %15, 4
%17 = add nsw i32 %14, %16
%18 = and i32 %17, 252645135
%19 = mul nsw i32 %18, 16843009
%20 = ashr i32 %19, 24
ret i32 %20
}

LLVM IR (-O2):
define i32 @hamming_weight(i32 %0) {
%2 = lshr i32 %0, 1
%3 = and i32 %2, 1431655765
%4 = sub nsw i32 %0, %3
%5 = and i32 %4, 858993459
%6 = lshr i32 %4, 2
%7 = and i32 %6, 858993459
%8 = add nuw nsw i32 %7, %5
%9 = lshr i32 %8, 4
%10 = add nuw nsw i32 %9, %8
%11 = and i32 %10, 252645135
%12 = mul nsw i32 %11, 16843009
%13 = lshr i32 %12, 24
ret i32 %13
}
/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ copytoglobal();
int /*<<< orphan*/ printf(char *);
int main() {
  char buffer[128] = {0};
  printf("I included libc for you...\n"
         "Can you ROP to system()?\n");
  copytoglobal();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <copytoglobal@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <copytoglobal@plt>
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [53 x i8] c"I included libc for you...\0ACan you ROP to system()?\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = bitcast [128 x i8]* %2 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @copytoglobal()
%6 = load i32, i32* @EXIT_SUCCESS
ret i32 %6
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [52 x i8] c"I included libc for you...\0ACan you ROP to system()?\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @copytoglobal()
%3 = load i32, i32* @EXIT_SUCCESS
ret i32 %3
}
/* Variables and functions */
scalar_t__ newmemory(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strdup(char *s) {
  char *d = (char *)newmemory(strlen(s) + 1);
  strcpy(d, s);
  return d;
}


x86 assembly (clang, -O0):
<strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <newmemory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdup>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1040 <newmemory@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @strdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = call i64 @newmemory(i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %3
ret i8* %12
}

LLVM IR (-O2):
define i8* @strdup(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i64 @newmemory(i64 %3)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
ret i8* %5
}
/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ report_test2(int, int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, char *);
int symlink(char *, char *);
void symlink_empty1(void) {
  int rv;
  rv = symlink("", "badcalllink");
  report_test2(rv, errno, 0, EINVAL, "symlink -> empty string");
  remove("badcalllink");
}


x86 assembly (clang, -O0):
<symlink_empty1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee4(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1050 <symlink@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    0x2e77(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
lea    0xea0(%rip),%r8
call   1040 <report_test2@plt>
lea    0xe88(%rip),%rdi
call   1030 <remove@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symlink_empty1>:
push   %rbx
lea    0xeeb(%rip),%rdi
lea    0xec1(%rip),%rbx
mov    %rbx,%rsi
call   1050 <symlink@plt>
mov    0x2e92(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e81(%rip),%rcx
mov    (%rcx),%ecx
lea    0xeac(%rip),%r8
mov    %eax,%edi
xor    %edx,%edx
call   1040 <report_test2@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <remove@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [12 x i8] c"badcalllink\00"
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [24 x i8] c"symlink -> empty string\00"
define void @symlink_empty1() {
%1 = alloca i32
%2 = call i32 @symlink(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = load i32, i32* @errno
%5 = load i32, i32* @EINVAL
%6 = call i32 @report_test2(i32 %3, i32 %4, i32 0, i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @remove(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [12 x i8] c"badcalllink\00"
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [24 x i8] c"symlink -> empty string\00"
define void @symlink_empty1() {
%1 = tail call i32 @symlink(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @errno
%3 = load i32, i32* @EINVAL
%4 = tail call i32 @report_test2(i32 %1, i32 %2, i32 0, i32 %3, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @remove(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
ret void
}
short ABS(short var) {
  short newvar = var;
  if (newvar < 0)
    newvar *= -1;
  return newvar;
}


x86 assembly (clang, -O0):
<ABS>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    -0x2(%rbp),%ax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
cmp    $0x0,%eax
jge    112b <ABS+0x2b>
movswl -0x4(%rbp),%eax
imul   $0xffffffff,%eax,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ABS>:
mov    %edi,%eax
neg    %ax
cmovs  %di,%ax
ret

LLVM IR (-O0):
define signext i16 @ABS(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %2
%4 = load i16, i16* %2
store i16 %4, i16* %3
%5 = load i16, i16* %3
%6 = sext i16 %5 to i32
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i16, i16* %3
%10 = sext i16 %9 to i32
%11 = mul nsw i32 %10, -1
%12 = trunc i32 %11 to i16
store i16 %12, i16* %3
br label %13
13: ; preds = %8, %1
%14 = load i16, i16* %3
ret i16 %14
}

LLVM IR (-O2):
define signext i16 @ABS(i16 signext %0) {
%2 = tail call i16 @llvm.abs.i16(i16 %0, i1 false)
ret i16 %2
}
int execute_sysinfo() { return 0; }


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

x86 assembly (clang, -O2):
<execute_sysinfo>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @execute_sysinfo() {
ret i32 0
}

LLVM IR (-O2):
define i32 @execute_sysinfo() {
ret i32 0
}
int returnIntI(int arg) { return arg; }


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

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

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

LLVM IR (-O2):
define i32 @returnIntI(i32 returned %0) {
ret i32 %0
}
int isconsonant(int c) {
  const unsigned letter_mask =
      (1 << ('b' - 'a')) | (1 << ('c' - 'a')) | (1 << ('d' - 'a')) |
      (1 << ('f' - 'a')) | (1 << ('g' - 'a')) | (1 << ('h' - 'a')) |
      (1 << ('j' - 'a')) | (1 << ('k' - 'a')) | (1 << ('l' - 'a')) |
      (1 << ('m' - 'a')) | (1 << ('n' - 'a')) | (1 << ('p' - 'a')) |
      (1 << ('q' - 'a')) | (1 << ('r' - 'a')) | (1 << ('s' - 'a')) |
      (1 << ('t' - 'a')) | (1 << ('v' - 'a')) | (1 << ('w' - 'a')) |
      (1 << ('x' - 'a')) | (1 << ('y' - 'a')) | (1 << ('z' - 'a'));
  unsigned x = (c | 32) - 'a';
  return ((x < 32) << (x & 31)) & letter_mask;
}


x86 assembly (clang, -O0):
<isconsonant>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x3efbeee,-0x8(%rbp)
mov    -0x4(%rbp),%eax
or     $0x20,%eax
sub    $0x61,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0xc(%rbp),%ecx
and    $0x1f,%ecx
shl    %cl,%eax
and    $0x3efbeee,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isconsonant>:
or     $0x20,%edi
lea    -0x61(%rdi),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
setb   %al
shl    %cl,%eax
and    $0x3efbeee,%eax
ret

LLVM IR (-O0):
define i32 @isconsonant(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 66043630, i32* %3
%5 = load i32, i32* %2
%6 = or i32 %5, 32
%7 = sub nsw i32 %6, 97
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ult i32 %8, 32
%10 = zext i1 %9 to i32
%11 = load i32, i32* %4
%12 = and i32 %11, 31
%13 = shl i32 %10, %12
%14 = and i32 %13, 66043630
ret i32 %14
}

LLVM IR (-O2):
define i32 @isconsonant(i32 %0) {
%2 = or i32 %0, 32
%3 = add nsw i32 %2, -97
%4 = icmp ult i32 %3, 32
%5 = zext i1 %4 to i32
%6 = and i32 %3, 31
%7 = shl nuw i32 %5, %6
%8 = and i32 %7, 66043630
ret i32 %8
}
/* Variables and functions */
float randu(float, float);
float randn() {
  return randu(-1.0f, 1.0f) + randu(-1.0f, 1.0f) + randu(-1.0f, 1.0f);
}


x86 assembly (clang, -O0):
<randn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  0xee0(%rip),%xmm0
movss  0xedc(%rip),%xmm1
call   1030 <randu@plt>
movss  %xmm0,-0x8(%rbp)
movss  0xec6(%rip),%xmm0
movss  0xec2(%rip),%xmm1
call   1030 <randu@plt>
movaps %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xea0(%rip),%xmm0
movss  0xe9c(%rip),%xmm1
call   1030 <randu@plt>
movaps %xmm0,%xmm1
movss  -0x4(%rbp),%xmm0
addss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randn>:
push   %rax
movss  0xee7(%rip),%xmm0
movss  0xee3(%rip),%xmm1
call   1030 <randu@plt>
movss  %xmm0,0x4(%rsp)
movss  0xecc(%rip),%xmm0
movss  0xec8(%rip),%xmm1
call   1030 <randu@plt>
addss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xeab(%rip),%xmm0
movss  0xea7(%rip),%xmm1
call   1030 <randu@plt>
addss  0x4(%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @randn() {
%1 = call float @randu(float -1.000000e+00, float 1.000000e+00)
%2 = call float @randu(float -1.000000e+00, float 1.000000e+00)
%3 = fadd float %1, %2
%4 = call float @randu(float -1.000000e+00, float 1.000000e+00)
%5 = fadd float %3, %4
ret float %5
}

LLVM IR (-O2):
define float @randn() {
%1 = tail call float @randu(float -1.000000e+00, float 1.000000e+00)
%2 = tail call float @randu(float -1.000000e+00, float 1.000000e+00)
%3 = fadd float %1, %2
%4 = tail call float @randu(float -1.000000e+00, float 1.000000e+00)
%5 = fadd float %3, %4
ret float %5
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void EPIDMATxCount(uint32_t ui32Base, uint32_t ui32Count) {
  ASSERT(ui32Base == 0x400D0000);
  ASSERT(ui32Count <= 1024);
  (*((volatile uint32_t *)(ui32Base + 0x00000208))) = ui32Count & 0xffff;
}


x86 assembly (clang, -O0):
<EPIDMATxCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x400d0000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x400,-0x8(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%ecx
and    $0xffff,%ecx
mov    -0x4(%rbp),%eax
add    $0x208,%eax
cltq
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EPIDMATxCount>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x400d0000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x401,%ebx
setl   %dil
call   1030 <ASSERT@plt>
movzwl %bx,%eax
movslq %ebp,%rcx
mov    %eax,0x208(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @EPIDMATxCount(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 1074593792
%7 = zext i1 %6 to i32
%8 = call i32 @ASSERT(i32 %7)
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 1024
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %4
%14 = and i32 %13, 65535
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 520
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
store volatile i32 %14, i32* %18
ret void
}

LLVM IR (-O2):
define void @EPIDMATxCount(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 1074593792
%4 = zext i1 %3 to i32
%5 = tail call i32 @ASSERT(i32 %4)
%6 = icmp slt i32 %1, 1025
%7 = zext i1 %6 to i32
%8 = tail call i32 @ASSERT(i32 %7)
%9 = and i32 %1, 65535
%10 = add nsw i32 %0, 520
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
store volatile i32 %9, i32* %12
ret void
}
/* Variables and functions */
int /*<<< orphan*/ assert(int);
int append_bit(int n, int bit) {
  assert(bit == 0 || bit == 1);
  int new_n = n << 1;
  new_n = new_n | bit;
  return new_n;
}


x86 assembly (clang, -O0):
<append_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1137 <append_bit+0x27>
cmpl   $0x1,-0x8(%rbp)
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_bit>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x2,%esi
setb   %dil
call   1030 <assert@plt>
add    %ebp,%ebp
or     %ebx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @append_bit(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br label %11
11: ; preds = %8, %2
%12 = phi i1 [ true, %2 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %3
%16 = shl i32 %15, 1
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = or i32 %17, %18
store i32 %19, i32* %5
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
define i32 @append_bit(i32 %0, i32 %1) {
%3 = icmp ult i32 %1, 2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = shl i32 %0, 1
%7 = or i32 %6, %1
ret i32 %7
}
void file_take_write(struct file *filp) {}


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

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

LLVM IR (-O0):
%struct.file = type opaque
define void @file_take_write(%struct.file* %0) {
%2 = alloca %struct.file*
store %struct.file* %0, %struct.file** %2
ret void
}

LLVM IR (-O2):
%struct.file = type opaque
define void @file_take_write(%struct.file* nocapture %0) {
ret void
}
int main() {
  struct {
    int x;
  } s = {0};
  return s.x;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.anon = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.anon
store i32 0, i32* %1
%3 = bitcast %struct.anon* %2 to i8*
%4 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 0
%5 = load i32, i32* %4
ret i32 %5
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
int rule_C() {}


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

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

LLVM IR (-O0):
define i32 @rule_C() {
%1 = alloca i32
%2 = load i32, i32* %1
ret i32 %2
}

LLVM IR (-O2):
define i32 @rule_C() {
ret i32 undef
}
/* Variables and functions */
int strlen(char const *);
char *xml_utf8_encode(char const *, int, int *, char *);
char *utf8_encode(const char *str) {
  char *out;
  if (strlen(str)) {
    int alen, len;
    alen = strlen(str);
    out = xml_utf8_encode(str, alen, &len, "ISO-8859-1");
  }
  return out;
}


x86 assembly (clang, -O0):
<utf8_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
je     1165 <utf8_encode+0x45>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdx
lea    0xea4(%rip),%rcx
call   1030 <xml_utf8_encode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_encode>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     1151 <utf8_encode+0x31>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xec0(%rip),%rcx
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <xml_utf8_encode@plt>
jmp    1151 <utf8_encode+0x31>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ISO-8859-1\00"
define i8* @utf8_encode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = call i8* @xml_utf8_encode(i8* %12, i32 %13, i32* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %3
br label %15
15: ; preds = %9, %1
%16 = load i8*, i8** %3
ret i8* %16
}

LLVM IR (-O2):
@.str = [11 x i8] c"ISO-8859-1\00"
define i8* @utf8_encode(i8* %0) {
%2 = alloca i32
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 @strlen(i8* %0)
%8 = call i8* @xml_utf8_encode(i8* %0, i32 %7, i32* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %5, %1
%10 = phi i8* [ %8, %5 ], [ undef, %1 ]
ret i8* %10
}
/* Variables and functions */
void free(void *);
void USB_Free(void *ptr) { return free(ptr); }


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

x86 assembly (clang, -O2):
<USB_Free>:
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @USB_Free(i8* nocapture %0) {
tail call void @free(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ sectioning_underscore(char *);
void cm_appendixsec(void) { sectioning_underscore("appendixsec"); }


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

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

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

LLVM IR (-O2):
@.str = [12 x i8] c"appendixsec\00"
define void @cm_appendixsec() {
%1 = tail call i32 @sectioning_underscore(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ CP15DCacheFlush();
void CacheDataInvalidateAll(void) { CP15DCacheFlush(); }


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

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

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

LLVM IR (-O2):
define void @CacheDataInvalidateAll() {
%1 = tail call i32 (...) @CP15DCacheFlush()
ret void
}
void sti(void) { asm("sti"); }


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

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

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

LLVM IR (-O2):
define void @sti() {
tail call void asm sideeffect "sti", "~{dirflag},~{fpsr},~{flags}"()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ cffti1(int, float *, int *);
void cffti(int n, float wsave[]) {
  int iw1, iw2;
  if (n == 1)
    return;
  iw1 = 2 * n;
  iw2 = iw1 + 2 * n;
  cffti1(n, wsave + iw1, (int *)(wsave + iw2));
}


x86 assembly (clang, -O0):
<cffti>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    112e <cffti+0x1e>
jmp    116b <cffti+0x5b>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
call   1030 <cffti1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cffti>:
cmp    $0x1,%edi
jne    1116 <cffti+0x6>
ret
lea    (%rdi,%rdi,1),%eax
lea    0x0(,%rdi,4),%ecx
cltq
lea    (%rsi,%rax,4),%rax
movslq %ecx,%rcx
lea    (%rsi,%rcx,4),%rdx
mov    %rax,%rsi
jmp    1030 <cffti1@plt>

LLVM IR (-O0):
define void @cffti(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
br label %28
10: ; preds = %2
%11 = load i32, i32* %3
%12 = mul nsw i32 2, %11
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = mul nsw i32 2, %14
%16 = add nsw i32 %13, %15
store i32 %16, i32* %6
%17 = load i32, i32* %3
%18 = load float*, float** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float*, float** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
%26 = bitcast float* %25 to i32*
%27 = call i32 @cffti1(i32 %17, float* %21, i32* %26)
br label %28
28: ; preds = %10, %9
ret void
}

LLVM IR (-O2):
define void @cffti(i32 %0, float* %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = shl nsw i32 %0, 1
%6 = shl nsw i32 %0, 2
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds float, float* %1, i64 %7
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds float, float* %1, i64 %9
%11 = bitcast float* %10 to i32*
%12 = tail call i32 @cffti1(i32 %0, float* %8, i32* %11)
br label %13
13: ; preds = %2, %4
ret void
}
void exynos4_default_mshci(void) {}


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

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

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

LLVM IR (-O2):
define void @exynos4_default_mshci() {
ret void
}
int test_imm_C0uint64_highword_mem(unsigned long long *val) {
  return ((*val >> 32) & (0xC0 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_C0uint64_highword_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
shr    $0x20,%rdx
and    $0xc0,%rdx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @test_imm_C0uint64_highword_mem(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = load i64, i64* %3
%5 = lshr i64 %4, 32
%6 = and i64 %5, 192
%7 = icmp ne i64 %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_C0uint64_highword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 824633720832
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void dummy_rdp() { printf("\n"); }


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

x86 assembly (clang, -O2):
<dummy_rdp>:
mov    $0xa,%edi
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @dummy_rdp() {
%1 = tail call i32 @putchar(i32 10)
ret void
}
/* Variables and functions */
long _tfsctrl(int, long, long);
int /*<<< orphan*/ monLock();
int /*<<< orphan*/ monUnlock();
long mon_tfsctrl(int rqst, long arg1, long arg2) {
  long ret;
  monLock();
  ret = _tfsctrl(rqst, arg1, arg2);
  monUnlock();
  return (ret);
}


x86 assembly (clang, -O0):
<mon_tfsctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1030 <monLock@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <_tfsctrl@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <monUnlock@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mon_tfsctrl>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <monLock@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <_tfsctrl@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <monUnlock@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @mon_tfsctrl(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = call i32 (...) @monLock()
%9 = load i32, i32* %4
%10 = load i64, i64* %5
%11 = load i64, i64* %6
%12 = call i64 @_tfsctrl(i32 %9, i64 %10, i64 %11)
store i64 %12, i64* %7
%13 = call i32 (...) @monUnlock()
%14 = load i64, i64* %7
ret i64 %14
}

LLVM IR (-O2):
define i64 @mon_tfsctrl(i32 %0, i64 %1, i64 %2) {
%4 = tail call i32 (...) @monLock()
%5 = tail call i64 @_tfsctrl(i32 %0, i64 %1, i64 %2)
%6 = tail call i32 (...) @monUnlock()
ret i64 %5
}
void gtk_text_iter_copy() {}


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

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

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

LLVM IR (-O2):
define void @gtk_text_iter_copy() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ bignum_to_fixnum(int /*<<< orphan*/);
int /*<<< orphan*/ dpeek();
int /*<<< orphan*/ drepl(int /*<<< orphan*/);
int /*<<< orphan*/ tag_fixnum(int /*<<< orphan*/);
int /*<<< orphan*/ untag_object(int /*<<< orphan*/);
void primitive_bignum_to_fixnum_impl(void) {
  drepl(tag_fixnum(bignum_to_fixnum(untag_object(dpeek()))));
}


x86 assembly (clang, -O0):
<primitive_bignum_to_fixnum_impl>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <dpeek@plt>
mov    %eax,%edi
call   1040 <untag_object@plt>
mov    %eax,%edi
call   1070 <bignum_to_fixnum@plt>
mov    %eax,%edi
call   1050 <tag_fixnum@plt>
mov    %eax,%edi
call   1060 <drepl@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<primitive_bignum_to_fixnum_impl>:
push   %rax
xor    %eax,%eax
call   1030 <dpeek@plt>
mov    %eax,%edi
call   1040 <untag_object@plt>
mov    %eax,%edi
call   1070 <bignum_to_fixnum@plt>
mov    %eax,%edi
call   1050 <tag_fixnum@plt>
mov    %eax,%edi
pop    %rax
jmp    1060 <drepl@plt>

LLVM IR (-O0):
define void @primitive_bignum_to_fixnum_impl() {
%1 = call i32 (...) @dpeek()
%2 = call i32 @untag_object(i32 %1)
%3 = call i32 @bignum_to_fixnum(i32 %2)
%4 = call i32 @tag_fixnum(i32 %3)
%5 = call i32 @drepl(i32 %4)
ret void
}

LLVM IR (-O2):
define void @primitive_bignum_to_fixnum_impl() {
%1 = tail call i32 (...) @dpeek()
%2 = tail call i32 @untag_object(i32 %1)
%3 = tail call i32 @bignum_to_fixnum(i32 %2)
%4 = tail call i32 @tag_fixnum(i32 %3)
%5 = tail call i32 @drepl(i32 %4)
ret void
}