xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
char *tree_zmalloc(size_t, void *);
char *tree_zstrndup(const char *str, size_t n, void *parent) {
  char *copy = NULL;
  if ((copy = tree_zmalloc(n + 1, parent)) == NULL) {
    return NULL;
  }
  memcpy(copy, str, n);
  copy[n] = '\0';
  return copy;
}


x86 assembly (clang, -O0):
<tree_zstrndup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
call   1030 <tree_zmalloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1168 <tree_zstrndup+0x48>
movq   $0x0,-0x8(%rbp)
jmp    118d <tree_zstrndup+0x6d>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tree_zstrndup>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x1(%rsi),%rdi
mov    %rdx,%rsi
call   1030 <tree_zmalloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1152 <tree_zstrndup+0x32>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <memcpy@plt>
movb   $0x0,(%rbx,%r15,1)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @tree_zstrndup(i8* %0, i64 %1, i8* %2) {
%4 = add i64 %1, 1
%5 = tail call i8* @tree_zmalloc(i64 %4, i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @memcpy(i8* %5, i8* %0, i64 %1)
%9 = getelementptr inbounds i8, i8* %5, i64 %1
store i8 0, i8* %9
br label %10
10: ; preds = %3, %7
ret i8* %5
}
/* Variables and functions */
int /*<<< orphan*/ dwb_getline(char *, int);
int /*<<< orphan*/ system(char *);
void casesy(void) {
  char sybuf[1024];
  dwb_getline(sybuf, 1024);
  system(sybuf);
}


x86 assembly (clang, -O0):
<casesy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1040 <dwb_getline@plt>
lea    -0x400(%rbp),%rdi
call   1030 <system@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<casesy>:
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <dwb_getline@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @casesy() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @dwb_getline(i8* %2, i32 1024)
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = call i32 @system(i8* %4)
ret void
}

