xunge/DecIR huggingface dataset:
/* Variables and functions */
int strlen(char *);
char tolower(char);
char *strlwr(char *s) {
  int len, i;
  len = strlen(s);
  for (i = 0; i < len; i++)
    s[i] = tolower(s[i]);
  return s;
}


x86 assembly (clang, -O0):
<strlwr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1177 <strlwr+0x57>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <strlwr+0x1f>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlwr>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    1157 <strlwr+0x37>
mov    %eax,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <strlwr+0x20>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @strlwr(i8* returned %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %11, %6 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %8
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, %5
br i1 %12, label %13, label %6
13: ; preds = %6, %1
ret i8* %0
}
/* Variables and functions */
int triangle(int, int);
int f(int x, int y) {
  return triangle(x % 10 - 5, y % 10 - 5);
  ;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
sub    $0x5,%edi
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
sub    $0x5,%esi
call   1030 <triangle@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0xfffffffb,%edi
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0xfffffffb,%esi
jmp    1030 <triangle@plt>

LLVM IR (-O0):
define i32 @f(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 = srem i32 %5, 10
%7 = sub nsw i32 %6, 5
%8 = load i32, i32* %4
%9 = srem i32 %8, 10
%10 = sub nsw i32 %9, 5
%11 = call i32 @triangle(i32 %7, i32 %10)
ret i32 %11
}

LLVM IR (-O2):
define i32 @f(i32 %0, i32 %1) {
%3 = srem i32 %0, 10
%4 = add nsw i32 %3, -5
%5 = srem i32 %1, 10
%6 = add nsw i32 %5, -5
%7 = tail call i32 @triangle(i32 %4, i32 %6)
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ default_isr();
__attribute__((weak)) void QUADEC_Handler() { default_isr(); }


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

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

LLVM IR (-O0):
define weak void @QUADEC_Handler() {
%1 = call i32 (...) @default_isr()
ret void
}

LLVM IR (-O2):
define weak void @QUADEC_Handler() {
%1 = tail call i32 (...) @default_isr()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ I();
int /*<<< orphan*/ LP();
int /*<<< orphan*/ eat(int);
int /*<<< orphan*/ printf(char *);
void L() {
  printf("L -> idIL'\n");
  eat(6);
  I();
  LP();
}


x86 assembly (clang, -O0):
<L>:
push   %rbp
mov    %rsp,%rbp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x6,%edi
call   1030 <eat@plt>
mov    $0x0,%al
call   1050 <I@plt>
mov    $0x0,%al
call   1060 <LP@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<L>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x6,%edi
call   1030 <eat@plt>
xor    %eax,%eax
call   1050 <I@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <LP@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"L -> idIL'\0A\00"
define void @L() {
%1 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @eat(i32 6)
%3 = call i32 (...) @I()
%4 = call i32 (...) @LP()
ret void
}

LLVM IR (-O2):
@str = [11 x i8] c"L -> idIL'\00"
define void @L() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @eat(i32 6)
%3 = tail call i32 (...) @I()
%4 = tail call i32 (...) @LP()
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int vfprintf(int /*<<< orphan*/, char const *const, int /*<<< orphan*/);
int ut_write_to_stderr(const char *const fmt, va_list args) {
  int nbytes = vfprintf(stderr, fmt, args);
  (void)fputc('\n', stderr);
  return nbytes;
}


x86 assembly (clang, -O0):
<ut_write_to_stderr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <vfprintf@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ut_write_to_stderr>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%edx
mov    %rdi,%rsi
mov    0x2eb0(%rip),%r14
mov    (%r14),%edi
call   1040 <vfprintf@plt>
mov    %eax,%ebx
mov    (%r14),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
define i32 @ut_write_to_stderr(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i32 @vfprintf(i32 %6, i8* %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* @stderr
%11 = call i32 @fputc(i8 signext 10, i32 %10)
%12 = load i32, i32* %5
ret i32 %12
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @ut_write_to_stderr(i8* %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @vfprintf(i32 %3, i8* %0, i32 %1)
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputc(i8 signext 10, i32 %5)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  void inverse(char str[]);
  char str[100];
  printf("input string:");
  scanf("%s", str);
  inverse(str);
  printf("inverse string:%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <inverse@plt>
lea    -0x70(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <inverse@plt>
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"input string:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [19 x i8] c"inverse string:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"input string:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [19 x i8] c"inverse string:%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret i32 0
}
/* Type definitions */
typedef union bpf_attr {
  int dummy;
} bpf_attr;

/* Variables and functions */
scalar_t__ syscall(int, int, union bpf_attr *, size_t);
int bpf(int cmd, union bpf_attr *attr, size_t size) {
  return (int)syscall(321, cmd, attr, size);
}


x86 assembly (clang, -O0):
<bpf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x141,%edi
call   1030 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf>:
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %edi,%esi
mov    $0x141,%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
%union.bpf_attr = type { i32 }
define i32 @bpf(i32 %0, %union.bpf_attr* %1, i64 %2) {
%4 = alloca i32
%5 = alloca %union.bpf_attr*
%6 = alloca i64
store i32 %0, i32* %4
store %union.bpf_attr* %1, %union.bpf_attr** %5
store i64 %2, i64* %6
%7 = load i32, i32* %4
%8 = load %union.bpf_attr*, %union.bpf_attr** %5
%9 = load i64, i64* %6
%10 = call i64 @syscall(i32 321, i32 %7, %union.bpf_attr* %8, i64 %9)
%11 = trunc i64 %10 to i32
ret i32 %11
}

LLVM IR (-O2):
%union.bpf_attr = type { i32 }
define i32 @bpf(i32 %0, %union.bpf_attr* %1, i64 %2) {
%4 = tail call i64 @syscall(i32 321, i32 %0, %union.bpf_attr* %1, i64 %2)
%5 = trunc i64 %4 to i32
ret i32 %5
}
/* Type definitions */
struct section_hash {
  int dummy;
};
struct genhash {
  int dummy;
};

/* Variables and functions */
scalar_t__ genhash_copy(struct genhash const *);
struct section_hash *section_hash_copy(const struct section_hash *tthis) {
  return (struct section_hash *)genhash_copy((const struct genhash *)tthis);
}


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

x86 assembly (clang, -O2):
<section_hash_copy>:
jmp    1030 <genhash_copy@plt>

LLVM IR (-O0):
%struct.section_hash = type { i32 }
%struct.genhash = type { i32 }
define %struct.section_hash* @section_hash_copy(%struct.section_hash* %0) {
%2 = alloca %struct.section_hash*
store %struct.section_hash* %0, %struct.section_hash** %2
%3 = load %struct.section_hash*, %struct.section_hash** %2
%4 = bitcast %struct.section_hash* %3 to %struct.genhash*
%5 = call i64 @genhash_copy(%struct.genhash* %4)
%6 = inttoptr i64 %5 to %struct.section_hash*
ret %struct.section_hash* %6
}

LLVM IR (-O2):
%struct.section_hash = type { i32 }
%struct.genhash = type { i32 }
define %struct.section_hash* @section_hash_copy(%struct.section_hash* %0) {
%2 = bitcast %struct.section_hash* %0 to %struct.genhash*
%3 = tail call i64 @genhash_copy(%struct.genhash* %2)
%4 = inttoptr i64 %3 to %struct.section_hash*
ret %struct.section_hash* %4
}
/* Variables and functions */
scalar_t__ INT_MAX;
int main(void) {
  INT_MAX + 1;
  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):
@INT_MAX = global i64 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i64, i64* @INT_MAX
%3 = add nsw i64 %2, 1
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i64 0
define i32 @main() {
ret i32 0
}
int c_ones3(unsigned int x) {
  int result = 0;
  while (x != 0) {
    if (x & 0x01)
      ++result;
    x >>= 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<c_ones3>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     113e <c_ones3+0x3e>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1130 <c_ones3+0x30>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110e <c_ones3+0xe>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_ones3>:
xor    %eax,%eax
test   %edi,%edi
je     1120 <c_ones3+0x20>
mov    %edi,%ecx
nopl   0x0(%rax,%rax,1)
mov    %edi,%edx
and    $0x1,%edx
add    %edx,%eax
shr    %ecx
cmp    $0x1,%edi
mov    %ecx,%edi
ja     1110 <c_ones3+0x10>
ret

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

LLVM IR (-O2):
define i32 @c_ones3(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %10, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %7, %3 ], [ 0, %1 ]
%5 = phi i32 [ %8, %3 ], [ %0, %1 ]
%6 = and i32 %5, 1
%7 = add nuw nsw i32 %4, %6
%8 = lshr i32 %5, 1
%9 = icmp ult i32 %5, 2
br i1 %9, label %10, label %3
10: ; preds = %3, %1
%11 = phi i32 [ 0, %1 ], [ %7, %3 ]
ret i32 %11
}
/* Variables and functions */
long long fatt(long);
long long nPk(long n, long k) { return fatt(n) / fatt(n - k); }


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

x86 assembly (clang, -O2):
<nPk>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <fatt@plt>
mov    %rax,%r15
sub    %r14,%rbx
mov    %rbx,%rdi
call   1030 <fatt@plt>
mov    %rax,%rcx
mov    %r15,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1147 <nPk+0x37>
mov    %r15,%rax
cqto
idiv   %rcx
jmp    114e <nPk+0x3e>
mov    %r15d,%eax
xor    %edx,%edx
div    %ecx
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @nPk(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = call i64 @fatt(i64 %5)
%7 = load i64, i64* %3
%8 = load i64, i64* %4
%9 = sub nsw i64 %7, %8
%10 = call i64 @fatt(i64 %9)
%11 = sdiv i64 %6, %10
ret i64 %11
}

LLVM IR (-O2):
define i64 @nPk(i64 %0, i64 %1) {
%3 = tail call i64 @fatt(i64 %0)
%4 = sub nsw i64 %0, %1
%5 = tail call i64 @fatt(i64 %4)
%6 = sdiv i64 %3, %5
ret i64 %6
}
/* Variables and functions */
int /*<<< orphan*/ usleep(int);
void sleep_msec(unsigned ms) { usleep(1000 * ms); }


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

x86 assembly (clang, -O2):
<sleep_msec>:
imul   $0x3e8,%edi,%edi
jmp    1030 <usleep@plt>

LLVM IR (-O0):
define void @sleep_msec(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = mul i32 1000, %3
%5 = call i32 @usleep(i32 %4)
ret void
}

LLVM IR (-O2):
define void @sleep_msec(i32 %0) {
%2 = mul i32 %0, 1000
%3 = tail call i32 @usleep(i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ perror(char const *);
void die(int errcode, const char *s) {
  perror(s);
  _exit(errcode);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <perror@plt>
mov    -0x4(%rbp),%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbx
mov    %edi,%ebx
mov    %rsi,%rdi
call   1040 <perror@plt>
mov    %ebx,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
define void @die(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @perror(i8* %5)
%7 = load i32, i32* %3
%8 = call i32 @_exit(i32 %7)
unreachable
}

LLVM IR (-O2):
define void @die(i32 %0, i8* nocapture %1) {
%3 = tail call i32 @perror(i8* %1)
%4 = tail call i32 @_exit(i32 %0)
unreachable
}
/* Forward declarations */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int type;
};
struct TYPE_4__ {
  TYPE_1__ xselection;
};
typedef TYPE_2__ XEvent;

/* Variables and functions */
void set_XEvent_xselection_type(void *_p, int _v) {
  ((XEvent *)_p)->xselection.type = (int)_v;
}


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

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

LLVM IR (-O0):
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
define void @set_XEvent_xselection_type(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to %struct.TYPE_4__*
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
store i32 %5, i32* %9
ret void
}

LLVM IR (-O2):
define void @set_XEvent_xselection_type(i8* nocapture writeonly %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
store i32 %1, i32* %3
ret void
}
/* Variables and functions */
double M_PI;
double radians(double degrees) { return degrees * M_PI / 180; }


x86 assembly (clang, -O0):
<radians>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2ed3(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xedf(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<radians>:
mov    0x2ee1(%rip),%rax
mulsd  (%rax),%xmm0
divsd  0xeed(%rip),%xmm0
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @radians(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = load double, double* @M_PI
%5 = fmul double %3, %4
%6 = fdiv double %5, 1.800000e+02
ret double %6
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @radians(double %0) {
%2 = load double, double* @M_PI
%3 = fmul double %2, %0
%4 = fdiv double %3, 1.800000e+02
ret double %4
}
int isspace(int c) { return ((c >= 0x09 && c <= 0x0D) || (c == 0x20)); }


x86 assembly (clang, -O0):
<isspace>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x9,-0x4(%rbp)
jl     1120 <isspace+0x20>
mov    $0x1,%al
cmpl   $0xd,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jle    112a <isspace+0x2a>
cmpl   $0x20,-0x4(%rbp)
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isspace>:
lea    -0x9(%rdi),%eax
cmp    $0x5,%eax
setb   %al
cmp    $0x20,%edi
sete   %cl
or     %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @isspace(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 9
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 13
br i1 %7, label %11, label %8
8: ; preds = %5, %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 32
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
ret i32 %13
}

LLVM IR (-O2):
define i32 @isspace(i32 %0) {
%2 = add i32 %0, -9
%3 = icmp ult i32 %2, 5
%4 = icmp eq i32 %0, 32
%5 = or i1 %4, %3
%6 = zext i1 %5 to i32
ret i32 %6
}
int maxi(int i, int j) { return i > j ? i : j; }


x86 assembly (clang, -O0):
<maxi>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1121 <maxi+0x21>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1127 <maxi+0x27>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxi>:
mov    %esi,%eax
cmp    %esi,%edi
cmovg  %edi,%eax
ret

LLVM IR (-O0):
define i32 @maxi(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 = load i32, i32* %4
%7 = icmp sgt i32 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i32, i32* %3
br label %12
10: ; preds = %2
%11 = load i32, i32* %4
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ]
ret i32 %13
}

LLVM IR (-O2):
define i32 @maxi(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
%4 = select i1 %3, i32 %0, i32 %1
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main() {
  char dest[20];
  char *source = "asdfasdf";
  memmove(dest, source, strlen(source) + 1);
  puts(dest);
  memmove(&dest[1], dest, 4);
  puts(dest);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <memmove@plt>
lea    -0x20(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memmove@plt>
lea    -0x20(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <memmove@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <memmove@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"asdfasdf\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, 1
%8 = call i32 @memmove(i8* %3, i8* %4, i32 %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%10 = call i32 @puts(i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%13 = call i32 @memmove(i8* %11, i8* %12, i32 4)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%15 = call i32 @puts(i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"asdfasdf\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = call i32 @memmove(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @puts(i8* %2)
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%8 = call i32 @memmove(i8* %7, i8* %2, i32 4)
%9 = call i32 @puts(i8* %2)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ pop_stack();
void zpop(void) { pop_stack(); }


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

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

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

LLVM IR (-O2):
define void @zpop() {
%1 = tail call i32 (...) @pop_stack()
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ int64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ prod_from_fileptr(int /*<<< orphan*/ *);
int64_t prod_from_filename(char *filename) {
  FILE *fp = fopen(filename, "r");
  int64_t prod = prod_from_fileptr(fp);
  fclose(fp);
  return prod;
}


x86 assembly (clang, -O0):
<prod_from_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <prod_from_fileptr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prod_from_filename>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <prod_from_fileptr@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @prod_from_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = call i32 @prod_from_fileptr(i32* %7)
store i32 %8, i32* %4
%9 = load i32*, i32** %3
%10 = call i32 @fclose(i32* %9)
%11 = load i32, i32* %4
ret i32 %11
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @prod_from_filename(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @prod_from_fileptr(i32* %2)
%4 = tail call i32 @fclose(i32* %2)
ret i32 %3
}
/* Type definitions */
struct group {
  int /*<<< orphan*/ gr_name;
};
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
struct group *getgrgid(int /*<<< orphan*/);
int /*<<< orphan*/ system_error(char *);
char *xstrdup(int /*<<< orphan*/);
char *get_group_name(gid_t gid) {
  struct group *entry;
  entry = getgrgid(gid);
  if (entry == NULL)
    system_error("getgrgid");
  return xstrdup(entry->gr_name);
}


x86 assembly (clang, -O0):
<get_group_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getgrgid@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115e <get_group_name+0x2e>
lea    0xea7(%rip),%rdi
call   1050 <system_error@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <xstrdup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_group_name>:
push   %rbx
call   1030 <getgrgid@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114a <get_group_name+0x1a>
lea    0xebb(%rip),%rdi
call   1050 <system_error@plt>
mov    (%rbx),%edi
pop    %rbx
jmp    1040 <xstrdup@plt>

LLVM IR (-O0):
%struct.group = type { i32 }
@.str = [9 x i8] c"getgrgid\00"
define i8* @get_group_name(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.group*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call %struct.group* @getgrgid(i32 %4)
store %struct.group* %5, %struct.group** %3
%6 = load %struct.group*, %struct.group** %3
%7 = icmp eq %struct.group* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @system_error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load %struct.group*, %struct.group** %3
%12 = getelementptr inbounds %struct.group, %struct.group* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i8* @xstrdup(i32 %13)
ret i8* %14
}

LLVM IR (-O2):
%struct.group = type { i32 }
@.str = [9 x i8] c"getgrgid\00"
define i8* @get_group_name(i32 %0) {
%2 = tail call %struct.group* @getgrgid(i32 %0)
%3 = icmp eq %struct.group* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @system_error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = getelementptr inbounds %struct.group, %struct.group* %2, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i8* @xstrdup(i32 %8)
ret i8* %9
}
const char *__malidrv_build_info(void) {
  return "malidrv:  API_VERSION=401 REPO_URL= REVISION=r4p0-00rel0 "
         "CHANGED_REVISION=r4p0-00rel0 CHANGE_DATE=r4p0-00rel0 BUILD=release "
         "TARGET_PLATFORM=sc8830 MALI_PLATFORM=sc8830 KDIR= "
         "OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=16 USING_UMP= USING_PROFILING=y "
         "USING_INTERNAL_PROFILING= USING_GPU_UTILIZATION=1 "
         "USING_POWER_PERFORMANCE_POLICY= MALI_UPPER_HALF_SCHEDULING=1";
}


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

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

LLVM IR (-O0):
@.str = [352 x i8] c"malidrv: API_VERSION=401 REPO_URL= REVISION=r4p0-00rel0 CHANGED_REVISION=r4p0-00rel0 CHANGE_DATE=r4p0-00rel0 BUILD=release TARGET_PLATFORM=sc8830 MALI_PLATFORM=sc8830 KDIR= OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=16 USING_UMP= USING_PROFILING=y USING_INTERNAL_PROFILING= USING_GPU_UTILIZATION=1 USING_POWER_PERFORMANCE_POLICY= MALI_UPPER_HALF_SCHEDULING=1\00"
define i8* @__malidrv_build_info() {
ret i8* getelementptr inbounds ([352 x i8], [352 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [352 x i8] c"malidrv: API_VERSION=401 REPO_URL= REVISION=r4p0-00rel0 CHANGED_REVISION=r4p0-00rel0 CHANGE_DATE=r4p0-00rel0 BUILD=release TARGET_PLATFORM=sc8830 MALI_PLATFORM=sc8830 KDIR= OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=16 USING_UMP= USING_PROFILING=y USING_INTERNAL_PROFILING= USING_GPU_UTILIZATION=1 USING_POWER_PERFORMANCE_POLICY= MALI_UPPER_HALF_SCHEDULING=1\00"
define i8* @__malidrv_build_info() {
ret i8* getelementptr inbounds ([352 x i8], [352 x i8]* @.str, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ bar();
void foo(void) {
#pragma omp parallel
  bar();
#pragma omp p
  bar();

#pragma omp parallel

  bar();

#pragma omp p

  bar();
}


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

x86 assembly (clang, -O2):
<foo>:
push   %rax
xor    %eax,%eax
call   1030 <bar@plt>
xor    %eax,%eax
call   1030 <bar@plt>
xor    %eax,%eax
call   1030 <bar@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <bar@plt>

LLVM IR (-O0):
define void @foo() {
%1 = call i32 (...) @bar()
%2 = call i32 (...) @bar()
%3 = call i32 (...) @bar()
%4 = call i32 (...) @bar()
ret void
}

LLVM IR (-O2):
define void @foo() {
%1 = tail call i32 (...) @bar()
%2 = tail call i32 (...) @bar()
%3 = tail call i32 (...) @bar()
%4 = tail call i32 (...) @bar()
ret void
}
/* Variables and functions */
int UINT32_MAX;
int arc4random();
bool house_coinflip(void) {
  return arc4random() > UINT32_MAX / 42 ? true : false;
}


x86 assembly (clang, -O0):
<house_coinflip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <arc4random@plt>
mov    %eax,-0x4(%rbp)
mov    0x2ecf(%rip),%rax
mov    (%rax),%eax
mov    $0x2a,%ecx
cltd
idiv   %ecx
mov    -0x4(%rbp),%edx
mov    %eax,%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovg  %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<house_coinflip>:
push   %rax
xor    %eax,%eax
call   1030 <arc4random@plt>
mov    0x2ed9(%rip),%rcx
movslq (%rcx),%rcx
imul   $0x30c30c31,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rdx
add    %ecx,%edx
xor    %ecx,%ecx
cmp    %edx,%eax
setg   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@UINT32_MAX = global i32 0
define i32 @house_coinflip() {
%1 = call i32 (...) @arc4random()
%2 = load i32, i32* @UINT32_MAX
%3 = sdiv i32 %2, 42
%4 = icmp sgt i32 %1, %3
%5 = zext i1 %4 to i64
%6 = select i1 %4, i32 1, i32 0
ret i32 %6
}

LLVM IR (-O2):
@UINT32_MAX = global i32 0
define i32 @house_coinflip() {
%1 = tail call i32 (...) @arc4random()
%2 = load i32, i32* @UINT32_MAX
%3 = sdiv i32 %2, 42
%4 = icmp sgt i32 %1, %3
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ child_log(char *, char const *);
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *create_command_copy(const char *command) {
  char *new_command = (char *)malloc(strlen(command) + 1);
  if (!new_command) {
    child_log("Child: Unable to allocate space for command: %s\n", command);
    exit(-1);
  }
  strcpy(new_command, command);
}


x86 assembly (clang, -O0):
<create_command_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <create_command_copy+0x4a>
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <child_log@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_command_copy>:
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     1173 <create_command_copy+0x23>
mov    %rax,%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <strcpy@plt>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
call   1040 <child_log@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"Child: Unable to allocate space for command: %s\0A\00"
define i8* @create_command_copy(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = add nsw i64 %6, 1
%8 = call i64 @malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @child_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [49 x i8] c"Child: Unable to allocate space for command: %s\0A\00"
define noalias i8* @create_command_copy(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i64 @malloc(i64 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 @child_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %1
%10 = inttoptr i64 %4 to i8*
%11 = tail call i32 @strcpy(i8* %10, i8* %0)
ret i8* undef
}
/* Type definitions */
typedef unsigned char int16_t;

/* Variables and functions */
int16_t get_int16(unsigned char *buf) { return (buf[0] | (buf[1] << 8)); }


x86 assembly (clang, -O0):
<get_int16>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int16>:
mov    (%rdi),%al
ret

LLVM IR (-O0):
define zeroext i8 @get_int16(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = shl i32 %10, 8
%12 = or i32 %6, %11
%13 = trunc i32 %12 to i8
ret i8 %13
}

LLVM IR (-O2):
define zeroext i8 @get_int16(i8* nocapture %0) {
%2 = load i8, i8* %0
ret i8 %2
}
/* Type definitions */
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ eeprom_write_word(int /*<<< orphan*/ *, int /*<<< orphan*/);
void eeprom_update_word(uint16_t *addr, uint16_t value) {
  eeprom_write_word(addr, value);
}


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

x86 assembly (clang, -O2):
<eeprom_update_word>:
jmp    1030 <eeprom_write_word@plt>

LLVM IR (-O0):
define void @eeprom_update_word(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 = load i32, i32* %4
%7 = call i32 @eeprom_write_word(i32* %5, i32 %6)
ret void
}

LLVM IR (-O2):
define void @eeprom_update_word(i32* %0, i32 %1) {
%3 = tail call i32 @eeprom_write_word(i32* %0, i32 %1)
ret void
}
/* Type definitions */
struct stat {
  int dummy;
};

/* Variables and functions */
scalar_t__ stat(char const *, struct stat *);
int osal_path_existsA(const char *path) {
  struct stat fileinfo;
  return stat(path, &fileinfo) == 0 ? 1 : 0;
}


x86 assembly (clang, -O0):
<osal_path_existsA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <stat@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osal_path_existsA>:
push   %rax
mov    %rsp,%rsi
call   1030 <stat@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @osal_path_existsA(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @stat(i8* %4, %struct.stat* %3)
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 1, i32 0
ret i32 %8
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @osal_path_existsA(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
ret i32 %6
}
/* Type definitions */
struct tpacket3_hdr {
  int tp_status;
};

/* Variables and functions */
int TP_STATUS_SENDING;
int TP_STATUS_SEND_REQUEST;
int __v3_tx_kernel_ready(struct tpacket3_hdr *hdr) {
  return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
}


x86 assembly (clang, -O0):
<__v3_tx_kernel_ready>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2ed3(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2eba(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__v3_tx_kernel_ready>:
mov    0x2ee1(%rip),%rax
mov    0x2eca(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %eax,%eax
test   %ecx,(%rdi)
sete   %al
ret

LLVM IR (-O0):
%struct.tpacket3_hdr = type { i32 }
@TP_STATUS_SEND_REQUEST = global i32 0
@TP_STATUS_SENDING = global i32 0
define i32 @__v3_tx_kernel_ready(%struct.tpacket3_hdr* %0) {
%2 = alloca %struct.tpacket3_hdr*
store %struct.tpacket3_hdr* %0, %struct.tpacket3_hdr** %2
%3 = load %struct.tpacket3_hdr*, %struct.tpacket3_hdr** %2
%4 = getelementptr inbounds %struct.tpacket3_hdr, %struct.tpacket3_hdr* %3, i32 0, i32 0
%5 = load i32, i32* %4
%6 = load i32, i32* @TP_STATUS_SEND_REQUEST
%7 = load i32, i32* @TP_STATUS_SENDING
%8 = or i32 %6, %7
%9 = and i32 %5, %8
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
%12 = zext i1 %11 to i32
ret i32 %12
}

LLVM IR (-O2):
%struct.tpacket3_hdr = type { i32 }
@TP_STATUS_SEND_REQUEST = global i32 0
@TP_STATUS_SENDING = global i32 0
define i32 @__v3_tx_kernel_ready(%struct.tpacket3_hdr* nocapture %0) {
%2 = getelementptr inbounds %struct.tpacket3_hdr, %struct.tpacket3_hdr* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = load i32, i32* @TP_STATUS_SEND_REQUEST
%5 = load i32, i32* @TP_STATUS_SENDING
%6 = or i32 %5, %4
%7 = and i32 %6, %3
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
ret i32 %9
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
void mpga_set_emphasis(uint8_t *p_mpga, uint8_t i_emphasis) {
  p_mpga[3] &= ~0x03;
  p_mpga[3] |= i_emphasis & 0x03;
}


x86 assembly (clang, -O0):
<mpga_set_emphasis>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%ecx
and    $0xfffffffc,%ecx
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
and    $0x3,%ecx
mov    -0x8(%rbp),%rax
or     0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpga_set_emphasis>:
mov    0xc(%rdi),%eax
and    $0xfffffffc,%eax
and    $0x3,%esi
or     %eax,%esi
mov    %esi,0xc(%rdi)
ret

LLVM IR (-O0):
define void @mpga_set_emphasis(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 = getelementptr inbounds i32, i32* %5, i64 3
%7 = load i32, i32* %6
%8 = and i32 %7, -4
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = and i32 %9, 3
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 3
%13 = load i32, i32* %12
%14 = or i32 %13, %10
store i32 %14, i32* %12
ret void
}

LLVM IR (-O2):
define void @mpga_set_emphasis(i32* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 3
%4 = load i32, i32* %3
%5 = and i32 %4, -4
%6 = and i32 %1, 3
%7 = or i32 %5, %6
store i32 %7, i32* %3
ret void
}
/* Type definitions */
struct obus_bus_event {
  int dummy;
};
struct net_bus_event {
  int dummy;
};

/* Variables and functions */
int obus_bus_event_destroy(struct obus_bus_event *);
int net_bus_event_destroy(struct net_bus_event *event) {
  return obus_bus_event_destroy((struct obus_bus_event *)event);
}


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

x86 assembly (clang, -O2):
<net_bus_event_destroy>:
jmp    1030 <obus_bus_event_destroy@plt>

LLVM IR (-O0):
%struct.net_bus_event = type { i32 }
%struct.obus_bus_event = type { i32 }
define i32 @net_bus_event_destroy(%struct.net_bus_event* %0) {
%2 = alloca %struct.net_bus_event*
store %struct.net_bus_event* %0, %struct.net_bus_event** %2
%3 = load %struct.net_bus_event*, %struct.net_bus_event** %2
%4 = bitcast %struct.net_bus_event* %3 to %struct.obus_bus_event*
%5 = call i32 @obus_bus_event_destroy(%struct.obus_bus_event* %4)
ret i32 %5
}

LLVM IR (-O2):
%struct.net_bus_event = type { i32 }
%struct.obus_bus_event = type { i32 }
define i32 @net_bus_event_destroy(%struct.net_bus_event* %0) {
%2 = bitcast %struct.net_bus_event* %0 to %struct.obus_bus_event*
%3 = tail call i32 @obus_bus_event_destroy(%struct.obus_bus_event* %2)
ret i32 %3
}
/* Type definitions */
struct sb {
  int dummy;
};
struct buffer_head {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ buffer_dirty(struct buffer_head *);
int leaf_need_redirect(struct sb *sb, struct buffer_head *buffer) {
  return !buffer_dirty(buffer);
}


x86 assembly (clang, -O0):
<leaf_need_redirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <buffer_dirty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leaf_need_redirect>:
push   %rax
mov    %rsi,%rdi
call   1030 <buffer_dirty@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sb = type { i32 }
%struct.buffer_head = type { i32 }
define i32 @leaf_need_redirect(%struct.sb* %0, %struct.buffer_head* %1) {
%3 = alloca %struct.sb*
%4 = alloca %struct.buffer_head*
store %struct.sb* %0, %struct.sb** %3
store %struct.buffer_head* %1, %struct.buffer_head** %4
%5 = load %struct.buffer_head*, %struct.buffer_head** %4
%6 = call i32 @buffer_dirty(%struct.buffer_head* %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
%struct.sb = type { i32 }
%struct.buffer_head = type { i32 }
define i32 @leaf_need_redirect(%struct.sb* nocapture readnone %0, %struct.buffer_head* %1) {
%3 = tail call i32 @buffer_dirty(%struct.buffer_head* %1)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ setchar(int, int, char);
void clear_line(int line) {
  for (int col = 0; col < 80; col++)
    setchar(line, col, ' ');
}


x86 assembly (clang, -O0):
<clear_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    114a <clear_line+0x3a>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x20,%edx
call   1030 <setchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <clear_line+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_line>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x20,%edx
call   1030 <setchar@plt>
add    $0x1,%ebp
cmp    $0x50,%ebp
jne    1120 <clear_line+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @clear_line(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %11, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 80
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @setchar(i32 %8, i32 %9, i8 signext 32)
br label %11
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %4
14: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @clear_line(i32 %0) {
br label %3
2: ; preds = %3
ret void
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %6, %3 ]
%5 = tail call i32 @setchar(i32 %0, i32 %4, i8 signext 32)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 80
br i1 %7, label %2, label %3
}