xunge/DecIR huggingface dataset:
/* Type definitions */
struct bi_tree {
  int dummy;
};

/* Variables and functions */
long bi_tree_get_sum_impl(struct bi_tree *, int);
long bi_tree_get_sum(struct bi_tree *bi, int idx) {
  if (bi == NULL)
    return 0;
  return bi_tree_get_sum_impl(bi, idx + 1);
}


x86 assembly (clang, -O0):
<bi_tree_get_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1137 <bi_tree_get_sum+0x27>
movq   $0x0,-0x8(%rbp)
jmp    114a <bi_tree_get_sum+0x3a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1030 <bi_tree_get_sum_impl@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bi_tree_get_sum>:
test   %rdi,%rdi
je     111d <bi_tree_get_sum+0xd>
add    $0x1,%esi
jmp    1030 <bi_tree_get_sum_impl@plt>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
%struct.bi_tree = type { i32 }
define i64 @bi_tree_get_sum(%struct.bi_tree* %0, i32 %1) {
%3 = icmp eq %struct.bi_tree* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = add nsw i32 %1, 1
%6 = tail call i64 @bi_tree_get_sum_impl(%struct.bi_tree* %0, i32 %5)
br label %7
7: ; preds = %2, %4
%8 = phi i64 [ %6, %4 ], [ 0, %2 ]
ret i64 %8
}
/* Variables and functions */
int /*<<< orphan*/ f7(int /*<<< orphan*/);
void f8(void) { f7(0); }


x86 assembly (clang, -O0):
<f8>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1030 <f7@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f8>:
xor    %edi,%edi
jmp    1030 <f7@plt>

LLVM IR (-O0):
define void @f8() {
%1 = call i32 @f7(i32 0)
ret void
}

LLVM IR (-O2):
define void @f8() {
%1 = tail call i32 @f7(i32 0)
ret void
}
int dev_printer_write(struct dev_printer *printer) { return 0; }


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

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

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

