xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ assert(int);
int f2(int i) {
  assert(i != 2);
  return i;
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x2,%ebx
setne  %dil
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @f2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 2
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i32, i32* %2
ret i32 %7
}

LLVM IR (-O2):
define i32 @f2(i32 returned %0) {
%2 = icmp ne i32 %0, 2
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
ret i32 %0
}
/* Variables and functions */
int task_flag_asserted(int, int);
int task_enabled(int id) { return task_flag_asserted(id, (1 << 0)); }


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

x86 assembly (clang, -O2):
<task_enabled>:
mov    $0x1,%esi
jmp    1030 <task_flag_asserted@plt>

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

LLVM IR (-O2):
define i32 @task_enabled(i32 %0) {
%2 = tail call i32 @task_flag_asserted(i32 %0, i32 1)
ret i32 %2
}
/* Variables and functions */
int strncmp(char const *, char const *, int);
int compare_strings_4(const void *a, const void *b) {
  return strncmp(*(const char **)a, *(const char **)b, 4);
}


x86 assembly (clang, -O0):
<compare_strings_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_strings_4>:
mov    (%rdi),%rdi
mov    (%rsi),%rsi
mov    $0x4,%edx
jmp    1030 <strncmp@plt>

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

LLVM IR (-O2):
define i32 @compare_strings_4(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i8**
%4 = load i8*, i8** %3
%5 = bitcast i8* %1 to i8**
%6 = load i8*, i8** %5
%7 = tail call i32 @strncmp(i8* %4, i8* %6, i32 4)
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ nao_troca(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ troca(int *, int *);
void main() {
  int x = 1, y = 2;
  nao_troca(x, y);
  printf("Valor de x = [%d] y = [%d]\n", x, y);
  troca(&x, &y);
  printf("Valor de x = [%d] y = [%d]\n", x, y);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <nao_troca@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <troca@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
movl   $0x2,0x8(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <nao_troca@plt>
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <troca@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Valor de x = [%d] y = [%d]\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %1
store i32 2, i32* %2
%3 = load i32, i32* %1
%4 = load i32, i32* %2
%5 = call i32 @nao_troca(i32 %3, i32 %4)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 @troca(i32* %1, i32* %2)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Valor de x = [%d] y = [%d]\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = tail call i32 @nao_troca(i32 1, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
%7 = call i32 @troca(i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
ret void
}
/* Type definitions */
struct timespec {
  int dummy;
};
typedef scalar_t__ clockid_t;

/* Variables and functions */
scalar_t__ _syscall5(int, void *, void *, void *, void *, void *);
int errno;
int clock_gettime(clockid_t clock_id, struct timespec *tp) {
  int ret = (int)_syscall5(42, (void *)clock_id, (void *)tp, ((void *)0),
                           ((void *)0), ((void *)0));
  if (ret < 0) {
    errno = -ret;
    return -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<clock_gettime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x2a,%edi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <_syscall5@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1164 <clock_gettime+0x54>
xor    %ecx,%ecx
sub    -0x1c(%rbp),%ecx
mov    0x2e8a(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    116a <clock_gettime+0x5a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_gettime>:
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    $0x2a,%edi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <_syscall5@plt>
test   %eax,%eax
js     112f <clock_gettime+0x1f>
pop    %rcx
ret
neg    %eax
mov    0x2ea8(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@errno = global i32 0
define i32 @clock_gettime(i64 %0, %struct.timespec* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca %struct.timespec*
%6 = alloca i32
store i64 %0, i64* %4
store %struct.timespec* %1, %struct.timespec** %5
%7 = load i64, i64* %4
%8 = inttoptr i64 %7 to i8*
%9 = load %struct.timespec*, %struct.timespec** %5
%10 = bitcast %struct.timespec* %9 to i8*
%11 = call i64 @_syscall5(i32 42, i8* %8, i8* %10, i8* null, i8* null, i8* null)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* %6
%17 = sub nsw i32 0, %16
store i32 %17, i32* @errno
store i32 -1, i32* %3
br label %20
18: ; preds = %2
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %20
20: ; preds = %18, %15
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@errno = global i32 0
define i32 @clock_gettime(i64 %0, %struct.timespec* %1) {
%3 = inttoptr i64 %0 to i8*
%4 = bitcast %struct.timespec* %1 to i8*
%5 = tail call i64 @_syscall5(i32 42, i8* %3, i8* %4, i8* null, i8* null, i8* null)
%6 = trunc i64 %5 to i32
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = sub nsw i32 0, %6
store i32 %9, i32* @errno
br label %10
10: ; preds = %2, %8
%11 = phi i32 [ -1, %8 ], [ %6, %2 ]
ret i32 %11
}
void putstr(s) const char *s;
{ addstr(s); }


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

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

LLVM IR (-O0):
define void @putstr(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @addstr to i32 (i8*, ...)*)(i8* %3)
ret void
}

LLVM IR (-O2):
define void @putstr(i8* %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @addstr to i32 (i8*, ...)*)(i8* %0)
ret void
}
/* Type definitions */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t be32getv(void *p) {
  uint8_t *a;
  uint32_t v;
  a = p;
  v = a[0] << 24;
  v |= a[1] << 16;
  v |= a[2] << 8;
  v |= a[3];
  return v;
}


x86 assembly (clang, -O0):
<be32getv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x18,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x10,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
shl    $0x8,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<be32getv>:
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
shl    $0x18,%eax
shl    $0x10,%ecx
or     %eax,%ecx
mov    0x8(%rdi),%eax
shl    $0x8,%eax
or     %ecx,%eax
or     0xc(%rdi),%eax
ret

LLVM IR (-O0):
define i32 @be32getv(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = shl i32 %9, 24
store i32 %10, i32* %4
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
%14 = shl i32 %13, 16
%15 = load i32, i32* %4
%16 = or i32 %15, %14
store i32 %16, i32* %4
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = shl i32 %19, 8
%21 = load i32, i32* %4
%22 = or i32 %21, %20
store i32 %22, i32* %4
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = load i32, i32* %4
%27 = or i32 %26, %25
store i32 %27, i32* %4
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
define i32 @be32getv(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = shl i32 %3, 24
%5 = getelementptr inbounds i8, i8* %0, i64 4
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
%8 = shl i32 %7, 16
%9 = or i32 %8, %4
%10 = getelementptr inbounds i8, i8* %0, i64 8
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = or i32 %9, %13
%15 = getelementptr inbounds i8, i8* %0, i64 12
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = or i32 %14, %17
ret i32 %18
}
int gcd(int x, int y) {
  if (y == 0)
    return 1;
  else
    return gcd(y, x % y);
}


x86 assembly (clang, -O0):
<gcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1134 <gcd+0x24>
movl   $0x1,-0x4(%rbp)
jmp    1148 <gcd+0x38>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
call   1030 <gcd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd>:
test   %esi,%esi
je     111b <gcd+0x1b>
mov    %esi,%edx
mov    %edi,%eax
nopl   0x0(%rax,%rax,1)
mov    %edx,%ecx
cltd
idiv   %ecx
mov    %ecx,%eax
test   %edx,%edx
jne    1110 <gcd+0x10>
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @gcd(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 eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %15
9: ; preds = %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = srem i32 %11, %12
%14 = call i32 @gcd(i32 %10, i32 %13)
store i32 %14, i32* %3
br label %15
15: ; preds = %9, %8
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
define i32 @gcd(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %9, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %7, %4 ], [ %1, %2 ]
%6 = phi i32 [ %5, %4 ], [ %0, %2 ]
%7 = srem i32 %6, %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4, %2
ret i32 1
}
long eval_exponent(char op, long a, long b) {
  if (b < 0)
    return 0;
  if (b == 0)
    return 1;
  if (b == 1)
    return a;
  return a * eval_exponent(op, a, b - 1);
}


x86 assembly (clang, -O0):
<eval_exponent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    113e <eval_exponent+0x2e>
movq   $0x0,-0x8(%rbp)
jmp    119c <eval_exponent+0x8c>
cmpq   $0x0,-0x20(%rbp)
jne    1156 <eval_exponent+0x46>
movq   $0x1,-0x8(%rbp)
jmp    119c <eval_exponent+0x8c>
cmpq   $0x1,-0x20(%rbp)
jne    116e <eval_exponent+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <eval_exponent+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
sub    $0x1,%rdx
movsbl %al,%edi
call   1030 <eval_exponent@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_exponent>:
mov    $0x1,%eax
test   %rdx,%rdx
js     1132 <eval_exponent+0x32>
nopw   0x0(%rax,%rax,1)
test   %rdx,%rdx
je     1128 <eval_exponent+0x28>
cmp    $0x1,%rdx
je     112d <eval_exponent+0x2d>
add    $0xffffffffffffffff,%rdx
imul   %rsi,%rax
test   %rdx,%rdx
jne    1115 <eval_exponent+0x15>
mov    $0x1,%esi
imul   %rsi,%rax
ret
xor    %esi,%esi
imul   %rsi,%rax
ret

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

LLVM IR (-O2):
define i64 @eval_exponent(i8 signext %0, i64 %1, i64 %2) {
%4 = icmp slt i64 %2, 0
br i1 %4, label %12, label %5
5: ; preds = %3, %8
%6 = phi i64 [ %9, %8 ], [ %2, %3 ]
%7 = phi i64 [ %10, %8 ], [ 1, %3 ]
switch i64 %6, label %8 [
i64 0, label %11
i64 1, label %12
]
8: ; preds = %5
%9 = add nsw i64 %6, -1
%10 = mul nsw i64 %7, %1
br label %5
11: ; preds = %5
br label %12
12: ; preds = %5, %11, %3
%13 = phi i64 [ 1, %3 ], [ %7, %11 ], [ %7, %5 ]
%14 = phi i64 [ 0, %3 ], [ 1, %11 ], [ %1, %5 ]
%15 = mul nsw i64 %14, %13
ret i64 %15
}
int acpi_is_wakeup_s4(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @acpi_is_wakeup_s4() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int regexec(int /*<<< orphan*/ *, char const *, int const, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int match_regex(regex_t *r, const char *to_match) {
  const char *p = to_match;
  const int n_matches = 1;
  regmatch_t m[n_matches];
  int nomatch = regexec(r, p, n_matches, m, 0);
  if (nomatch) {
    return nomatch;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<match_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    %rsp,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
lea    -0x40(%rbp),%rcx
xor    %r8d,%r8d
call   1030 <regexec@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     116e <match_regex+0x5e>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    117c <match_regex+0x6c>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_regex>:
push   %rax
mov    %rsp,%rcx
mov    $0x1,%edx
xor    %r8d,%r8d
call   1030 <regexec@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @match_regex(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %5
store i8* %11, i8** %6
store i32 1, i32* %7
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i32, i64 1
%14 = load i32*, i32** %4
%15 = load i8*, i8** %6
%16 = call i32 @regexec(i32* %14, i8* %15, i32 1, i32* %13, i32 0)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = load i32, i32* %9
store i32 %20, i32* %3
store i32 1, i32* %10
br label %22
21: ; preds = %2
store i32 0, i32* %3
store i32 1, i32* %10
br label %22
22: ; preds = %21, %19
%23 = load i8*, i8** %8
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @match_regex(i32* %0, i8* %1) {
%3 = alloca i32
%4 = call i32 @regexec(i32* %0, i8* %1, i32 1, i32* %3, i32 0)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void usage() {
  fprintf(stderr, "Usage: "
                  "sg_read_block_limits  [--help] [--hex] [--raw] [--verbose] "
                  "[--version]\n"
                  "                             DEVICE\n"
                  "  where:\n"
                  "    --help|-h          print out usage message\n"
                  "    --hex|-H           output response in hexadecimal\n"
                  "    --raw|-r           output response in binary to stdout\n"
                  "    --verbose|-v       increase verbosity\n"
                  "    --version|-V       print version string and exit\n\n"
                  "Performs a SCSI READ BLOCK LIMITS command and decode the "
                  "response\n");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    0xee0(%rip),%rsi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [446 x i8] c"Usage: sg_read_block_limits [--help] [--hex] [--raw] [--verbose] [--version]\0A DEVICE\0A where:\0A --help|-h print out usage message\0A --hex|-H output response in hexadecimal\0A --raw|-r output response in binary to stdout\0A --verbose|-v increase verbosity\0A --version|-V print version string and exit\0A\0APerforms a SCSI READ BLOCK LIMITS command and decode the response\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([446 x i8], [446 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [446 x i8] c"Usage: sg_read_block_limits [--help] [--hex] [--raw] [--verbose] [--version]\0A DEVICE\0A where:\0A --help|-h print out usage message\0A --hex|-H output response in hexadecimal\0A --raw|-r output response in binary to stdout\0A --verbose|-v increase verbosity\0A --version|-V print version string and exit\0A\0APerforms a SCSI READ BLOCK LIMITS command and decode the response\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([446 x i8], [446 x i8]* @.str, i64 0, i64 0))
ret void
}
int main() {
  __attribute__((type_annotate("tainted"))) int x;
  x = 5;
  int y;
  y = x;
  x = y;
  y = x + 3;
  y = -x;
  float z;
  z = x;
  int a = x * 9;
  __attribute__((type_annotate("tainted"))) int *b;
  int *c;
  b = c;
  c = b;
  b = b;
  c = c;
  b = 0;
  c = 0;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
imul   $0x9,-0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%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 i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
store i32 5, i32* %2
%8 = load i32, i32* %2
store i32 %8, i32* %3
%9 = load i32, i32* %3
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 3
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = sub nsw i32 0, %12
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to float
store float %15, float* %4
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 9
store i32 %17, i32* %5
%18 = load i32*, i32** %7
store i32* %18, i32** %6
%19 = load i32*, i32** %6
store i32* %19, i32** %7
%20 = load i32*, i32** %6
store i32* %20, i32** %6
%21 = load i32*, i32** %7
store i32* %21, i32** %7
store i32* null, i32** %6
store i32* null, i32** %7
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
int loop() {
  int i, j, k;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      for (k = 0; k < 100; k++) {
        int sum = i + j;
      }
    }
  }
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1174 <loop+0x74>
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1161 <loop+0x61>
movl   $0x0,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jge    114e <loop+0x4e>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <loop+0x2d>
jmp    1153 <loop+0x53>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111c <loop+0x1c>
jmp    1166 <loop+0x66>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    110b <loop+0xb>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @loop() {
ret i32 undef
}
int hp71_length(unsigned char *entry) {
  int length;
  length = (*(entry + 28)) + ((*(entry + 29)) << 8) + ((*(entry + 30)) << 16);
  length = (length + 1) / 2;
  return (length);
}


x86 assembly (clang, -O0):
<hp71_length>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x1c(%rax),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1d(%rcx),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1e(%rcx),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hp71_length>:
movzwl 0x1c(%rdi),%eax
movzbl 0x1e(%rdi),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
add    $0x1,%eax
shr    %eax
ret

LLVM IR (-O0):
define i32 @hp71_length(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 28
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 29
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = shl i32 %11, 8
%13 = add nsw i32 %7, %12
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 30
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl i32 %17, 16
%19 = add nsw i32 %13, %18
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sdiv i32 %21, 2
store i32 %22, i32* %3
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @hp71_length(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 28
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = getelementptr inbounds i8, i8* %0, i64 29
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = shl nuw nsw i32 %7, 8
%9 = or i32 %8, %4
%10 = getelementptr inbounds i8, i8* %0, i64 30
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = shl nuw nsw i32 %12, 16
%14 = or i32 %9, %13
%15 = add nuw nsw i32 %14, 1
%16 = lshr i32 %15, 1
ret i32 %16
}
/* Variables and functions */
void *pubrealloc(int /*<<< orphan*/ *, size_t, char *);
void *malloc(size_t size) { return (pubrealloc(NULL, size, " in malloc():")); }


x86 assembly (clang, -O0):
<malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    0xed5(%rip),%rdx
call   1030 <pubrealloc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<malloc>:
mov    %rdi,%rsi
lea    0xee6(%rip),%rdx
xor    %edi,%edi
jmp    1030 <pubrealloc@plt>

LLVM IR (-O0):
@.str = [14 x i8] c" in malloc():\00"
define i8* @malloc(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = call i8* @pubrealloc(i32* null, i64 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i8* %4
}

LLVM IR (-O2):
@.str = [14 x i8] c" in malloc():\00"
define i8* @malloc(i64 %0) {
%2 = tail call i8* @pubrealloc(i32* null, i64 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i8* %2
}
int int_shifts_are_logical(void) {
  int x = ~0;
  x >>= 1;
  return !!(~x);
}


x86 assembly (clang, -O0):
<int_shifts_are_logical>:
push   %rbp
mov    %rsp,%rbp
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @int_shifts_are_logical() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = load i32, i32* %1
%3 = ashr i32 %2, 1
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = xor i32 %4, -1
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
define i32 @int_shifts_are_logical() {
ret i32 0
}
/* Variables and functions */
int atoi(char *);
void copy_int(char *str, void *val) { *((int *)val) = atoi(str); }


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

x86 assembly (clang, -O2):
<copy_int>:
push   %rbx
mov    %rsi,%rbx
call   1030 <atoi@plt>
mov    %eax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @copy_int(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i32 @atoi(i8* %5)
%7 = load i8*, i8** %4
%8 = bitcast i8* %7 to i32*
store i32 %6, i32* %8
ret void
}

LLVM IR (-O2):
define void @copy_int(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @atoi(i8* %0)
%4 = bitcast i8* %1 to i32*
store i32 %3, i32* %4
ret void
}
/* Variables and functions */
int /*<<< orphan*/ g_world();
int /*<<< orphan*/ h_world();
int main(void) {
  h_world();
  g_world();
}


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @h_world()
%2 = tail call i32 (...) @g_world()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ lgen(char *, char *, int);
void cgldlab(int id) { lgen("%s\t$%c%d,%%eax", "movl", id); }


x86 assembly (clang, -O0):
<cgldlab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
lea    0xedb(%rip),%rdi
lea    0xee3(%rip),%rsi
call   1030 <lgen@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgldlab>:
mov    %edi,%edx
lea    0xee7(%rip),%rdi
lea    0xeef(%rip),%rsi
jmp    1030 <lgen@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%s\09$%c%d,%%eax\00"
@.str.1 = [5 x i8] c"movl\00"
define void @cgldlab(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @lgen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%s\09$%c%d,%%eax\00"
@.str.1 = [5 x i8] c"movl\00"
define void @cgldlab(i32 %0) {
%2 = tail call i32 @lgen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(int argc, char const *argv[]) {
  printf("Hello World");
  return 0;
}


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    0xed3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [12 x i8] c"Hello World\00"
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 i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello World\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int fib(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[], char *envp[]) {
  int g3;
  int local0;
  printf("Input number: ");
  scanf("%d", &local0);
  g3 = fib(local0);
  printf("fibonacci(%d) = %d\n", local0, g3);
  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)
mov    %rdx,-0x18(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%edi
call   1050 <fib@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
call   1050 <fib@plt>
mov    0x4(%rsp),%esi
lea    0xeae(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Input number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"fibonacci(%d) = %d\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%12 = load i32, i32* %9
%13 = call i32 @fib(i32 %12)
store i32 %13, i32* %8
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Input number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"fibonacci(%d) = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = call i32 @fib(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %9)
ret i32 0
}
int mat4_idx(int row, int column) { return row + (column << 2); }


x86 assembly (clang, -O0):
<mat4_idx>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4_idx>:
lea    (%rdi,%rsi,4),%eax
ret

LLVM IR (-O0):
define i32 @mat4_idx(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 = shl i32 %6, 2
%8 = add nsw i32 %5, %7
ret i32 %8
}

LLVM IR (-O2):
define i32 @mat4_idx(i32 %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = add nsw i32 %3, %0
ret i32 %4
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int dll_setvbuf(int /*<<< orphan*/ *, char *, int, size_t);
int __wrap_setvbuf(FILE *stream, char *buf, int type, size_t size) {
  return dll_setvbuf(stream, buf, type, size);
}


x86 assembly (clang, -O0):
<__wrap_setvbuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <dll_setvbuf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__wrap_setvbuf>:
jmp    1030 <dll_setvbuf@plt>

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

LLVM IR (-O2):
define i32 @__wrap_setvbuf(i32* %0, i8* %1, i32 %2, i64 %3) {
%5 = tail call i32 @dll_setvbuf(i32* %0, i8* %1, i32 %2, i64 %3)
ret i32 %5
}
double copy_kernel(double v) { return v; }


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

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

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

LLVM IR (-O2):
define double @copy_kernel(double returned %0) {
ret double %0
}
/* Variables and functions */
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ errno;
void *sbrk(intptr_t increment) {
  errno = ENOSYS;
  return (void *)-1;
}


x86 assembly (clang, -O0):
<sbrk>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    0x2ed9(%rip),%rax
mov    (%rax),%ecx
mov    0x2ec0(%rip),%rax
mov    %ecx,(%rax)
mov    $0xffffffffffffffff,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sbrk>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%eax
mov    0x2ec8(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
@ENOSYS = global i32 0
@errno = global i32 0
define i8* @sbrk(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i32, i32* @ENOSYS
store i32 %3, i32* @errno
ret i8* inttoptr (i64 -1 to i8*)
}

LLVM IR (-O2):
@ENOSYS = global i32 0
@errno = global i32 0
define i8* @sbrk(i64 %0) {
%2 = load i32, i32* @ENOSYS
store i32 %2, i32* @errno
ret i8* inttoptr (i64 -1 to i8*)
}
/* Variables and functions */
int /*<<< orphan*/ write(int, char *, int);
void errchar(char c) { write(2, &c, 1); }


x86 assembly (clang, -O0):
<errchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x2,%edi
lea    -0x1(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @errchar(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = call i32 @write(i32 2, i8* %2, i32 1)
ret void
}

LLVM IR (-O2):
define void @errchar(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = call i32 @write(i32 2, i8* %2, i32 1)
ret void
}
/* Type definitions */
struct timespec {
  int dummy;
};

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
scalar_t__ nanosleep(struct timespec const *, struct timespec *);
int thrd_sleep(const struct timespec *duration, struct timespec *remaining) {
  if (nanosleep(duration, remaining) < 0)
    return errno == EINTR ? -1 : -2;
  return 0;
}


x86 assembly (clang, -O0):
<thrd_sleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <nanosleep@plt>
cmp    $0x0,%rax
jge    1163 <thrd_sleep+0x53>
mov    0x2ea2(%rip),%rax
mov    (%rax),%rdx
mov    0x2e90(%rip),%rax
mov    (%rax),%rsi
mov    $0xfffffffe,%eax
mov    $0xffffffff,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    116a <thrd_sleep+0x5a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thrd_sleep>:
push   %rax
call   1030 <nanosleep@plt>
mov    0x2ec3(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2eb1(%rip),%rdx
xor    %esi,%esi
cmp    (%rdx),%rcx
sete   %sil
or     $0xfffffffe,%esi
sar    $0x3f,%rax
and    %esi,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @thrd_sleep(%struct.timespec* %0, %struct.timespec* %1) {
%3 = alloca i32
%4 = alloca %struct.timespec*
%5 = alloca %struct.timespec*
store %struct.timespec* %0, %struct.timespec** %4
store %struct.timespec* %1, %struct.timespec** %5
%6 = load %struct.timespec*, %struct.timespec** %4
%7 = load %struct.timespec*, %struct.timespec** %5
%8 = call i64 @nanosleep(%struct.timespec* %6, %struct.timespec* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = load i64, i64* @EINTR
%13 = icmp eq i64 %11, %12
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 -1, i32 -2
store i32 %15, i32* %3
br label %17
16: ; preds = %2
store i32 0, i32* %3
br label %17
17: ; preds = %16, %10
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @thrd_sleep(%struct.timespec* %0, %struct.timespec* %1) {
%3 = tail call i64 @nanosleep(%struct.timespec* %0, %struct.timespec* %1)
%4 = icmp slt i64 %3, 0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EINTR
%7 = icmp eq i64 %5, %6
%8 = select i1 %7, i32 -1, i32 -2
%9 = select i1 %4, i32 %8, i32 0
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ dotest(int, int, char *);
int main() {
  dotest(1, 250, "{{1, 1}{42, 2500}{246, 84100}}");
  dotest(42, 250, "{{42, 2500}{246, 84100}}");
  dotest(250, 500, "{{287, 84100}}");
  dotest(300, 600, "{}");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%edi
mov    $0xfa,%esi
lea    0xedb(%rip),%rdx
call   1030 <dotest@plt>
mov    $0x2a,%edi
mov    $0xfa,%esi
lea    0xee4(%rip),%rdx
call   1030 <dotest@plt>
mov    $0xfa,%edi
mov    $0x1f4,%esi
lea    0xee7(%rip),%rdx
call   1030 <dotest@plt>
mov    $0x12c,%edi
mov    $0x258,%esi
lea    0xee0(%rip),%rdx
call   1030 <dotest@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdx
mov    $0x1,%edi
mov    $0xfa,%esi
call   1030 <dotest@plt>
lea    0xef1(%rip),%rdx
mov    $0x2a,%edi
mov    $0xfa,%esi
call   1030 <dotest@plt>
lea    0xef4(%rip),%rdx
mov    $0xfa,%edi
mov    $0x1f4,%esi
call   1030 <dotest@plt>
lea    0xeed(%rip),%rdx
mov    $0x12c,%edi
mov    $0x258,%esi
call   1030 <dotest@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"{{1, 1}{42, 2500}{246, 84100}}\00"
@.str.1 = [25 x i8] c"{{42, 2500}{246, 84100}}\00"
@.str.2 = [15 x i8] c"{{287, 84100}}\00"
@.str.3 = [3 x i8] c"{}\00"
define i32 @main() {
%1 = call i32 @dotest(i32 1, i32 250, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @dotest(i32 42, i32 250, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @dotest(i32 250, i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @dotest(i32 300, i32 600, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"{{1, 1}{42, 2500}{246, 84100}}\00"
@.str.1 = [25 x i8] c"{{42, 2500}{246, 84100}}\00"
@.str.2 = [15 x i8] c"{{287, 84100}}\00"
@.str.3 = [3 x i8] c"{}\00"
define i32 @main() {
%1 = tail call i32 @dotest(i32 1, i32 250, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @dotest(i32 42, i32 250, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @dotest(i32 250, i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @dotest(i32 300, i32 600, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ emit_generic_instruction(int /*<<< orphan*/,
                                            int /*<<< orphan*/, int);
void add_r64_r64(uint8_t dest, uint8_t source) {
  emit_generic_instruction(dest, source, 0x3);
}


x86 assembly (clang, -O0):
<add_r64_r64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x3,%edx
call   1030 <emit_generic_instruction@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_r64_r64>:
mov    $0x3,%edx
jmp    1030 <emit_generic_instruction@plt>

LLVM IR (-O0):
define void @add_r64_r64(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 @emit_generic_instruction(i32 %5, i32 %6, i32 3)
ret void
}

LLVM IR (-O2):
define void @add_r64_r64(i32 %0, i32 %1) {
%3 = tail call i32 @emit_generic_instruction(i32 %0, i32 %1, i32 3)
ret void
}
int asm_function() { return 41; }


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

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

LLVM IR (-O0):
define i32 @asm_function() {
ret i32 41
}

LLVM IR (-O2):
define i32 @asm_function() {
ret i32 41
}
int fs_rename(char *oldname, char *newname) {
  (void)oldname;
  (void)newname;
  return -1;
}


x86 assembly (clang, -O0):
<fs_rename>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xffffffff,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @fs_rename(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
ret i32 -1
}

LLVM IR (-O2):
define i32 @fs_rename(i8* nocapture readnone %0, i8* nocapture readnone %1) {
ret i32 -1
}
/* Type definitions */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double Wtime(void) {
  struct timeval t;
  gettimeofday(&t, NULL);
  return ((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03);
}


x86 assembly (clang, -O0):
<Wtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdq -0x8(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xecf(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xebb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Wtime>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdq 0x10(%rsp),%xmm0
cvtsi2sdq 0x8(%rsp),%xmm1
mulsd  0xeca(%rip),%xmm1
mulsd  0xeca(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define double @Wtime() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%4 = load i64, i64* %3
%5 = sitofp i64 %4 to double
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = fmul double %8, 1.000000e-03
%10 = call double @llvm.fmuladd.f64(double %5, double 1.000000e+03, double %9)
ret double %10
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define double @Wtime() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%5 = load i64, i64* %4
%6 = sitofp i64 %5 to double
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%8 = load i64, i64* %7
%9 = sitofp i64 %8 to double
%10 = fmul double %9, 1.000000e-03
%11 = tail call double @llvm.fmuladd.f64(double %6, double 1.000000e+03, double %10)
ret double %11
}