LLVM IR (-O2):
define void @casesy() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @dwb_getline(i8* %2, i32 1024)
%4 = call i32 @system(i8* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
void test2() {
  puts("test2.a");
  puts("test2.b");
}


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

x86 assembly (clang, -O2):
<test2>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"test2.a\00"
@.str.1 = [8 x i8] c"test2.b\00"
define void @test2() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
float pow(float, int);
float quartic_out(float step, float max_steps, float max_val) {
  float ratio = (step / max_steps) - 1.0;
  return max_val + max_val * pow(ratio, 5);
}


x86 assembly (clang, -O0):
<quartic_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec3(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mov    $0x5,%edi
call   1030 <pow@plt>
movss  -0x18(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x14(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quartic_out>:
push   %rax
movss  %xmm2,0x4(%rsp)
divss  %xmm1,%xmm0
addss  0xedd(%rip),%xmm0
mov    $0x5,%edi
call   1030 <pow@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @quartic_out(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %4
%9 = load float, float* %5
%10 = fdiv float %8, %9
%11 = fpext float %10 to double
%12 = fsub double %11, 1.000000e+00
%13 = fptrunc double %12 to float
store float %13, float* %7
%14 = load float, float* %6
%15 = load float, float* %6
%16 = load float, float* %7
%17 = call float @pow(float %16, i32 5)
%18 = call float @llvm.fmuladd.f32(float %15, float %17, float %14)
ret float %18
}

LLVM IR (-O2):
define float @quartic_out(float %0, float %1, float %2) {
%4 = fdiv float %0, %1
%5 = fadd float %4, -1.000000e+00
%6 = tail call float @pow(float %5, i32 5)
%7 = tail call float @llvm.fmuladd.f32(float %2, float %6, float %2)
ret float %7
}
void p0(char *b) { __builtin_memset(b, 0, 400); }


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

x86 assembly (clang, -O2):
<p0>:
mov    $0x190,%edx
xor    %esi,%esi
jmp    1030 <memset@plt>

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

LLVM IR (-O2):
define void @p0(i8* nocapture writeonly %0) {
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(400) %0, i8 0, i64 400, i1 false)
ret void
}
int foo(int b) {
  int a = 10;
  a += b;
  return a;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
lea    0xa(%rdi),%eax
ret

LLVM IR (-O0):
define i32 @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 10, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* %3
%6 = add nsw i32 %5, %4
store i32 %6, i32* %3
%7 = load i32, i32* %3
ret i32 %7
}

LLVM IR (-O2):
define i32 @foo(i32 %0) {
%2 = add nsw i32 %0, 10
ret i32 %2
}
/* Variables and functions */
int bb_strtoull(char const *, char **, int);
unsigned bb_strtou(const char *arg, char **endp, int base) {
  return bb_strtoull(arg, endp, base);
}


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

x86 assembly (clang, -O2):
<bb_strtou>:
jmp    1030 <bb_strtoull@plt>

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

LLVM IR (-O2):
define i32 @bb_strtou(i8* %0, i8** %1, i32 %2) {
%4 = tail call i32 @bb_strtoull(i8* %0, i8** %1, i32 %2)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
void scamper_udp4_close(int fd) {
  close(fd);
  return;
}


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

x86 assembly (clang, -O2):
<scamper_udp4_close>:
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define void @scamper_udp4_close(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret void
}
int foo(int i) {
  if (i) {
    if (i)
      return 1;
    else
      return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1133 <foo+0x33>
cmpl   $0x0,-0x8(%rbp)
je     1127 <foo+0x27>
movl   $0x1,-0x4(%rbp)
jmp    113a <foo+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    113a <foo+0x3a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
xor    %eax,%eax
test   %edi,%edi
setne  %al
ret

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

LLVM IR (-O2):
define i32 @foo(i32 %0) {
%2 = icmp ne i32 %0, 0
%3 = zext i1 %2 to i32
ret i32 %3
}
int dummy_func(int a) { return ~a; }


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

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

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

LLVM IR (-O2):
define i32 @dummy_func(i32 %0) {
%2 = xor i32 %0, -1
ret i32 %2
}
int test_imm_BEuint8_mem(unsigned char *val) {
  return ((*val) & (-0xBE << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_BEuint8_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
and    $0xffffff42,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @test_imm_BEuint8_mem(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = and i32 %5, -190
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i32 -20, i32 -40
ret i32 %9
}

LLVM IR (-O2):
define i32 @test_imm_BEuint8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = and i8 %2, 66
%4 = icmp eq i8 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
double clock();
double cpu() { return clock() / (double)CLOCKS_PER_SEC; }


x86 assembly (clang, -O0):
<cpu>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <clock@plt>
mov    0x2ec6(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu>:
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    0x2ec9(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i64 0
define double @cpu() {
%1 = call double (...) @clock()
%2 = load i64, i64* @CLOCKS_PER_SEC
%3 = sitofp i64 %2 to double
%4 = fdiv double %1, %3
ret double %4
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i64 0
define double @cpu() {
%1 = tail call double (...) @clock()
%2 = load i64, i64* @CLOCKS_PER_SEC
%3 = sitofp i64 %2 to double
%4 = fdiv double %1, %3
ret double %4
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void usage() {
  fprintf(stderr, "rill_count -<a|b> <file>\n");
  exit(1);
}


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

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"rill_count -<a|b> <file>\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"rill_count -<a|b> <file>\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @exit(i32 1)
unreachable
}
void lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,
                 const char *action, int ret, int completion) {
  do {
  } while (0);
}


x86 assembly (clang, -O0):
<lws_latency>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
jmp    111c <lws_latency+0x1c>
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.libwebsocket_context = type opaque
%struct.libwebsocket = type opaque
define void @lws_latency(%struct.libwebsocket_context* %0, %struct.libwebsocket* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca %struct.libwebsocket_context*
%7 = alloca %struct.libwebsocket*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store %struct.libwebsocket_context* %0, %struct.libwebsocket_context** %6
store %struct.libwebsocket* %1, %struct.libwebsocket** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
br label %11
11: ; preds = %5
br label %12
12: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.libwebsocket_context = type opaque
%struct.libwebsocket = type opaque
define void @lws_latency(%struct.libwebsocket_context* nocapture %0, %struct.libwebsocket* nocapture %1, i8* nocapture %2, i32 %3, i32 %4) {
ret void
}
int SND_setup(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @SND_setup() {
ret i32 0
}
void swap(char *a, char *b) {
  char temp;
  temp = *a;
  *a = *b;
  *b = temp;
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @swap(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
store i8 %4, i8* %0
store i8 %3, i8* %1
ret void
}
int main() {
  int x;
  if ((sizeof(int) - 4))
    return 1;
  if ((sizeof(&x) - 8))
    return 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):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char a;
  char *str = &a;
  strcpy(str, "hello\n");
  printf("%s", str);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rsi
lea    0xf(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"hello\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i8
%2 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
ret i32 0
}
void train_dcgan(char *cfg, char *weight, char *acfg, char *aweight, int clear,
                 int display, char *train_images) {}


x86 assembly (clang, -O0):
<train_dcgan>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @train_dcgan(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
ret void
}

LLVM IR (-O2):
define void @train_dcgan(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3, i32 %4, i32 %5, i8* nocapture %6) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
int getdtablesize();
void closeall(void) {
  int i;
  for (i = getdtablesize() - 1; i > 2; i--)
    close(i);
}


x86 assembly (clang, -O0):
<closeall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <getdtablesize@plt>
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    1155 <closeall+0x35>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1135 <closeall+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeall>:
push   %rbx
xor    %eax,%eax
call   1040 <getdtablesize@plt>
cmp    $0x4,%eax
jl     1150 <closeall+0x30>
mov    %eax,%ebx
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x2(%rbx),%edi
call   1030 <close@plt>
add    $0xffffffff,%ebx
cmp    $0x4,%ebx
ja     1140 <closeall+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @closeall() {
%1 = alloca i32
%2 = call i32 (...) @getdtablesize()
%3 = sub nsw i32 %2, 1
store i32 %3, i32* %1
br label %4
4: ; preds = %10, %0
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = load i32, i32* %1
%9 = call i32 @close(i32 %8)
br label %10
10: ; preds = %7
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
br label %4
13: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @closeall() {
%1 = tail call i32 (...) @getdtablesize()
%2 = icmp sgt i32 %1, 3
br i1 %2, label %3, label %8
3: ; preds = %0, %3
%4 = phi i32 [ %5, %3 ], [ %1, %0 ]
%5 = add nsw i32 %4, -1
%6 = tail call i32 @close(i32 %5)
%7 = icmp ugt i32 %4, 4
br i1 %7, label %3, label %8
8: ; preds = %3, %0
ret void
}
void smbprofile_dump_setup(struct tevent_context *ev) { return; }


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

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

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

LLVM IR (-O2):
%struct.tevent_context = type opaque
define void @smbprofile_dump_setup(%struct.tevent_context* nocapture %0) {
ret void
}
fu(unsigned short data) { return data; }


x86 assembly (clang, -O0):
<fu>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @fu(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
ret i32 %4
}

LLVM IR (-O2):
define i32 @fu(i16 zeroext %0) {
%2 = zext i16 %0 to i32
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
int close_dhcp_socket(int sock) {
  close(sock);
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @close_dhcp_socket(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret i32 0
}
int counter(const char *code_point, const char plus) {
  int count = 0;
  int i = 0;
  while (plus == code_point[i++])
    count++;
  return count;
}


x86 assembly (clang, -O0):
<counter>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movsbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    114c <counter+0x4c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    111c <counter+0x1c>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<counter>:
xor    %eax,%eax
cmp    %sil,(%rdi)
jne    111e <counter+0x1e>
xor    %eax,%eax
nopl   0x0(%rax)
mov    %rax,%rcx
add    $0x1,%rax
cmp    %sil,0x1(%rdi,%rcx,1)
je     1110 <counter+0x10>
ret

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

LLVM IR (-O2):
define i32 @counter(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, %1
br i1 %4, label %5, label %13
5: ; preds = %2, %5
%6 = phi i64 [ %7, %5 ], [ 0, %2 ]
%7 = add nuw nsw i64 %6, 1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, %1
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = trunc i64 %7 to i32
br label %13
13: ; preds = %11, %2
%14 = phi i32 [ 0, %2 ], [ %12, %11 ]
ret i32 %14
}
/* Type definitions */
struct totem_ip_address {
  int dummy;
};

/* Variables and functions */
int totemmrp_ifaces_get(unsigned int, struct totem_ip_address *, char ***,
                        unsigned int *);
int totempg_ifaces_get(unsigned int nodeid, struct totem_ip_address *interfaces,
                       char ***status, unsigned int *iface_count) {
  int res;
  res = totemmrp_ifaces_get(nodeid, interfaces, status, iface_count);
  return (res);
}


x86 assembly (clang, -O0):
<totempg_ifaces_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <totemmrp_ifaces_get@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<totempg_ifaces_get>:
jmp    1030 <totemmrp_ifaces_get@plt>

LLVM IR (-O0):
%struct.totem_ip_address = type { i32 }
define i32 @totempg_ifaces_get(i32 %0, %struct.totem_ip_address* %1, i8*** %2, i32* %3) {
%5 = alloca i32
%6 = alloca %struct.totem_ip_address*
%7 = alloca i8***
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store %struct.totem_ip_address* %1, %struct.totem_ip_address** %6
store i8*** %2, i8**** %7
store i32* %3, i32** %8
%10 = load i32, i32* %5
%11 = load %struct.totem_ip_address*, %struct.totem_ip_address** %6
%12 = load i8***, i8**** %7
%13 = load i32*, i32** %8
%14 = call i32 @totemmrp_ifaces_get(i32 %10, %struct.totem_ip_address* %11, i8*** %12, i32* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
ret i32 %15
}

LLVM IR (-O2):
%struct.totem_ip_address = type { i32 }
define i32 @totempg_ifaces_get(i32 %0, %struct.totem_ip_address* %1, i8*** %2, i32* %3) {
%5 = tail call i32 @totemmrp_ifaces_get(i32 %0, %struct.totem_ip_address* %1, i8*** %2, i32* %3)
ret i32 %5
}
/* Forward declarations */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  unsigned long serial;
};
struct TYPE_4__ {
  TYPE_1__ xselectionclear;
};
typedef TYPE_2__ XEvent;

/* Variables and functions */
void set_XEvent_xselectionclear_serial(void *_p, unsigned long _v) {
  ((XEvent *)_p)->xselectionclear.serial = (unsigned long)_v;
}


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

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

LLVM IR (-O0):
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i64 }
define void @set_XEvent_xselectionclear_serial(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i64, i64* %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 i64 %5, i64* %9
ret void
}

LLVM IR (-O2):
define void @set_XEvent_xselectionclear_serial(i8* nocapture writeonly %0, i64 %1) {
%3 = bitcast i8* %0 to i64*
store i64 %1, i64* %3
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_cmpeq_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
__m128i test_mm_cmpeq_epi8(__m128i A, __m128i B) {
  return _mm_cmpeq_epi8(A, B);
}


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

x86 assembly (clang, -O2):
<test_mm_cmpeq_epi8>:
jmp    1030 <_mm_cmpeq_epi8@plt>

LLVM IR (-O0):
define i32 @test_mm_cmpeq_epi8(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 @_mm_cmpeq_epi8(i32 %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @test_mm_cmpeq_epi8(i32 %0, i32 %1) {
%3 = tail call i32 @_mm_cmpeq_epi8(i32 %0, i32 %1)
ret i32 %3
}
int of_open(const char *node_name) {
  struct {
    const char *name;
    int num_args;
    int num_returns;
    const char *node_name;
    int handle;
  } args;
  args.name = "open";
  args.num_args = 1;
  args.num_returns = 1;
  args.node_name = node_name;
  of(&args);
  return args.handle;
}


x86 assembly (clang, -O0):
<of_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1030 <of@plt>
mov    -0x10(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<of_open>:
sub    $0x28,%rsp
lea    0xee5(%rip),%rax
mov    %rax,0x8(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x10(%rsp)
mov    %rdi,0x18(%rsp)
lea    0x8(%rsp),%rdi
xor    %eax,%eax
call   1030 <of@plt>
mov    0x20(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32, i32, i8*, i32 }
@.str = [5 x i8] c"open\00"
define i32 @of_open(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.anon
store i8* %0, i8** %2
%4 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 1
store i32 1, i32* %5
%6 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 2
store i32 1, i32* %6
%7 = load i8*, i8** %2
%8 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 3
store i8* %7, i8** %8
%9 = call i32 (%struct.anon*, ...) bitcast (i32 (...)* @of to i32 (%struct.anon*, ...)*)(%struct.anon* %3)
%10 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 4
%11 = load i32, i32* %10
ret i32 %11
}

LLVM IR (-O2):
%struct.anon = type { i8*, i32, i32, i8*, i32 }
@.str = [5 x i8] c"open\00"
define i32 @of_open(i8* %0) {
%2 = alloca %struct.anon
%3 = bitcast %struct.anon* %2 to i8*
%4 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 1
store i32 1, i32* %5
%6 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 2
store i32 1, i32* %6
%7 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 3
store i8* %0, i8** %7
%8 = call i32 (%struct.anon*, ...) bitcast (i32 (...)* @of to i32 (%struct.anon*, ...)*)(%struct.anon* %2)
%9 = getelementptr inbounds %struct.anon, %struct.anon* %2, i64 0, i32 4
%10 = load i32, i32* %9
ret i32 %10
}
int main() {
  int i = 1;
  char c = 'A';
  printf("%x %x\n", &i, &c);
  i = i + c;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movb   $0x41,-0x9(%rbp)
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x9(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
movsbl -0x9(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x1,0x4(%rsp)
movb   $0x41,0x3(%rsp)
lea    0xedb(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x3(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%x %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 1, i32* %2
store i8 65, i8* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i8* %3)
%5 = load i32, i32* %2
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = add nsw i32 %5, %7
store i32 %8, i32* %2
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%x %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
store i8 65, i8* %2
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i8* %2)
ret i32 0
}
/* Variables and functions */
int f19(int *);
int f20(int *p) { return f19(p); }


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

x86 assembly (clang, -O2):
<f20>:
jmp    1030 <f19@plt>

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

LLVM IR (-O2):
define i32 @f20(i32* %0) {
%2 = tail call i32 @f19(i32* %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void printHelp() {
  printf("\n\n                        C.A.D. 		Curso 2011-2012");
  printf("\n Escape: Salir");
  printf("\n\n\n");
}


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

x86 assembly (clang, -O2):
<printHelp>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
call   1040 <printf@plt>
lea    0xf03(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"\0A\0A C.A.D. \09\09Curso 2011-2012\00"
@.str.1 = [16 x i8] c"\0A Escape: Salir\00"
@.str.2 = [4 x i8] c"\0A\0A\0A\00"
define void @printHelp() {
%1 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"\0A\0A C.A.D. \09\09Curso 2011-2012\00"
@.str.1 = [16 x i8] c"\0A Escape: Salir\00"
@str = [3 x i8] c"\0A\0A\00"
define void @printHelp() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
void *malloc(size_t);
int main(int argc, char **argv) {
  size_t size = 15;
  void *p = malloc(size + 1);
  ((char *)p)[16] = 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xf,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,0x10(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i64 15, i64* %5
%7 = load i64, i64* %5
%8 = add i64 %7, 1
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 16
store i8 0, i8* %11
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
ret i32 0
}
int check_prime(int num) {
  int i, p = 0, j = 0;
  for (i = 2; i < num; i++) {
    if (num % i == 0) {
      break;
    } else {
      p = p + 1;
    }
  }
  if (p == num - 2) {
    j = 1;
  }
  return j;
}


x86 assembly (clang, -O0):
<check_prime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1159 <check_prime+0x59>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    113d <check_prime+0x3d>
jmp    1159 <check_prime+0x59>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <check_prime+0x4b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    111c <check_prime+0x1c>
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jne    1171 <check_prime+0x71>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_prime>:
lea    -0x2(%rdi),%ecx
xor    %esi,%esi
cmp    $0x3,%edi
jl     1127 <check_prime+0x27>
mov    $0x2,%esi
nop
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1124 <check_prime+0x24>
add    $0x1,%esi
cmp    %esi,%edi
jne    1110 <check_prime+0x10>
mov    %ecx,%esi
jmp    1127 <check_prime+0x27>
add    $0xfffffffe,%esi
xor    %eax,%eax
cmp    %ecx,%esi
sete   %al
ret

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

LLVM IR (-O2):
define i32 @check_prime(i32 %0) {
%2 = icmp sgt i32 %0, 2
%3 = add nsw i32 %0, -2
br i1 %2, label %4, label %13
4: ; preds = %1, %9
%5 = phi i32 [ %10, %9 ], [ 0, %1 ]
%6 = phi i32 [ %11, %9 ], [ 2, %1 ]
%7 = srem i32 %0, %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = add nuw nsw i32 %5, 1
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %10, %3
br i1 %12, label %13, label %4
13: ; preds = %9, %4, %1
%14 = phi i32 [ 0, %1 ], [ %5, %4 ], [ %3, %9 ]
%15 = icmp eq i32 %14, %3
%16 = zext i1 %15 to i32
ret i32 %16
}
void copy(char str1[], char str2[]) {
  while ((*str1++ = *str2++) != '\0')
    ;
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    -0x8(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
je     113f <copy+0x3f>
jmp    110c <copy+0xc>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rsi,%rax,1),%ecx
mov    %cl,(%rdi,%rax,1)
add    $0x1,%rax
test   %cl,%cl
jne    1110 <copy+0x10>
ret

LLVM IR (-O0):
define void @copy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %13, %2
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %4
%8 = load i8, i8* %6
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
store i8 %8, i8* %9
%11 = sext i8 %8 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %5
br label %5
14: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @copy(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i8* [ %0, %2 ], [ %8, %3 ]
%5 = phi i8* [ %1, %2 ], [ %6, %3 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
%8 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %7, i8* %4
%9 = icmp eq i8 %7, 0
br i1 %9, label %10, label %3
10: ; preds = %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int a = 0, b = -1;
  int i1 = a++ + ++b;
  printf("i1 = %d\n", i1);
  return 0x1e - 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1d,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [9 x i8] c"i1 = %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0)
ret i32 29
}
/* Variables and functions */
int foo(int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  printf("%u\n", foo(3, 7));
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
mov    $0x7,%esi
call   1040 <foo@plt>
lea    0xec9(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = tail call i32 @foo(i32 3, i32 7)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1)
ret i32 0
}
/* Type definitions */
struct timespec {
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int64_t _GetCurrentTime() {
  struct timespec ts;
  clock_gettime(CLOCK_MONOTONIC, &ts);
  return (int64_t)ts.tv_sec;
}


x86 assembly (clang, -O0):
<_GetCurrentTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_GetCurrentTime>:
push   %rax
mov    0x2ed0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @_GetCurrentTime() {
%1 = alloca %struct.timespec
%2 = load i32, i32* @CLOCK_MONOTONIC
%3 = call i32 @clock_gettime(i32 %2, %struct.timespec* %1)
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%5 = load i32, i32* %4
ret i32 %5
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @_GetCurrentTime() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%6 = load i32, i32* %5
ret i32 %6
}
void pcm_pause(struct codec *c, int p) {}


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

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

LLVM IR (-O0):
%struct.codec = type opaque
define void @pcm_pause(%struct.codec* %0, i32 %1) {
%3 = alloca %struct.codec*
%4 = alloca i32
store %struct.codec* %0, %struct.codec** %3
store i32 %1, i32* %4
ret void
}

LLVM IR (-O2):
%struct.codec = type opaque
define void @pcm_pause(%struct.codec* nocapture %0, i32 %1) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *, int *);
int main() {
  int a, b, x;
  x = scanf("%d %d", &a, &b);
  printf("%d", a + b);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
store i32 %5, i32* %4
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = add nsw i32 %6, %7
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add nsw i32 %7, %6
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
ret i32 0
}