xunge/DecIR huggingface dataset:
/* Variables and functions */
char *strcpy(char *dest, const char *src) {
  size_t index;
  for (index = 0; src[index]; index++)
    dest[index] = src[index];
  dest[index] = '\0';
  return dest;
}


x86 assembly (clang, -O0):
<strcpy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     114d <strcpy+0x4d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1114 <strcpy+0x14>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy>:
mov    %rdi,%rax
mov    (%rsi),%dl
xor    %ecx,%ecx
test   %dl,%dl
je     1120 <strcpy+0x20>
nopl   0x0(%rax,%rax,1)
mov    %dl,(%rax,%rcx,1)
movzbl 0x1(%rsi,%rcx,1),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    1110 <strcpy+0x10>
movb   $0x0,(%rax,%rcx,1)
ret

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

LLVM IR (-O2):
define i8* @strcpy(i8* returned writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %11, %5 ], [ %3, %2 ]
%7 = phi i64 [ %9, %5 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 %6, i8* %8
%9 = add i64 %7, 1
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %2
%14 = phi i64 [ 0, %2 ], [ %9, %5 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
ret i8* %0
}
int isDecimal(int c) {
  switch (c) {
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
  case 'x':
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isDecimal>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
add    $0xffffffd0,%eax
sub    $0xa,%eax
jb     112f <isDecimal+0x2f>
jmp    111e <isDecimal+0x1e>
mov    -0xc(%rbp),%eax
sub    $0x78,%eax
jne    113b <isDecimal+0x3b>
jmp    112f <isDecimal+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    1142 <isDecimal+0x42>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isDecimal>:
mov    $0x1,%eax
lea    -0x30(%rdi),%ecx
cmp    $0xa,%ecx
jae    110e <isDecimal+0xe>
ret
cmp    $0x78,%edi
je     110d <isDecimal+0xd>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @isDecimal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %6 [
i32 48, label %5
i32 49, label %5
i32 50, label %5
i32 51, label %5
i32 52, label %5
i32 53, label %5
i32 54, label %5
i32 55, label %5
i32 56, label %5
i32 57, label %5
i32 120, label %5
]
5: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
store i32 1, i32* %2
br label %7
6: ; preds = %1
store i32 0, i32* %2
br label %7
7: ; preds = %6, %5
%8 = load i32, i32* %2
ret i32 %8
}

LLVM IR (-O2):
define i32 @isDecimal(i32 %0) {
switch i32 %0, label %2 [
i32 48, label %3
i32 49, label %3
i32 50, label %3
i32 51, label %3
i32 52, label %3
i32 53, label %3
i32 54, label %3
i32 55, label %3
i32 56, label %3
i32 57, label %3
i32 120, label %3
]
2: ; preds = %1
br label %3
3: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %2
%4 = phi i32 [ 0, %2 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ]
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  printf("Hola Munro\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%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 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str = [11 x i8] c"Hola Munro\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void help(void) {
  printf("tcc version "
         "0.9.26-cl-preprocessor"
         " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n"
         "Usage: tcc [options...] infile(s)...\n"
         "General options:\n"
         "  -v          show version\n"
         "Preprocessor options:\n"
         "  -E          preprocess only\n"
         "  -Idir       add include path 'dir'\n"
         "  -Dsym[=val] define 'sym' with value 'val'\n"
         "  -Usym       undefine 'sym'\n");
}


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

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

LLVM IR (-O0):
@.str = [339 x i8] c"tcc version 0.9.26-cl-preprocessor - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\0AUsage: tcc [options...] infile(s)...\0AGeneral options:\0A -v show version\0APreprocessor options:\0A -E preprocess only\0A -Idir add include path 'dir'\0A -Dsym[=val] define 'sym' with value 'val'\0A -Usym undefine 'sym'\0A\00"
define void @help() {
%1 = call i32 @printf(i8* getelementptr inbounds ([339 x i8], [339 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [338 x i8] c"tcc version 0.9.26-cl-preprocessor - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\0AUsage: tcc [options...] infile(s)...\0AGeneral options:\0A -v show version\0APreprocessor options:\0A -E preprocess only\0A -Idir add include path 'dir'\0A -Dsym[=val] define 'sym' with value 'val'\0A -Usym undefine 'sym'\00"
define void @help() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([338 x i8], [338 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ drawtextbox_color(unsigned char, unsigned char,
                                     unsigned char, unsigned char, int);
void drawtextbox(unsigned char x, unsigned char y, unsigned char w,
                 unsigned char h) {
  drawtextbox_color(x, y, w, h, (((0) << 7) | ((1) << 6) | ((7) << 3) | (0)));
}


x86 assembly (clang, -O0):
<drawtextbox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %cl,-0x3(%rbp)
mov    %al,-0x4(%rbp)
mov    -0x1(%rbp),%dl
mov    -0x2(%rbp),%cl
mov    -0x3(%rbp),%al
mov    $0x78,%r8d
movzbl %dl,%edi
movzbl %cl,%esi
movzbl %al,%edx
movzbl -0x4(%rbp),%ecx
call   1030 <drawtextbox_color@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawtextbox>:
mov    $0x78,%r8d
jmp    1030 <drawtextbox_color@plt>

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

LLVM IR (-O2):
define void @drawtextbox(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3) {
%5 = tail call i32 @drawtextbox_color(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i32 120)
ret void
}
/* Variables and functions */
int modify_capability_raw(int /*<<< orphan*/);
int disable_capability_raw(void) { return modify_capability_raw(0); }


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

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

LLVM IR (-O0):
define i32 @disable_capability_raw() {
%1 = call i32 @modify_capability_raw(i32 0)
ret i32 %1
}

LLVM IR (-O2):
define i32 @disable_capability_raw() {
%1 = tail call i32 @modify_capability_raw(i32 0)
ret i32 %1
}
int test_cell(const char *p) { const unsigned char *marker; }


x86 assembly (clang, -O0):
<test_cell>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @test_cell(i8* nocapture readnone %0) {
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ fabs(double);
double floor(int /*<<< orphan*/);
double lr_floor0(double value, double rf) {
  double result;
  result = floor(fabs(value * rf)) / rf;
  if (value < 0.0)
    return -result;
  return result;
}


x86 assembly (clang, -O0):
<lr_floor0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <floor@plt>
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1186 <lr_floor0+0x66>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1190 <lr_floor0+0x70>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lr_floor0>:
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,0x10(%rsp)
mulsd  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <floor@plt>
divsd  0x8(%rsp),%xmm0
movapd 0xeb2(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @lr_floor0(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = load double, double* %5
%9 = fmul double %7, %8
%10 = call i32 @fabs(double %9)
%11 = call double @floor(i32 %10)
%12 = load double, double* %5
%13 = fdiv double %11, %12
store double %13, double* %6
%14 = load double, double* %4
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load double, double* %6
%18 = fneg double %17
store double %18, double* %3
br label %21
19: ; preds = %2
%20 = load double, double* %6
store double %20, double* %3
br label %21
21: ; preds = %19, %16
%22 = load double, double* %3
ret double %22
}

LLVM IR (-O2):
define double @lr_floor0(double %0, double %1) {
%3 = fmul double %0, %1
%4 = tail call i32 @fabs(double %3)
%5 = tail call double @floor(i32 %4)
%6 = fdiv double %5, %1
%7 = fcmp olt double %0, 0.000000e+00
%8 = fneg double %6
%9 = select i1 %7, double %8, double %6
ret double %9
}
OPHANDLER(clr_a) { SET_ACC(0); }


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

x86 assembly (clang, -O2):
<OPHANDLER>:
xor    %edi,%edi
xor    %eax,%eax
jmp    1030 <SET_ACC@plt>

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

LLVM IR (-O2):
define i32 @OPHANDLER(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @SET_ACC to i32 (i32, ...)*)(i32 0)
ret i32 undef
}
cbuf38(f, n) { return (cbuf(f, n, 38)); }


x86 assembly (clang, -O0):
<cbuf38>:
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    $0x26,%edx
mov    $0x0,%al
call   1030 <cbuf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbuf38>:
mov    $0x26,%edx
xor    %eax,%eax
jmp    1030 <cbuf@plt>

LLVM IR (-O0):
define i32 @cbuf38(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 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %5, i32 %6, i32 38)
ret i32 %7
}

LLVM IR (-O2):
define i32 @cbuf38(i32 %0, i32 %1) {
%3 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %0, i32 %1, i32 38)
ret i32 %3
}
void po(float e1[4], long j, long k, long l) {
  e1[j] = e1[k];
  e1[k] = e1[l];
  e1[l] = e1[j];
  return;
}


x86 assembly (clang, -O0):
<po>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<po>:
movss  (%rdi,%rdx,4),%xmm0
movss  %xmm0,(%rdi,%rsi,4)
movss  (%rdi,%rcx,4),%xmm0
movss  %xmm0,(%rdi,%rdx,4)
movss  (%rdi,%rsi,4),%xmm0
movss  %xmm0,(%rdi,%rcx,4)
ret

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

LLVM IR (-O2):
define void @po(float* nocapture %0, i64 %1, i64 %2, i64 %3) {
%5 = getelementptr inbounds float, float* %0, i64 %2
%6 = load float, float* %5
%7 = getelementptr inbounds float, float* %0, i64 %1
store float %6, float* %7
%8 = getelementptr inbounds float, float* %0, i64 %3
%9 = load float, float* %8
store float %9, float* %5
%10 = load float, float* %7
store float %10, float* %8
ret void
}
void test5(int b) {
  int *p = __builtin_malloc(sizeof(int) * 4);
  if (p)
    __builtin_free(p);
}


x86 assembly (clang, -O0):
<test5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114d <test5+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @test5(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i8* @malloc(i64 16)
%5 = bitcast i8* %4 to i32*
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = bitcast i32* %9 to i8*
br label %11
11: ; preds = %8, %1
ret void
}

LLVM IR (-O2):
define void @test5(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
do_stuff() { printf("c-plugin doing stuff.\n"); }


x86 assembly (clang, -O0):
<do_stuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [23 x i8] c"c-plugin doing stuff.\0A\00"
define i32 @do_stuff() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %1
ret i32 %3
}

LLVM IR (-O2):
@str = [22 x i8] c"c-plugin doing stuff.\00"
define i32 @do_stuff() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ DEBUG_PutString(char *);
int /*<<< orphan*/ Usart4Init();
int /*<<< orphan*/ setupUSB();
void ComInit(void) {
  Usart4Init();
  DEBUG_PutString("setup USB...\r\n");
  setupUSB();
  DEBUG_PutString("setup USB done\r\n");
}


x86 assembly (clang, -O0):
<ComInit>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <Usart4Init@plt>
lea    0xebe(%rip),%rdi
call   1050 <DEBUG_PutString@plt>
mov    $0x0,%al
call   1040 <setupUSB@plt>
lea    0xeba(%rip),%rdi
call   1050 <DEBUG_PutString@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComInit>:
push   %rax
xor    %eax,%eax
call   1030 <Usart4Init@plt>
lea    0xec1(%rip),%rdi
call   1050 <DEBUG_PutString@plt>
xor    %eax,%eax
call   1040 <setupUSB@plt>
lea    0xebd(%rip),%rdi
pop    %rax
jmp    1050 <DEBUG_PutString@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"setup USB...\0D\0A\00"
@.str.1 = [17 x i8] c"setup USB done\0D\0A\00"
define void @ComInit() {
%1 = call i32 (...) @Usart4Init()
%2 = call i32 @DEBUG_PutString(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @setupUSB()
%4 = call i32 @DEBUG_PutString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"setup USB...\0D\0A\00"
@.str.1 = [17 x i8] c"setup USB done\0D\0A\00"
define void @ComInit() {
%1 = tail call i32 (...) @Usart4Init()
%2 = tail call i32 @DEBUG_PutString(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @setupUSB()
%4 = tail call i32 @DEBUG_PutString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int foo2() {
  int b2 = 21;
  return b2;
}


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

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

LLVM IR (-O0):
define i32 @foo2() {
%1 = alloca i32
store i32 21, i32* %1
%2 = load i32, i32* %1
ret i32 %2
}

LLVM IR (-O2):
define i32 @foo2() {
ret i32 21
}
/* Type definitions */
struct rlimit {
  int /*<<< orphan*/ rlim_max;
  int /*<<< orphan*/ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_MEMLOCK;
int /*<<< orphan*/ RLIM_INFINITY;
int setrlimit(int /*<<< orphan*/, struct rlimit *);
int bump_memlock_rlimit(void) {
  struct rlimit rlim_new = {
      .rlim_cur = RLIM_INFINITY,
      .rlim_max = RLIM_INFINITY,
  };
  return setrlimit(RLIMIT_MEMLOCK, &rlim_new);
}


x86 assembly (clang, -O0):
<bump_memlock_rlimit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1030 <setrlimit@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIM_INFINITY = global i32 0
@RLIMIT_MEMLOCK = global i32 0
define i32 @bump_memlock_rlimit() {
%1 = alloca %struct.rlimit
%2 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
%3 = load i32, i32* @RLIM_INFINITY
store i32 %3, i32* %2
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
%5 = load i32, i32* @RLIM_INFINITY
store i32 %5, i32* %4
%6 = load i32, i32* @RLIMIT_MEMLOCK
%7 = call i32 @setrlimit(i32 %6, %struct.rlimit* %1)
ret i32 %7
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIM_INFINITY = global i32 0
@RLIMIT_MEMLOCK = global i32 0
define i32 @bump_memlock_rlimit() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%4 = load i32, i32* @RLIM_INFINITY
store i32 %4, i32* %3
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i32 %4, i32* %5
%6 = load i32, i32* @RLIMIT_MEMLOCK
%7 = call i32 @setrlimit(i32 %6, %struct.rlimit* %1)
ret i32 %7
}
int zenglrun_Hash(void *VM_ARG, char *key) {
  int temp = 0;
  int i = 0;
  while (key[i] != '\0') {
    temp = ((temp << 4) + key[i]) % 211;
    ++i;
  }
  return temp;
}


x86 assembly (clang, -O0):
<zenglrun_Hash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     115c <zenglrun_Hash+0x5c>
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    $0xd3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111a <zenglrun_Hash+0x1a>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<zenglrun_Hash>:
mov    (%rsi),%cl
test   %cl,%cl
je     1142 <zenglrun_Hash+0x42>
add    $0x1,%rsi
xor    %eax,%eax
nopl   0x0(%rax)
movsbl %cl,%ecx
shl    $0x4,%eax
add    %ecx,%eax
cltq
imul   $0x4da637d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
imul   $0xd3,%ecx,%ecx
sub    %ecx,%eax
movzbl (%rsi),%ecx
add    $0x1,%rsi
test   %cl,%cl
jne    1110 <zenglrun_Hash+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @zenglrun_Hash(i8* %0, i8* %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 = %15, %2
%8 = load i8*, i8** %4
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %7
%16 = load i32, i32* %5
%17 = shl i32 %16, 4
%18 = load i8*, i8** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = add nsw i32 %17, %23
%25 = srem i32 %24, 211
store i32 %25, i32* %5
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %7
28: ; preds = %7
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
define i32 @zenglrun_Hash(i8* nocapture readnone %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %13, %5 ], [ 0, %2 ]
%7 = phi i8 [ %15, %5 ], [ %3, %2 ]
%8 = phi i32 [ %12, %5 ], [ 0, %2 ]
%9 = sext i8 %7 to i32
%10 = shl nsw i32 %8, 4
%11 = add nsw i32 %10, %9
%12 = srem i32 %11, 211
%13 = add nuw nsw i64 %6, 1
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %2
%18 = phi i32 [ 0, %2 ], [ %12, %5 ]
ret i32 %18
}
/* Variables and functions */
int /*<<< orphan*/ fatal_error(int, char *);
void *malloc(size_t);
void *bfm_malloc(size_t bytes) {
  void *res = malloc(bytes);
  if (!res)
    fatal_error(-1, "out of memory.");
  return res;
}


x86 assembly (clang, -O0):
<bfm_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1155 <bfm_malloc+0x35>
mov    $0xffffffff,%edi
lea    0xeb0(%rip),%rsi
call   1030 <fatal_error@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfm_malloc>:
push   %rbx
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    113f <bfm_malloc+0x1f>
lea    0xecb(%rip),%rsi
mov    $0xffffffff,%edi
call   1030 <fatal_error@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"out of memory.\00"
define i8* @bfm_malloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i8* @malloc(i64 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @fatal_error(i32 -1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %3
ret i8* %11
}

LLVM IR (-O2):
@.str = [15 x i8] c"out of memory.\00"
define noalias i8* @bfm_malloc(i64 %0) {
%2 = tail call i8* @malloc(i64 %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fatal_error(i32 -1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
ret i8* %2
}
void rtvTDMB_StandbyMode(int on) {}


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

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

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

LLVM IR (-O2):
define void @rtvTDMB_StandbyMode(i32 %0) {
ret void
}
/* Variables and functions */
void *BG_Alloc(int);
void *B_Alloc(int size) { return BG_Alloc(size); }


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

x86 assembly (clang, -O2):
<B_Alloc>:
jmp    1030 <BG_Alloc@plt>

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

LLVM IR (-O2):
define i8* @B_Alloc(i32 %0) {
%2 = tail call i8* @BG_Alloc(i32 %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *, double *);
int main() {
  double a, b;
  scanf("%lf %lf", &a, &b);
  printf("%.3lf km/l\n", a / b);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [12 x i8] c"%.3lf km/l\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %2, double* %3)
%5 = load double, double* %2
%6 = load double, double* %3
%7 = fdiv double %5, %6
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %7)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [12 x i8] c"%.3lf km/l\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%6 = load double, double* %1
%7 = load double, double* %2
%8 = fdiv double %6, %7
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %8)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, unsigned int);
scalar_t__ pthread_self();
int /*<<< orphan*/ sleep(int);
void *foo_task(void *arg) {
  printf("%u: running foo_task\n", (unsigned int)pthread_self());
  sleep(1);
  return arg;
}


x86 assembly (clang, -O0):
<foo_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <pthread_self@plt>
mov    %eax,%esi
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo_task>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <pthread_self@plt>
lea    0xebe(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%u: running foo_task\0A\00"
define i8* @foo_task(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i64 (...) @pthread_self()
%4 = trunc i64 %3 to i32
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @sleep(i32 1)
%7 = load i8*, i8** %2
ret i8* %7
}

LLVM IR (-O2):
@.str = [22 x i8] c"%u: running foo_task\0A\00"
define i8* @foo_task(i8* readnone returned %0) {
%2 = tail call i64 (...) @pthread_self()
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @sleep(i32 1)
ret i8* %0
}
/* Variables and functions */
double mystery();
int libcall_double(int uno, double dos) {
  if (dos == 0.75) {
    return 17;
  } else {
    return (int)(mystery() * dos * uno);
  }
}


x86 assembly (clang, -O0):
<libcall_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1149 <libcall_double+0x39>
jp     1149 <libcall_double+0x39>
movl   $0x11,-0x4(%rbp)
jmp    1165 <libcall_double+0x55>
mov    $0x0,%al
call   1030 <mystery@plt>
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libcall_double>:
push   %rbx
sub    $0x10,%rsp
mov    $0x11,%eax
ucomisd 0xede(%rip),%xmm0
jne    1126 <libcall_double+0x16>
jnp    1147 <libcall_double+0x37>
mov    %edi,%ebx
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1030 <mystery@plt>
cvtsi2sd %ebx,%xmm1
mulsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @libcall_double(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%6 = load double, double* %5
%7 = fcmp oeq double %6, 7.500000e-01
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 17, i32* %3
br label %17
9: ; preds = %2
%10 = call double (...) @mystery()
%11 = load double, double* %5
%12 = fmul double %10, %11
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = fmul double %12, %14
%16 = fptosi double %15 to i32
store i32 %16, i32* %3
br label %17
17: ; preds = %9, %8
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @libcall_double(i32 %0, double %1) {
%3 = fcmp oeq double %1, 7.500000e-01
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = tail call double (...) @mystery()
%6 = fmul double %5, %1
%7 = sitofp i32 %0 to double
%8 = fmul double %6, %7
%9 = fptosi double %8 to i32
br label %10
10: ; preds = %2, %4
%11 = phi i32 [ %9, %4 ], [ 17, %2 ]
ret i32 %11
}
/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
typedef int int32_t;

/* Variables and functions */
int32_t diff_timeval(struct timeval *a, struct timeval *b) {
  return (b->tv_sec - a->tv_sec) * 1000000000 +
         (b->tv_usec - a->tv_usec) * 1000;
}


x86 assembly (clang, -O0):
<diff_timeval>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%eax
imul   $0x3b9aca00,%eax,%eax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
mov    -0x8(%rbp),%rdx
sub    0x4(%rdx),%ecx
imul   $0x3e8,%ecx,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff_timeval>:
mov    (%rsi),%eax
mov    0x4(%rsi),%ecx
sub    (%rdi),%eax
imul   $0x3b9aca00,%eax,%edx
sub    0x4(%rdi),%ecx
imul   $0x3e8,%ecx,%eax
add    %edx,%eax
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i32 @diff_timeval(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%5 = load %struct.timeval*, %struct.timeval** %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = load %struct.timeval*, %struct.timeval** %3
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = sub nsw i32 %7, %10
%12 = mul nsw i32 %11, 1000000000
%13 = load %struct.timeval*, %struct.timeval** %4
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = load %struct.timeval*, %struct.timeval** %3
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = sub nsw i32 %15, %18
%20 = mul nsw i32 %19, 1000
%21 = add nsw i32 %12, %20
ret i32 %21
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i32 @diff_timeval(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = sub nsw i32 %4, %6
%8 = mul nsw i32 %7, 1000000000
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%12 = load i32, i32* %11
%13 = sub nsw i32 %10, %12
%14 = mul nsw i32 %13, 1000
%15 = add nsw i32 %14, %8
ret i32 %15
}
/* Type definitions */
struct rlimit {
  long rlim_cur;
  long rlim_max;
};

/* Variables and functions */
int syscall(int, int, long *);
int setrlimit(int resource, const struct rlimit *rlim) {
  long k_rlim[2] = {rlim->rlim_cur, rlim->rlim_max};
  return syscall(75, resource, k_rlim);
}


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

x86 assembly (clang, -O2):
<setrlimit>:
sub    $0x18,%rsp
mov    %edi,%eax
movups (%rsi),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
mov    $0x4b,%edi
mov    %eax,%esi
call   1030 <syscall@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.rlimit = type { i64, i64 }
define i32 @setrlimit(i32 %0, %struct.rlimit* %1) {
%3 = alloca i32
%4 = alloca %struct.rlimit*
%5 = alloca [2 x i64]
store i32 %0, i32* %3
store %struct.rlimit* %1, %struct.rlimit** %4
%6 = getelementptr inbounds [2 x i64], [2 x i64]* %5, i64 0, i64 0
%7 = load %struct.rlimit*, %struct.rlimit** %4
%8 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 0
%9 = load i64, i64* %8
store i64 %9, i64* %6
%10 = getelementptr inbounds i64, i64* %6, i64 1
%11 = load %struct.rlimit*, %struct.rlimit** %4
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %11, i32 0, i32 1
%13 = load i64, i64* %12
store i64 %13, i64* %10
%14 = load i32, i32* %3
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %5, i64 0, i64 0
%16 = call i32 @syscall(i32 75, i32 %14, i64* %15)
ret i32 %16
}

LLVM IR (-O2):
%struct.rlimit = type { i64, i64 }
define i32 @setrlimit(i32 %0, %struct.rlimit* nocapture %1) {
%3 = alloca <2 x i64>
%4 = bitcast <2 x i64>* %3 to i8*
%5 = getelementptr inbounds <2 x i64>, <2 x i64>* %3, i64 0, i64 0
%6 = bitcast %struct.rlimit* %1 to <2 x i64>*
%7 = load <2 x i64>, <2 x i64>* %6
store <2 x i64> %7, <2 x i64>* %3
%8 = call i32 @syscall(i32 75, i32 %0, i64* %5)
ret i32 %8
}
/* Variables and functions */
unsigned int M4U_ReadReg32(unsigned int, unsigned int);
unsigned int m4uHw_get_field_by_mask(unsigned int M4UBase, unsigned int reg,
                                     unsigned int mask) {
  return M4U_ReadReg32(M4UBase, reg) & mask;
}


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

x86 assembly (clang, -O2):
<m4uHw_get_field_by_mask>:
push   %rbx
mov    %edx,%ebx
call   1030 <M4U_ReadReg32@plt>
and    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @m4uHw_get_field_by_mask(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @M4U_ReadReg32(i32 %0, i32 %1)
%5 = and i32 %4, %2
ret i32 %5
}
void myFunc(void) { printf("%s:\n", __func__); }


x86 assembly (clang, -O0):
<myFunc>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee3(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<myFunc>:
lea    0xee9(%rip),%rdi
lea    0xee7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s:\0A\00"
@__func__.myFunc = [7 x i8] c"myFunc\00"
define void @myFunc() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.myFunc, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@__func__.myFunc = [7 x i8] c"myFunc\00"
define void @myFunc() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.myFunc, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
size_t read(int, void *, size_t);
void read_X(int fd, void *buf, size_t count) {
  ssize_t readed = read(fd, buf, count);
  if (readed != count) {
    do {
      perror("read");
      exit(EXIT_FAILURE);
    } while (0);
  }
}


x86 assembly (clang, -O0):
<read_X>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <read@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1184 <read_X+0x54>
jmp    116a <read_X+0x3a>
lea    0xe8f(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_X>:
push   %rbx
mov    %rdx,%rbx
call   1030 <read@plt>
cmp    %rbx,%rax
jne    1140 <read_X+0x10>
pop    %rbx
ret
lea    0xeb9(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@EXIT_FAILURE = global i32 0
define void @read_X(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = call i64 @read(i32 %8, i8* %9, i64 %10)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = load i64, i64* %6
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %3
br label %16
16: ; preds = %15
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; No predecessors!
br label %21
21: ; preds = %20, %3
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@EXIT_FAILURE = global i32 0
define void @read_X(i32 %0, i8* nocapture %1, i64 %2) {
%4 = tail call i64 @read(i32 %0, i8* %1, i64 %2)
%5 = icmp eq i64 %4, %2
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
char *strdup(char const *);
void modify_string(const char **string_out, const char *string_in) {
  char *tmp;
  printf("modify_string got %s\n", string_in);
  tmp = strdup(string_in);
  tmp[0] = 'A';
  *string_out = tmp;
  printf("modify_string returns %s\n", *string_out);
}


x86 assembly (clang, -O0):
<modify_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x41,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modify_string>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
movb   $0x41,(%rax)
mov    %rax,(%r14)
lea    0xecb(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"modify_string got %s\0A\00"
@.str.1 = [26 x i8] c"modify_string returns %s\0A\00"
define void @modify_string(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** %4
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %4
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 65, i8* %11
%12 = load i8*, i8** %5
%13 = load i8**, i8*** %3
store i8* %12, i8** %13
%14 = load i8**, i8*** %3
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"modify_string got %s\0A\00"
@.str.1 = [26 x i8] c"modify_string returns %s\0A\00"
define void @modify_string(i8** nocapture writeonly %0, i8* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i8* @strdup(i8* %1)
store i8 65, i8* %4
store i8* %4, i8** %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}
void _run() {}


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

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

LLVM IR (-O0):
define void @_run() {
ret void
}

LLVM IR (-O2):
define void @_run() {
ret void
}
/* Variables and functions */
int lua_dobuffer(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int lua_dostring(char *str) { return lua_dobuffer(str, strlen(str), 0); }


x86 assembly (clang, -O0):
<lua_dostring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1040 <lua_dobuffer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lua_dostring>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
pop    %rbx
jmp    1040 <lua_dobuffer@plt>

LLVM IR (-O0):
define i32 @lua_dostring(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = call i32 @lua_dobuffer(i8* %3, i32 %5, i32 0)
ret i32 %6
}

LLVM IR (-O2):
define i32 @lua_dostring(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @lua_dobuffer(i8* %0, i32 %2, i32 0)
ret i32 %3
}