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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int ternarySearch(int *, int /*<<< orphan*/, int, int);
int main(void) {
  int array[] = {1, 2, 3, 5};
  int size = sizeof(array) / sizeof(array[0]);
  int find = 3;
  printf("Position of %d is %d\n", find,
         ternarySearch(array, 0, size - 1, find));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x3,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x28(%rbp),%ecx
xor    %esi,%esi
call   1030 <ternarySearch@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
call   1030 <ternarySearch@plt>
lea    0xec6(%rip),%rdi
mov    $0x3,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.array = [4 x i32] [i32 1, i32 2, i32 3, i32 5]
@.str = [22 x i8] c"Position of %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [4 x i32]* %2 to i8*
store i32 4, i32* %3
store i32 3, i32* %4
%6 = load i32, i32* %4
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = load i32, i32* %4
%11 = call i32 @ternarySearch(i32* %7, i32 0, i32 %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %11)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [4 x i32] [i32 1, i32 2, i32 3, i32 5]
@.str = [22 x i8] c"Position of %d is %d\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @ternarySearch(i32* %3, i32 0, i32 3, i32 3)
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 3, i32 %4)
ret i32 0
}
void free_matrix(unsigned int **mat, unsigned int n) {
  int i;
  for (i = 0; i < n; i++) {
    free(mat[i]);
  }
  free(mat);
}


x86 assembly (clang, -O0):
<free_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1151 <free_matrix+0x41>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <free_matrix+0x16>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_matrix>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
je     1142 <free_matrix+0x32>
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <free_matrix+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @free_matrix(i32** nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %11, %6 ]
%8 = getelementptr inbounds i32*, i32** %0, i64 %7
%9 = bitcast i32** %8 to i8**
%10 = load i8*, i8** %9
tail call void @free(i8* %10)
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, %5
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = bitcast i32** %0 to i8*
tail call void @free(i8* %14)
ret void
}
/* Variables and functions */
char *cat2(char *, char *);
int /*<<< orphan*/ dealloc(char *);
char *s_cat2(char *a, char *b) {
  char *ret = cat2(a, b);
  dealloc(a);
  dealloc(b);
  return ret;
}


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

x86 assembly (clang, -O2):
<s_cat2>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <cat2@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <dealloc@plt>
mov    %r14,%rdi
call   1030 <dealloc@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @s_cat2(i8* %0, i8* %1) {
%3 = tail call i8* @cat2(i8* %0, i8* %1)
%4 = tail call i32 @dealloc(i8* %0)
%5 = tail call i32 @dealloc(i8* %1)
ret i8* %3
}
/* Variables and functions */
int /*<<< orphan*/ japi_drawimagesource(int, int, int, int, int, int *, int *,
                                        int *);