LLVM IR (-O2):
%struct.dev_printer = type opaque
define i32 @dev_printer_write(%struct.dev_printer* nocapture readnone %0) {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ gethostname(char *, int);
char *Socket_gethostname() {
  static char buf[256 + 1] = "";
  gethostname(buf, 256 + 1);
  return buf;
}


x86 assembly (clang, -O0):
<Socket_gethostname>:
push   %rbp
mov    %rsp,%rbp
lea    0x2f25(%rip),%rdi
mov    $0x101,%esi
call   1030 <gethostname@plt>
lea    0x2f14(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Socket_gethostname>:
push   %rbx
lea    0x2f28(%rip),%rbx
mov    %rbx,%rdi
mov    $0x101,%esi
call   1030 <gethostname@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@Socket_gethostname.buf = internal global [257 x i8] zeroinitializer
define i8* @Socket_gethostname() {
%1 = call i32 @gethostname(i8* getelementptr inbounds ([257 x i8], [257 x i8]* @Socket_gethostname.buf, i64 0, i64 0), i32 257)
ret i8* getelementptr inbounds ([257 x i8], [257 x i8]* @Socket_gethostname.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@Socket_gethostname.buf = internal global [257 x i8] zeroinitializer
define i8* @Socket_gethostname() {
%1 = tail call i32 @gethostname(i8* getelementptr inbounds ([257 x i8], [257 x i8]* @Socket_gethostname.buf, i64 0, i64 0), i32 257)
ret i8* getelementptr inbounds ([257 x i8], [257 x i8]* @Socket_gethostname.buf, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, void *, int);
void *testMalloc(int);
void *testMallocCopy(void *pCopy, int nByte) {
  void *pRet = testMalloc(nByte);
  memcpy(pRet, pCopy, nByte);
  return pRet;
}


x86 assembly (clang, -O0):
<testMallocCopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <testMalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testMallocCopy>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   1040 <testMalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @testMallocCopy(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i8* @testMalloc(i32 %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @memcpy(i8* %8, i8* %9, i32 %10)
%12 = load i8*, i8** %5
ret i8* %12
}

LLVM IR (-O2):
define i8* @testMallocCopy(i8* %0, i32 %1) {
%3 = tail call i8* @testMalloc(i32 %1)
%4 = tail call i32 @memcpy(i8* %3, i8* %0, i32 %1)
ret i8* %3
}
int fib(int param1, int param2) {
  int g1;
  int i4;
  int local19;
  int o0;
  int o0_1;
  int o4;
  i4 = param2;
  if (param1 <= 1) {
    g1 = param1;
    local19 = param1;
  } else {
    o0_1 = fib(param1 - 1, param2);
    o0 = fib(param1 - 2, o4);
    i4 = o0_1;
    local19 = o0_1 + o0;
  }
  return local19;
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     113f <fib+0x2f>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <fib+0x60>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1030 <fib@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x2,%edi
mov    -0x20(%rbp),%esi
call   1030 <fib@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %ebp,%ebp
cmp    $0x2,%edi
jge    1121 <fib+0x11>
mov    %ebx,%ecx
jmp    1147 <fib+0x37>
mov    %esi,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rbx),%edi
mov    %r14d,%esi
call   1030 <fib@plt>
lea    -0x2(%rbx),%ecx
add    %eax,%ebp
cmp    $0x3,%ebx
mov    %ecx,%ebx
ja     1130 <fib+0x20>
add    %ecx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @fib(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %12, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %9, %4 ], [ %0, %2 ]
%6 = phi i32 [ %10, %4 ], [ 0, %2 ]
%7 = add nsw i32 %5, -1
%8 = tail call i32 @fib(i32 %7, i32 %1)
%9 = add nsw i32 %5, -2
%10 = add nsw i32 %8, %6
%11 = icmp ult i32 %5, 4
br i1 %11, label %12, label %4
12: ; preds = %4, %2
%13 = phi i32 [ 0, %2 ], [ %10, %4 ]
%14 = phi i32 [ %0, %2 ], [ %9, %4 ]
%15 = add nsw i32 %14, %13
ret i32 %15
}
/* Variables and functions */
int /*<<< orphan*/ filewindow(int, char *);
viewfile(void) { filewindow(1, "View File = "); }


x86 assembly (clang, -O0):
<viewfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
lea    0xedc(%rip),%rsi
call   1030 <filewindow@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<viewfile>:
lea    0xee9(%rip),%rsi
mov    $0x1,%edi
jmp    1030 <filewindow@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"View File = \00"
define i32 @viewfile() {
%1 = alloca i32
%2 = call i32 @filewindow(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %1
ret i32 %3
}

LLVM IR (-O2):
@.str = [13 x i8] c"View File = \00"
define i32 @viewfile() {
%1 = tail call i32 @filewindow(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, void const *, size_t);
size_t memcpyrc(void *s1, const void *s2, size_t n) {
  memcpy(s1, s2, n);
  return n;
}


x86 assembly (clang, -O0):
<memcpyrc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpyrc>:
push   %rbx
mov    %rdx,%rbx
call   1030 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @memcpyrc(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i64, i64* %6
%10 = call i32 @memcpy(i8* %7, i8* %8, i64 %9)
%11 = load i64, i64* %6
ret i64 %11
}

LLVM IR (-O2):
define i64 @memcpyrc(i8* %0, i8* %1, i64 returned %2) {
%4 = tail call i32 @memcpy(i8* %0, i8* %1, i64 %2)
ret i64 %2
}
/* Variables and functions */
int SIGTERM;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void signal_handler(int sig) {
  if (sig == SIGTERM)
    fprintf(stderr, "done\n");
  exit(1);
}


x86 assembly (clang, -O0):
<signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jne    1152 <signal_handler+0x32>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<signal_handler>:
push   %rax
mov    0x2ec0(%rip),%rax
cmp    %edi,(%rax)
jne    1141 <signal_handler+0x21>
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@SIGTERM = global i32 0
@stderr = global i32 0
@.str = [6 x i8] c"done\0A\00"
define void @signal_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGTERM
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %1
%10 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@SIGTERM = global i32 0
@stderr = global i32 0
@.str = [6 x i8] c"done\0A\00"
define void @signal_handler(i32 %0) {
%2 = load i32, i32* @SIGTERM
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %1
%8 = tail call i32 @exit(i32 1)
unreachable
}
void f(void (*x)(int)) {}


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(void (i32)* %0) {
%2 = alloca void (i32)*
store void (i32)* %0, void (i32)** %2
ret void
}

LLVM IR (-O2):
define void @f(void (i32)* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void grpcsharp_channel_args_set_integer() {
  fprintf(stderr, "Should never reach here");
  abort();
}


x86 assembly (clang, -O0):
<grpcsharp_channel_args_set_integer>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<grpcsharp_channel_args_set_integer>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Should never reach here\00"
define void @grpcsharp_channel_args_set_integer() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Should never reach here\00"
define void @grpcsharp_channel_args_set_integer() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @abort()
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int *, int **);
void test(int *x, int b) {
  x = &b;
  printf("%d\t%p\t%p\n", *x, &b, &x);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xecc(%rip),%rdi
lea    -0xc(%rbp),%rdx
lea    -0x8(%rbp),%rcx
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    %rdx,0x10(%rsp)
lea    0xed7(%rip),%rdi
lea    0x10(%rsp),%rcx
call   1030 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%d\09%p\09%p\0A\00"
define void @test(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = load i32, i32* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %6, i32* %4, i32** %3)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d\09%p\09%p\0A\00"
define void @test(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32 %1, i32* %4
store i32* %4, i32** %3
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1, i32* %4, i32** %3)
ret void
}
/* Variables and functions */
int swapoff(char *);
int swapon(char *, int /*<<< orphan*/);
int main(void) {
  static char swapfile[] = "test.swap";
  int ret;
  ret = swapon(swapfile, 0);
  (void)ret;
  ret = swapoff(swapfile);
  (void)ret;
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0x2f08(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <swapon@plt>
mov    %rbx,%rdi
call   1040 <swapoff@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.swapfile = internal global [10 x i8] c"test.swap\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @swapon(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.swapfile, i64 0, i64 0), i32 0)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @swapoff(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.swapfile, i64 0, i64 0))
store i32 %5, i32* %2
%6 = load i32, i32* %2
ret i32 0
}

LLVM IR (-O2):
@main.swapfile = internal global [10 x i8] c"test.swap\00"
define i32 @main() {
%1 = tail call i32 @swapon(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.swapfile, i64 0, i64 0), i32 0)
%2 = tail call i32 @swapoff(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.swapfile, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ get_xmval();
int /*<<< orphan*/ report_info(char *, char *, int /*<<< orphan*/);
void show_xmval(int sig) {
  report_info("show_xmval()",
              "\nIf the worker is suspended, the following value should be "
              "2\n#xmalloc() - #xfree() = %d",
              get_xmval());
}


x86 assembly (clang, -O0):
<show_xmval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <get_xmval@plt>
mov    %eax,%edx
lea    0xec5(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1030 <report_info@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_xmval>:
push   %rax
xor    %eax,%eax
call   1040 <get_xmval@plt>
lea    0xed1(%rip),%rdi
lea    0xed7(%rip),%rsi
mov    %eax,%edx
pop    %rax
jmp    1030 <report_info@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"show_xmval()\00"
@.str.1 = [88 x i8] c"\0AIf the worker is suspended, the following value should be 2\0A#xmalloc() - #xfree() = %d\00"
define void @show_xmval(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @get_xmval()
%4 = call i32 @report_info(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"show_xmval()\00"
@.str.1 = [88 x i8] c"\0AIf the worker is suspended, the following value should be 2\0A#xmalloc() - #xfree() = %d\00"
define void @show_xmval(i32 %0) {
%2 = tail call i32 (...) @get_xmval()
%3 = tail call i32 @report_info(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int test(int, int);
int main(int argc, char const *argv[]) {
  int i, j, k;
  i = 3;
  j = 2;
  k = test(i, j);
  if (k > 5) {
    printf(">5\n");
  } else {
    printf("<=5\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <test@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jle    116d <main+0x4d>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
jmp    1179 <main+0x59>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
mov    $0x2,%esi
call   1040 <test@plt>
cmp    $0x6,%eax
lea    0xeca(%rip),%rax
lea    0xebf(%rip),%rdi
cmovge %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str = [4 x i8] c"<=5\00"
@str.2 = [3 x i8] c">5\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @test(i32 3, i32 2)
%4 = icmp sgt i32 %3, 5
%5 = select i1 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
ret i32 0
}
/* Variables and functions */
unsigned int seed_step(unsigned int);
int calculate_num(unsigned int *num, int val) {
  if (!(val > 0x10001)) {
    *num = seed_step(*num);
    return ((int)(*num >> 16) * val) >> 16;
  } else {
    ;
  }
  if (val > 0xff) {
    ;
  }
  return val;
}


x86 assembly (clang, -O0):
<calculate_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x10001,-0x14(%rbp)
jg     1157 <calculate_num+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <seed_step@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shr    $0x10,%eax
imul   -0x14(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <calculate_num+0x64>
jmp    115c <calculate_num+0x4c>
cmpl   $0xff,-0x14(%rbp)
jle    116e <calculate_num+0x5e>
jmp    116e <calculate_num+0x5e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_num>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    $0x10001,%esi
jg     1136 <calculate_num+0x26>
mov    %rdi,%r14
mov    (%rdi),%edi
call   1030 <seed_step@plt>
mov    %eax,(%r14)
shr    $0x10,%eax
imul   %ebx,%eax
sar    $0x10,%eax
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @calculate_num(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 65537
br i1 %7, label %19, label %8
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = call i32 @seed_step(i32 %10)
%12 = load i32*, i32** %4
store i32 %11, i32* %12
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = lshr i32 %14, 16
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = ashr i32 %17, 16
store i32 %18, i32* %3
br label %26
19: ; preds = %2
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 255
br i1 %22, label %23, label %24
23: ; preds = %20
br label %24
24: ; preds = %23, %20
%25 = load i32, i32* %5
store i32 %25, i32* %3
br label %26
26: ; preds = %24, %8
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @calculate_num(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 65537
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* %0
%6 = tail call i32 @seed_step(i32 %5)
store i32 %6, i32* %0
%7 = lshr i32 %6, 16
%8 = mul nsw i32 %7, %1
%9 = ashr i32 %8, 16
br label %10
10: ; preds = %2, %4
%11 = phi i32 [ %9, %4 ], [ %1, %2 ]
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
void clibc_free(void *ptr) { free(ptr); }


x86 assembly (clang, -O0):
<clibc_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):
<clibc_free>:
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @clibc_free(i8* nocapture %0) {
%2 = tail call i32 @free(i8* %0)
ret void
}
void VIDDummyVdp2SetPriorityNBG0(__attribute((unused)) int priority) {}


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

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

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

LLVM IR (-O2):
define void @VIDDummyVdp2SetPriorityNBG0(i32 %0) {
ret void
}
int slowRangeBitwiseAnd(int m, int n) {
  int ans = n;
  for (int i = n - 1; i >= m && ans; --i)
    ans &= i;
  return ans;
}


x86 assembly (clang, -O0):
<slowRangeBitwiseAnd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x11(%rbp)
jl     1134 <slowRangeBitwiseAnd+0x34>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1144 <slowRangeBitwiseAnd+0x44>
jmp    115b <slowRangeBitwiseAnd+0x5b>
mov    -0x10(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1119 <slowRangeBitwiseAnd+0x19>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<slowRangeBitwiseAnd>:
mov    %esi,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%eax
cmp    %edi,%ecx
jle    1121 <slowRangeBitwiseAnd+0x21>
add    $0xffffffff,%ecx
mov    %ecx,%esi
and    %eax,%esi
test   %eax,%eax
jne    1110 <slowRangeBitwiseAnd+0x10>
ret

LLVM IR (-O0):
define i32 @slowRangeBitwiseAnd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
store i32 %7, i32* %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %6
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %3
%13 = icmp sge i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %14, %10
%18 = phi i1 [ false, %10 ], [ %16, %14 ]
br i1 %18, label %19, label %26
19: ; preds = %17
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = and i32 %21, %20
store i32 %22, i32* %5
br label %23
23: ; preds = %19
%24 = load i32, i32* %6
%25 = add nsw i32 %24, -1
store i32 %25, i32* %6
br label %10
26: ; preds = %17
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @slowRangeBitwiseAnd(i32 %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ %1, %2 ], [ %10, %3 ]
%5 = phi i32 [ %1, %2 ], [ %6, %3 ]
%6 = add nsw i32 %5, -1
%7 = icmp sgt i32 %5, %0
%8 = icmp ne i32 %4, 0
%9 = select i1 %7, i1 %8, i1 false
%10 = and i32 %6, %4
br i1 %9, label %3, label %11
11: ; preds = %3
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ yac_allocator_shutdown();
void yac_storage_shutdown(void) { yac_allocator_shutdown(); }


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

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

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

LLVM IR (-O2):
define void @yac_storage_shutdown() {
%1 = tail call i32 (...) @yac_allocator_shutdown()
ret void
}
struct X *wrap(struct X *p) {
  return p;
}


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

x86 assembly (clang, -O2):
<wrap>:
mov    %rdi,%rax
ret

LLVM IR (-O0):
%struct.X = type opaque
define %struct.X* @wrap(%struct.X* %0) {
%2 = alloca %struct.X*
store %struct.X* %0, %struct.X** %2
%3 = load %struct.X*, %struct.X** %2
ret %struct.X* %3
}

LLVM IR (-O2):
%struct.X = type opaque
define %struct.X* @wrap(%struct.X* readnone returned %0) {
ret %struct.X* %0
}
/* Variables and functions */
int /*<<< orphan*/ AAAA_CONTROL_LOOP_IMPL();
int /*<<< orphan*/ AAAA_TEMPERATURE_IMPL();
int /*<<< orphan*/ AIBV_plant_IMPL();
int /*<<< orphan*/ omp_set_num_threads(int);
int main(int argc, char *argv[]) {
  omp_set_num_threads(3);
#pragma omp parallel sections
  {
#pragma omp section
    { AAAA_CONTROL_LOOP_IMPL(); }
#pragma omp section
    { AAAA_TEMPERATURE_IMPL(); }
#pragma omp section
    { AIBV_plant_IMPL(); }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3,%edi
call   1060 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1050 <AAAA_CONTROL_LOOP_IMPL@plt>
mov    $0x0,%al
call   1040 <AAAA_TEMPERATURE_IMPL@plt>
mov    $0x0,%al
call   1030 <AIBV_plant_IMPL@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
call   1060 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1050 <AAAA_CONTROL_LOOP_IMPL@plt>
xor    %eax,%eax
call   1040 <AAAA_TEMPERATURE_IMPL@plt>
xor    %eax,%eax
call   1030 <AIBV_plant_IMPL@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @omp_set_num_threads(i32 3)
%4 = tail call i32 (...) @AAAA_CONTROL_LOOP_IMPL()
%5 = tail call i32 (...) @AAAA_TEMPERATURE_IMPL()
%6 = tail call i32 (...) @AIBV_plant_IMPL()
ret i32 0
}
/* Type definitions */
typedef int GLuint;

/* Variables and functions */
int nearestPower(GLuint value) {
  int i;
  i = 1;
  if (value == 0)
    return -1;
  for (;;) {
    if (value == 1) {
      return i;
    } else if (value == 3) {
      return i * 4;
    }
    value = value >> 1;
    i *= 2;
  }
}


x86 assembly (clang, -O0):
<nearestPower>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1124 <nearestPower+0x24>
movl   $0xffffffff,-0x4(%rbp)
jmp    1172 <nearestPower+0x72>
jmp    1129 <nearestPower+0x29>
cmpl   $0x1,-0x8(%rbp)
jne    113e <nearestPower+0x3e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <nearestPower+0x72>
cmpl   $0x3,-0x8(%rbp)
jne    1156 <nearestPower+0x56>
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <nearestPower+0x72>
jmp    115b <nearestPower+0x5b>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <nearestPower+0x29>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nearestPower>:
test   %edi,%edi
je     111f <nearestPower+0x1f>
mov    $0x1,%eax
cmp    $0x1,%edi
je     111e <nearestPower+0x1e>
xchg   %ax,%ax
cmp    $0x3,%edi
je     1125 <nearestPower+0x25>
sar    %edi
add    %eax,%eax
cmp    $0x1,%edi
jne    1110 <nearestPower+0x10>
ret
mov    $0xffffffff,%eax
ret
shl    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @nearestPower(i32 %0) {
%2 = alloca i32
%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, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -1, i32* %2
br label %26
8: ; preds = %1
br label %9
9: ; preds = %21, %8
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32, i32* %4
store i32 %13, i32* %2
br label %26
14: ; preds = %9
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %4
%19 = mul nsw i32 %18, 4
store i32 %19, i32* %2
br label %26
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = ashr i32 %22, 1
store i32 %23, i32* %3
%24 = load i32, i32* %4
%25 = mul nsw i32 %24, 2
store i32 %25, i32* %4
br label %9
26: ; preds = %17, %12, %7
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @nearestPower(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %11, label %3
3: ; preds = %1, %8
%4 = phi i32 [ %9, %8 ], [ %0, %1 ]
%5 = phi i32 [ %10, %8 ], [ 1, %1 ]
switch i32 %4, label %8 [
i32 1, label %11
i32 3, label %6
]
6: ; preds = %3
%7 = shl nsw i32 %5, 2
br label %11
8: ; preds = %3
%9 = ashr i32 %4, 1
%10 = shl nsw i32 %5, 1
br label %3
11: ; preds = %3, %1, %6
%12 = phi i32 [ %7, %6 ], [ -1, %1 ], [ %5, %3 ]
ret i32 %12
}
/* Variables and functions */
void *malloc(size_t);
void *myMalloc(size_t size) { return malloc(size); }


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

x86 assembly (clang, -O2):
<myMalloc>:
jmp    1030 <malloc@plt>

LLVM IR (-O0):
define i8* @myMalloc(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = call i8* @malloc(i64 %3)
ret i8* %4
}

LLVM IR (-O2):
define noalias i8* @myMalloc(i64 %0) {
%2 = tail call i8* @malloc(i64 %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ abort();
void check(short *a, short *b, int N) {
  int i;
  for (i = 0; i < N; i++)
    if (a[i] != b[i])
      abort();
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1170 <check+0x60>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movswl (%rcx,%rdx,2),%ecx
cmp    %ecx,%eax
je     115d <check+0x4d>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1162 <check+0x52>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <check+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rax
test   %edx,%edx
jle    1133 <check+0x23>
mov    %edx,%eax
xor    %ecx,%ecx
nopl   0x0(%rax)
movzwl (%rdi,%rcx,2),%edx
cmp    (%rsi,%rcx,2),%dx
jne    1135 <check+0x25>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1120 <check+0x10>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define void @check(i16* nocapture %0, i16* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %19
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %16, %6
br i1 %8, label %19, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %16, %7 ]
%11 = getelementptr inbounds i16, i16* %0, i64 %10
%12 = load i16, i16* %11
%13 = getelementptr inbounds i16, i16* %1, i64 %10
%14 = load i16, i16* %13
%15 = icmp eq i16 %12, %14
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %7, label %17
17: ; preds = %9
%18 = tail call i32 (...) @abort()
unreachable
19: ; preds = %7, %3
ret void
}
void arch_sigreturn(struct tcb *tcp) {}


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

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

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

LLVM IR (-O2):
%struct.tcb = type opaque
define void @arch_sigreturn(%struct.tcb* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ handle_TTOU(int /*<<< orphan*/);
int gen_TTOU() { handle_TTOU(0); }


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

x86 assembly (clang, -O2):
<gen_TTOU>:
xor    %edi,%edi
jmp    1030 <handle_TTOU@plt>

LLVM IR (-O0):
define i32 @gen_TTOU() {
%1 = alloca i32
%2 = call i32 @handle_TTOU(i32 0)
%3 = load i32, i32* %1
ret i32 %3
}

LLVM IR (-O2):
define i32 @gen_TTOU() {
%1 = tail call i32 @handle_TTOU(i32 0)
ret i32 undef
}
unsigned pvr2_tex_mem_addr_64_to_32(unsigned offs) {
  unsigned offs64 = offs & 0x007ffffc;
  unsigned offs32;
  if (offs64 % 8)
    offs32 = ((offs64 - 4) / 2) + ((0x057fffff - 0x05000000 + 1) / 2);
  else
    offs32 = offs64 / 2;
  return offs32 | (offs & 3);
}


x86 assembly (clang, -O0):
<pvr2_tex_mem_addr_64_to_32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7ffffc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
je     1137 <pvr2_tex_mem_addr_64_to_32+0x37>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
shr    $0x1,%eax
add    $0x400000,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <pvr2_tex_mem_addr_64_to_32+0x40>
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
and    $0x3,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pvr2_tex_mem_addr_64_to_32>:
mov    %edi,%eax
and    $0x7ffffc,%eax
lea    -0x4(%rax),%ecx
shr    %ecx
add    $0x400000,%ecx
shr    %eax
test   $0x4,%dil
cmovne %ecx,%eax
and    $0x3,%edi
or     %edi,%eax
ret

LLVM IR (-O0):
define i32 @pvr2_tex_mem_addr_64_to_32(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = and i32 %5, 8388604
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = urem i32 %7, 8
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* %3
%12 = sub i32 %11, 4
%13 = udiv i32 %12, 2
%14 = add i32 %13, 4194304
store i32 %14, i32* %4
br label %18
15: ; preds = %1
%16 = load i32, i32* %3
%17 = udiv i32 %16, 2
store i32 %17, i32* %4
br label %18
18: ; preds = %15, %10
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = and i32 %20, 3
%22 = or i32 %19, %21
ret i32 %22
}

LLVM IR (-O2):
define i32 @pvr2_tex_mem_addr_64_to_32(i32 %0) {
%2 = and i32 %0, 8388604
%3 = and i32 %0, 4
%4 = icmp eq i32 %3, 0
%5 = add nsw i32 %2, -4
%6 = lshr exact i32 %5, 1
%7 = add nuw i32 %6, 4194304
%8 = lshr exact i32 %2, 1
%9 = select i1 %4, i32 %8, i32 %7
%10 = and i32 %0, 3
%11 = or i32 %9, %10
ret i32 %11
}
/* Variables and functions */
int atoi(char *);
int getInteger(char *str) { return atoi(str); }


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

x86 assembly (clang, -O2):
<getInteger>:
jmp    1030 <atoi@plt>

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

LLVM IR (-O2):
define i32 @getInteger(i8* nocapture %0) {
%2 = tail call i32 @atoi(i8* %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void cmark_strbuf_overflow_err() {
  fprintf(stderr, "String buffer overflow");
  abort();
}


x86 assembly (clang, -O0):
<cmark_strbuf_overflow_err>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<cmark_strbuf_overflow_err>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"String buffer overflow\00"
define void @cmark_strbuf_overflow_err() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"String buffer overflow\00"
define void @cmark_strbuf_overflow_err() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @abort()
unreachable
}
char SpaceToDash(char Id) {
  static char NewId;
  if (Id == ' ')
    NewId = '-';
  else
    NewId = Id;
  return (NewId);
}


x86 assembly (clang, -O0):
<SpaceToDash>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x20,%eax
jne    1123 <SpaceToDash+0x23>
movb   $0x2d,0x2f03(%rip)
jmp    112c <SpaceToDash+0x2c>
mov    -0x1(%rbp),%al
mov    %al,0x2ef5(%rip)
movsbl 0x2eee(%rip),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<SpaceToDash>:
cmp    $0x20,%dil
mov    $0x2d,%eax
cmovne %edi,%eax
ret

LLVM IR (-O0):
@SpaceToDash.NewId = internal global i8 0
define signext i8 @SpaceToDash(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = icmp eq i32 %4, 32
br i1 %5, label %6, label %7
6: ; preds = %1
store i8 45, i8* @SpaceToDash.NewId
br label %9
7: ; preds = %1
%8 = load i8, i8* %2
store i8 %8, i8* @SpaceToDash.NewId
br label %9
9: ; preds = %7, %6
%10 = load i8, i8* @SpaceToDash.NewId
ret i8 %10
}

LLVM IR (-O2):
define signext i8 @SpaceToDash(i8 signext %0) {
%2 = icmp eq i8 %0, 32
%3 = select i1 %2, i8 45, i8 %0
ret i8 %3
}
/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, char *);
char *string_replace(char *, char *, char *);
int main(int argc, char *argv[]) {
  printf("%s\n", string_replace("Hello ciao", "ciao", "world"));
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec7(%rip),%rdi
lea    0xec6(%rip),%rsi
lea    0xec4(%rip),%rdx
call   1030 <string_replace@plt>
mov    %rax,%rsi
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedc(%rip),%rdi
lea    0xedb(%rip),%rsi
lea    0xed9(%rip),%rdx
call   1030 <string_replace@plt>
lea    0xebe(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [11 x i8] c"Hello ciao\00"
@.str.2 = [5 x i8] c"ciao\00"
@.str.3 = [6 x i8] c"world\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i8* @string_replace(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_SUCCESS
ret i32 %8
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [11 x i8] c"Hello ciao\00"
@.str.2 = [5 x i8] c"ciao\00"
@.str.3 = [6 x i8] c"world\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @string_replace(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i32, i32* @EXIT_SUCCESS
ret i32 %5
}
long long _addsub(unsigned int src1, unsigned int src2) {
  int res_lo;
  int res_hi;
  res_hi = src1 + src2;
  res_lo = src1 - src2;
  return (((unsigned long long)res_hi) << 32) | ((unsigned int)res_lo);
}


x86 assembly (clang, -O0):
<_addsub>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x20,%rax
mov    -0xc(%rbp),%ecx
or     %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_addsub>:
lea    (%rsi,%rdi,1),%eax
sub    %esi,%edi
shl    $0x20,%rax
or     %rdi,%rax
ret

LLVM IR (-O0):
define i64 @_addsub(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = add i32 %7, %8
store i32 %9, i32* %6
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = sub i32 %10, %11
store i32 %12, i32* %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = shl i64 %14, 32
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = or i64 %15, %17
ret i64 %18
}

LLVM IR (-O2):
define i64 @_addsub(i32 %0, i32 %1) {
%3 = add i32 %1, %0
%4 = sub i32 %0, %1
%5 = zext i32 %3 to i64
%6 = shl nuw i64 %5, 32
%7 = zext i32 %4 to i64
%8 = or i64 %6, %7
ret i64 %8
}
/* Variables and functions */
int /*<<< orphan*/ iothub_client_sample_amqp_run();
int main(void) { iothub_client_sample_amqp_run(); }


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

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

LLVM IR (-O0):
define i32 @main() {
%1 = call i32 (...) @iothub_client_sample_amqp_run()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @iothub_client_sample_amqp_run()
ret i32 0
}
/* Variables and functions */
int *malloc(int);
int *MakeInt(int value) {
  int *ptr = malloc(sizeof(int));
  *ptr = value;
  return ptr;
}


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

x86 assembly (clang, -O2):
<MakeInt>:
push   %rbx
mov    %edi,%ebx
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %ebx,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i32* @MakeInt(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @malloc(i32 4)
store i32* %4, i32** %3
%5 = load i32, i32* %2
%6 = load i32*, i32** %3
store i32 %5, i32* %6
%7 = load i32*, i32** %3
ret i32* %7
}

LLVM IR (-O2):
define noalias i32* @MakeInt(i32 %0) {
%2 = tail call i32* @malloc(i32 4)
store i32 %0, i32* %2
ret i32* %2
}
void WaitZip(int nr) {}


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

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

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

LLVM IR (-O2):
define void @WaitZip(i32 %0) {
ret void
}