void j_drawimagesource(int arg0, int arg1, int arg2, int arg3, int arg4,
                       int *arg5, int *arg6, int *arg7) {
  japi_drawimagesource(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}


x86 assembly (clang, -O0):
<j_drawimagesource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <japi_drawimagesource@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<j_drawimagesource>:
jmp    1030 <japi_drawimagesource@plt>

LLVM IR (-O0):
define void @j_drawimagesource(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i32* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32* %5, i32** %14
store i32* %6, i32** %15
store i32* %7, i32** %16
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = load i32, i32* %12
%21 = load i32, i32* %13
%22 = load i32*, i32** %14
%23 = load i32*, i32** %15
%24 = load i32*, i32** %16
%25 = call i32 @japi_drawimagesource(i32 %17, i32 %18, i32 %19, i32 %20, i32 %21, i32* %22, i32* %23, i32* %24)
ret void
}

LLVM IR (-O2):
define void @j_drawimagesource(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i32* %7) {
%9 = tail call i32 @japi_drawimagesource(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i32* %7)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ compilerAssert();
void chpl_incRefCountsForDomainsInArrayEltTypes(void) {
  compilerAssert();
  return;
}


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

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

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

LLVM IR (-O2):
define void @chpl_incRefCountsForDomainsInArrayEltTypes() {
%1 = tail call i32 (...) @compilerAssert()
ret void
}
float seconds2ticks(float seconds) { return seconds * 1000; }


x86 assembly (clang, -O0):
<seconds2ticks>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  0xeef(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds2ticks>:
mulss  0xef8(%rip),%xmm0
ret

LLVM IR (-O0):
define float @seconds2ticks(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fmul float %3, 1.000000e+03
ret float %4
}

LLVM IR (-O2):
define float @seconds2ticks(float %0) {
%2 = fmul float %0, 1.000000e+03
ret float %2
}
int comp3(const void *e1, const void *e2) {
  return *(const int *)e2 - *(const int *)e1;
}


x86 assembly (clang, -O0):
<comp3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<comp3>:
mov    (%rsi),%eax
sub    (%rdi),%eax
ret

LLVM IR (-O0):
define i32 @comp3(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = sub nsw i32 %7, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @comp3(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
%4 = load i32, i32* %3
%5 = bitcast i8* %0 to i32*
%6 = load i32, i32* %5
%7 = sub nsw i32 %4, %6
ret i32 %7
}
/* Type definitions */
struct yas_driver {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ yas_cdrv_term();
int suspend(struct yas_driver *d) {
  (printf("suspend IN\n"));
  (void)d;
  yas_cdrv_term();
  (printf("suspend OUT\n"));
  return 0;
}


x86 assembly (clang, -O0):
<suspend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <yas_cdrv_term@plt>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.yas_driver = type { i32 }
@.str = [12 x i8] c"suspend IN\0A\00"
@.str.1 = [13 x i8] c"suspend OUT\0A\00"
define i32 @suspend(%struct.yas_driver* %0) {
%2 = alloca %struct.yas_driver*
store %struct.yas_driver* %0, %struct.yas_driver** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = load %struct.yas_driver*, %struct.yas_driver** %2
%5 = call i32 (...) @yas_cdrv_term()
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.yas_driver = type { i32 }
@str = [11 x i8] c"suspend IN\00"
@str.2 = [12 x i8] c"suspend OUT\00"
define i32 @suspend(%struct.yas_driver* nocapture readnone %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @yas_cdrv_term()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}
char *langRomTypeMsxMidi() { return "MSX-MIDI"; }


x86 assembly (clang, -O0):
<langRomTypeMsxMidi>:
push   %rbp
mov    %rsp,%rbp
lea    0xef5(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<langRomTypeMsxMidi>:
lea    0xef9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"MSX-MIDI\00"
define i8* @langRomTypeMsxMidi() {
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [9 x i8] c"MSX-MIDI\00"
define i8* @langRomTypeMsxMidi() {
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ cur_term;
int /*<<< orphan*/ putp(int /*<<< orphan*/);
int /*<<< orphan*/ setupterm(int /*<<< orphan*/ *, int /*<<< orphan*/, int *);
int /*<<< orphan*/ tigetstr(char *);
void clear_term() {
  int res = 0;
  if (!cur_term) {
    setupterm(NULL, STDOUT_FILENO, &res);
    if (res <= 0)
      return;
  }
  putp(tigetstr("clear"));
}


x86 assembly (clang, -O0):
<clear_term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
cmpl   $0x0,(%rax)
jne    1179 <clear_term+0x49>
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x4(%rbp),%rdx
call   1030 <setupterm@plt>
cmpl   $0x0,-0x4(%rbp)
jg     1174 <clear_term+0x44>
jmp    118c <clear_term+0x5c>
jmp    1179 <clear_term+0x49>
lea    0xe80(%rip),%rdi
call   1050 <tigetstr@plt>
mov    %eax,%edi
call   1040 <putp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_term>:
push   %rax
movl   $0x0,0x4(%rsp)
mov    0x2ea0(%rip),%rax
cmpl   $0x0,(%rax)
jne    1161 <clear_term+0x31>
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
xor    %edi,%edi
call   1030 <setupterm@plt>
cmpl   $0x0,0x4(%rsp)
jle    1174 <clear_term+0x44>
lea    0xe98(%rip),%rdi
call   1050 <tigetstr@plt>
mov    %eax,%edi
call   1040 <putp@plt>
pop    %rax
ret

LLVM IR (-O0):
@cur_term = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [6 x i8] c"clear\00"
define void @clear_term() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @cur_term
%3 = icmp ne i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @setupterm(i32* null, i32 %5, i32* %1)
%7 = load i32, i32* %1
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %4
br label %14
10: ; preds = %4
br label %11
11: ; preds = %10, %0
%12 = call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @putp(i32 %12)
br label %14
14: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@cur_term = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [6 x i8] c"clear\00"
define void @clear_term() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = load i32, i32* @cur_term
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @STDOUT_FILENO
%7 = call i32 @setupterm(i32* null, i32 %6, i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %5, %0
%11 = call i32 @tigetstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @putp(i32 %11)
br label %13
13: ; preds = %5, %10
ret void
}
/* Variables and functions */
int /*<<< orphan*/ link_error();
int main() {
  int a[4];
  if (&a[2] - 1 != &a[1])
    link_error();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
store i32 0, i32* %1
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
void close_device(int device_id) {
  if (device_id != 0x01) {
    close(device_id);
  }
}


x86 assembly (clang, -O0):
<close_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     112d <close_device+0x1d>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_device>:
cmp    $0x1,%edi
jne    1116 <close_device+0x6>
ret
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define void @close_device(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @close(i32 %0)
br label %5
5: ; preds = %3, %1
ret void
}
/* Variables and functions */
int write(int, char *, int);
int send_command(int fd, char command) {
  int result;
  result = write(fd, &command, 1);
  return (result);
}


x86 assembly (clang, -O0):
<send_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_command>:
push   %rax
mov    %sil,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @send_command(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%6 = load i32, i32* %3
%7 = call i32 @write(i32 %6, i8* %4, i32 1)
store i32 %7, i32* %5
%8 = load i32, i32* %5
ret i32 %8
}

LLVM IR (-O2):
define i32 @send_command(i32 %0, i8 signext %1) {
%3 = alloca i8
store i8 %1, i8* %3
%4 = call i32 @write(i32 %0, i8* %3, i32 1)
ret i32 %4
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void mumble_audio_callback(uint8_t *audio_data, uint32_t audio_data_size,
                           void *user_data) {
  printf("I received %d bytes of audio data\n", audio_data_size);
}


x86 assembly (clang, -O0):
<mumble_audio_callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [35 x i8] c"I received %d bytes of audio data\0A\00"
define void @mumble_audio_callback(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7)
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"I received %d bytes of audio data\0A\00"
define void @mumble_audio_callback(i32* nocapture readnone %0, i32 %1, i8* nocapture readnone %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %1)
ret void
}
void ble_evt_attributes_status(
    const struct ble_msg_attributes_status_evt_t *msg) {}


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

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

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

LLVM IR (-O2):
%struct.ble_msg_attributes_status_evt_t = type opaque
define void @ble_evt_attributes_status(%struct.ble_msg_attributes_status_evt_t* nocapture %0) {
ret void
}
/* Variables and functions */
char *malloc(int);
char *crash_me() {
  int one = 1;
  char *ptr = malloc(3);
  static int i;
  static char *p;
  for (p = (char *)&one, i = 0; i < 150; i++) {
    *p++ = 10;
  }
  return ptr;
}


x86 assembly (clang, -O0):
<crash_me>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
mov    $0x3,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,0x2f00(%rip)
movl   $0x0,0x2eee(%rip)
cmpl   $0x96,0x2ee4(%rip)
jge    117e <crash_me+0x6e>
mov    0x2edf(%rip),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x2ed1(%rip)
movb   $0xa,(%rax)
mov    0x2ec0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb7(%rip)
jmp    1142 <crash_me+0x32>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crash_me>:
push   %rax
mov    $0x3,%edi
call   1030 <malloc@plt>
lea    0x9a(%rsp),%rcx
mov    %rcx,0x2f06(%rip)
pop    %rcx
ret

LLVM IR (-O0):
@crash_me.i = internal global i32 0
@crash_me.p = internal global i8* null
define i8* @crash_me() {
%1 = alloca i32
%2 = alloca i8*
store i32 1, i32* %1
%3 = call i8* @malloc(i32 3)
store i8* %3, i8** %2
%4 = bitcast i32* %1 to i8*
store i8* %4, i8** @crash_me.p
store i32 0, i32* @crash_me.i
br label %5
5: ; preds = %11, %0
%6 = load i32, i32* @crash_me.i
%7 = icmp slt i32 %6, 150
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i8*, i8** @crash_me.p
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** @crash_me.p
store i8 10, i8* %9
br label %11
11: ; preds = %8
%12 = load i32, i32* @crash_me.i
%13 = add nsw i32 %12, 1
store i32 %13, i32* @crash_me.i
br label %5
14: ; preds = %5
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@crash_me.p = internal unnamed_addr global i8* null
define noalias i8* @crash_me() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%4 = getelementptr i32, i32* %1, i64 37
%5 = bitcast i32* %4 to i8*
%6 = getelementptr i8, i8* %5, i64 2
store i8* %6, i8** @crash_me.p
ret i8* %3
}