xunge/DecIR huggingface dataset:
/* Type definitions */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
scalar_t__ connect(int, struct sockaddr const *, int /*<<< orphan*/);
int /*<<< orphan*/ err_sys(char *);
void Connect(int fd, const struct sockaddr *sa, socklen_t salen) {
  if (connect(fd, sa, salen) < 0)
    err_sys("connect error");
}


x86 assembly (clang, -O0):
<Connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <connect@plt>
cmp    $0x0,%rax
jge    1157 <Connect+0x37>
lea    0xeae(%rip),%rdi
call   1030 <err_sys@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Connect>:
push   %rax
call   1040 <connect@plt>
test   %rax,%rax
js     112d <Connect+0xd>
pop    %rax
ret
lea    0xecc(%rip),%rdi
pop    %rax
jmp    1030 <err_sys@plt>

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

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"connect error\00"
define void @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
ret void
}
void test10() {}


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

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

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

LLVM IR (-O2):
define void @test10() {
ret void
}
/* Type definitions */
typedef int w;
typedef int int64_t;
typedef int int32_t;

/* Variables and functions */
int32_t FixedScale(int32_t orig, int32_t factor, int32_t divisor) {
  int64_t x = orig;
  int64_t y = factor;
  int64_t z = divisor;
  int64_t w = (x * y) / z;
  return (w)&0xffffffff;
}


x86 assembly (clang, -O0):
<FixedScale>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xffffffff,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FixedScale>:
mov    %edx,%ecx
mov    %edi,%eax
imul   %esi,%eax
cltd
idiv   %ecx
ret

LLVM IR (-O0):
define i32 @FixedScale(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
store i32 %11, i32* %7
%12 = load i32, i32* %5
store i32 %12, i32* %8
%13 = load i32, i32* %6
store i32 %13, i32* %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* %9
%18 = sdiv i32 %16, %17
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = and i32 %19, -1
ret i32 %20
}

LLVM IR (-O2):
define i32 @FixedScale(i32 %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %1, %0
%5 = sdiv i32 %4, %2
ret i32 %5
}
const char *fpp_config_get_default_plugin_descr(void) {
  return "Shockwave Flash 13.1 r2";
}


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

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

LLVM IR (-O0):
@.str = [24 x i8] c"Shockwave Flash 13.1 r2\00"
define i8* @fpp_config_get_default_plugin_descr() {
ret i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [24 x i8] c"Shockwave Flash 13.1 r2\00"
define i8* @fpp_config_get_default_plugin_descr() {
ret i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void clobber() { printf("clobbering\n"); }


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

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

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

LLVM IR (-O2):
@str = [11 x i8] c"clobbering\00"
define void @clobber() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret void
}
long min_long(int wsize) {
  if (wsize == 0)
    return 0;
  return -(1 << (wsize - 1));
}


x86 assembly (clang, -O0):
<min_long>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    111e <min_long+0x1e>
movq   $0x0,-0x8(%rbp)
jmp    1137 <min_long+0x37>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<min_long>:
lea    -0x1(%rdi),%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
xor    %ecx,%ecx
cmp    $0x1,%edi
cmovae %eax,%ecx
movslq %ecx,%rax
ret

LLVM IR (-O0):
define i64 @min_long(i32 %0) {
%2 = alloca i64
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i64 0, i64* %2
br label %13
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = shl i32 1, %9
%11 = sub nsw i32 0, %10
%12 = sext i32 %11 to i64
store i64 %12, i64* %2
br label %13
13: ; preds = %7, %6
%14 = load i64, i64* %2
ret i64 %14
}

LLVM IR (-O2):
define i64 @min_long(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = add nsw i32 %0, -1
%4 = shl nsw i32 -1, %3
%5 = select i1 %2, i32 0, i32 %4
%6 = sext i32 %5 to i64
ret i64 %6
}
int nthreads(void) { return 1; }


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

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

LLVM IR (-O0):
define i32 @nthreads() {
ret i32 1
}

LLVM IR (-O2):
define i32 @nthreads() {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("hi I am ISO C\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 = [15 x i8] c"hi I am ISO C\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [14 x i8] c"hi I am ISO C\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ d2mce_finalize();
int /*<<< orphan*/ d2mce_init();
int /*<<< orphan*/ d2mce_join(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_info();
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char input;
  d2mce_init();
  d2mce_join("matrix", "eps", 0);
  print_info();
  scanf("%c", &input);
  print_info();
  d2mce_finalize();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <d2mce_init@plt>
lea    0xe8c(%rip),%rdi
lea    0xe8c(%rip),%rsi
xor    %edx,%edx
call   1050 <d2mce_join@plt>
mov    $0x0,%al
call   1070 <print_info@plt>
lea    0xe7b(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1070 <print_info@plt>
mov    $0x0,%al
call   1040 <d2mce_finalize@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <d2mce_init@plt>
lea    0xea1(%rip),%rdi
lea    0xea1(%rip),%rsi
xor    %edx,%edx
call   1050 <d2mce_join@plt>
xor    %eax,%eax
call   1070 <print_info@plt>
lea    0xe90(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1070 <print_info@plt>
xor    %eax,%eax
call   1040 <d2mce_finalize@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"matrix\00"
@.str.1 = [4 x i8] c"eps\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @d2mce_init()
%8 = call i32 @d2mce_join(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%9 = call i32 (...) @print_info()
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%11 = call i32 (...) @print_info()
%12 = call i32 (...) @d2mce_finalize()
ret i32 1
}

LLVM IR (-O2):
@.str = [7 x i8] c"matrix\00"
@.str.1 = [4 x i8] c"eps\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32 (...) @d2mce_init()
%5 = tail call i32 @d2mce_join(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = tail call i32 (...) @print_info()
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = call i32 (...) @print_info()
%9 = call i32 (...) @d2mce_finalize()
ret i32 1
}
SP_CASE(imacro, imetamacro_argcount) {
  int argn = 4;
  SP_TRUE(argn == 4);
}


x86 assembly (clang, -O0):
<SP_CASE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <SP_TRUE@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SP_CASE>:
mov    $0x1,%edi
xor    %eax,%eax
jmp    1030 <SP_TRUE@plt>

LLVM IR (-O0):
define i32 @SP_CASE(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 4, i32* %6
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 4
%9 = zext i1 %8 to i32
%10 = call i32 (i32, ...) bitcast (i32 (...)* @SP_TRUE to i32 (i32, ...)*)(i32 %9)
%11 = load i32, i32* %3
ret i32 %11
}

LLVM IR (-O2):
define i32 @SP_CASE(i32 %0, i32 %1) {
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @SP_TRUE to i32 (i32, ...)*)(i32 1)
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ HandleSignal(int, int /*<<< orphan*/);
#define SIGKILL 129
#define SIGSTOP 128
int /*<<< orphan*/ SIG_DFL;
void UnHandle(int sig) {
  switch (sig) {
  case SIGSTOP:
  case SIGKILL:
    return;
  default:
    HandleSignal(sig, SIG_DFL);
  }
}


x86 assembly (clang, -O0):
<UnHandle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     1134 <UnHandle+0x24>
jmp    112f <UnHandle+0x1f>
jmp    1145 <UnHandle+0x35>
mov    -0x4(%rbp),%edi
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
call   1030 <HandleSignal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UnHandle>:
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x80,%eax
jne    111d <UnHandle+0xd>
ret
mov    0x2ebc(%rip),%rax
mov    (%rax),%esi
jmp    1030 <HandleSignal@plt>

LLVM IR (-O0):
@SIG_DFL = global i32 0
define void @UnHandle(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %5 [
i32 128, label %4
i32 129, label %4
]
4: ; preds = %1, %1
br label %9
5: ; preds = %1
%6 = load i32, i32* %2
%7 = load i32, i32* @SIG_DFL
%8 = call i32 @HandleSignal(i32 %6, i32 %7)
br label %9
9: ; preds = %4, %5
ret void
}

LLVM IR (-O2):
@SIG_DFL = global i32 0
define void @UnHandle(i32 %0) {
%2 = and i32 %0, -2
%3 = icmp eq i32 %2, 128
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @SIG_DFL
%6 = tail call i32 @HandleSignal(i32 %0, i32 %5)
br label %7
7: ; preds = %1, %4
ret void
}
/* Variables and functions */
int /*<<< orphan*/ find_open_doors(unsigned int *);
int /*<<< orphan*/ print_open_doors(unsigned int *);
int main() {
  unsigned int doors[4] = {0};
  find_open_doors(doors);
  print_open_doors(doors);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x20(%rbp),%rdi
call   1040 <find_open_doors@plt>
lea    -0x20(%rbp),%rdi
call   1050 <print_open_doors@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <find_open_doors@plt>
mov    %rbx,%rdi
call   1040 <print_open_doors@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
store i32 0, i32* %1
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @find_open_doors(i32* %4)
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = call i32 @print_open_doors(i32* %6)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @find_open_doors(i32* %3)
%5 = call i32 @print_open_doors(i32* %3)
ret i32 0
}
/* Variables and functions */
scalar_t__ any(char, char *);
int delim(char c) {
  if (any(c, " \t\n"))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<delim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
lea    0xedb(%rip),%rsi
movsbl -0x5(%rbp),%edi
call   1030 <any@plt>
cmp    $0x0,%rax
je     1144 <delim+0x34>
movl   $0x1,-0x4(%rbp)
jmp    114b <delim+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delim>:
push   %rax
lea    0xee8(%rip),%rsi
call   1030 <any@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
define i32 @delim(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i64 @any(i8 signext %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %2
br label %9
8: ; preds = %1
store i32 0, i32* %2
br label %9
9: ; preds = %8, %7
%10 = load i32, i32* %2
ret i32 %10
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
define i32 @delim(i8 signext %0) {
%2 = tail call i64 @any(i8 signext %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
%4 = zext i1 %3 to i32
ret i32 %4
}
int get_red(unsigned int p) { return (p & 0xFF0000) >> 16; }


x86 assembly (clang, -O0):
<get_red>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_red>:
shr    $0x10,%edi
movzbl %dil,%eax
ret

LLVM IR (-O0):
define i32 @get_red(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 16711680
%5 = lshr i32 %4, 16
ret i32 %5
}

LLVM IR (-O2):
define i32 @get_red(i32 %0) {
%2 = lshr i32 %0, 16
%3 = and i32 %2, 255
ret i32 %3
}
void __gettexterror(str) const char *str;
{}


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

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

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

LLVM IR (-O2):
define void @__gettexterror(i8* nocapture %0) {
ret void
}
/* Type definitions */
struct cmdline_args_info {
  int dummy;
};

/* Variables and functions */
int cmdline_args2(int, char **, struct cmdline_args_info *, int /*<<< orphan*/,
                  int, int);
int cmdline_args(int argc, char **argv, struct cmdline_args_info *args_info) {
  return cmdline_args2(argc, argv, args_info, 0, 1, 1);
}


x86 assembly (clang, -O0):
<cmdline_args>:
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
xor    %ecx,%ecx
mov    $0x1,%r9d
mov    %r9d,%r8d
call   1030 <cmdline_args2@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdline_args>:
xor    %ecx,%ecx
mov    $0x1,%r8d
mov    $0x1,%r9d
jmp    1030 <cmdline_args2@plt>

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

LLVM IR (-O2):
%struct.cmdline_args_info = type { i32 }
define i32 @cmdline_args(i32 %0, i8** %1, %struct.cmdline_args_info* %2) {
%4 = tail call i32 @cmdline_args2(i32 %0, i8** %1, %struct.cmdline_args_info* %2, i32 0, i32 1, i32 1)
ret i32 %4
}
void RTDbgModSymbolByNameA(void) {}


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

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

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

LLVM IR (-O2):
define void @RTDbgModSymbolByNameA() {
ret void
}
void testBinaryCondOp(int *p) {
  int *x = p ?: p;
  *x = 1;
}


x86 assembly (clang, -O0):
<testBinaryCondOp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1127 <testBinaryCondOp+0x27>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    112f <testBinaryCondOp+0x2f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<testBinaryCondOp>:
movl   $0x1,(%rdi)
ret

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

LLVM IR (-O2):
define void @testBinaryCondOp(i32* nocapture writeonly %0) {
store i32 1, i32* %0
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int getAddress(int);
int /*<<< orphan*/ printSegmentationFaultMessage();
int checkJtypeIsValid(uint32_t ins) {
  uint32_t add = getAddress(ins);
  if (add < 0 || add >= 65536) {
    printSegmentationFaultMessage();
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkJtypeIsValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <getAddress@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     114d <checkJtypeIsValid+0x2d>
cmpl   $0x10000,-0xc(%rbp)
jl     1160 <checkJtypeIsValid+0x40>
mov    $0x0,%al
call   1040 <printSegmentationFaultMessage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1167 <checkJtypeIsValid+0x47>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkJtypeIsValid>:
push   %rbx
call   1030 <getAddress@plt>
mov    $0x1,%ebx
cmp    $0x10000,%eax
jb     113b <checkJtypeIsValid+0x1b>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printSegmentationFaultMessage@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @checkJtypeIsValid(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @getAddress(i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 65536
br i1 %11, label %12, label %14
12: ; preds = %9, %1
%13 = call i32 (...) @printSegmentationFaultMessage()
store i32 0, i32* %2
br label %15
14: ; preds = %9
store i32 1, i32* %2
br label %15
15: ; preds = %14, %12
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @checkJtypeIsValid(i32 %0) {
%2 = tail call i32 @getAddress(i32 %0)
%3 = icmp ugt i32 %2, 65535
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @printSegmentationFaultMessage()
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ 0, %4 ], [ 1, %1 ]
ret i32 %7
}
int jimp() { return 1; }


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

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

LLVM IR (-O0):
define i32 @jimp() {
ret i32 1
}

LLVM IR (-O2):
define i32 @jimp() {
ret i32 1
}
void foo() {
  if (1) {
    int i = 0;
  }
}


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

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

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

LLVM IR (-O2):
define void @foo() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ load_cube(int *, int, char **);
int /*<<< orphan*/ printsummary();
int /*<<< orphan*/ solve(int *);
int main(int argc, char *argv[]) {
  int i;
  int cube[24];
  load_cube(cube, argc - 1, argv);
  solve(cube);
  printsummary();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
call   1040 <load_cube@plt>
lea    -0x80(%rbp),%rdi
call   1030 <solve@plt>
mov    $0x0,%al
call   1050 <printsummary@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rdx
lea    -0x1(%rdi),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <load_cube@plt>
mov    %rbx,%rdi
call   1030 <solve@plt>
xor    %eax,%eax
call   1050 <printsummary@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [24 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [24 x i32], [24 x i32]* %7, i64 0, i64 0
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = load i8**, i8*** %5
%12 = call i32 @load_cube(i32* %8, i32 %10, i8** %11)
%13 = getelementptr inbounds [24 x i32], [24 x i32]* %7, i64 0, i64 0
%14 = call i32 @solve(i32* %13)
%15 = call i32 (...) @printsummary()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [24 x i32]
%4 = bitcast [24 x i32]* %3 to i8*
%5 = getelementptr inbounds [24 x i32], [24 x i32]* %3, i64 0, i64 0
%6 = add nsw i32 %0, -1
%7 = call i32 @load_cube(i32* %5, i32 %6, i8** %1)
%8 = call i32 @solve(i32* %5)
%9 = call i32 (...) @printsummary()
ret i32 0
}
void _m_empty(void) {}


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

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

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

LLVM IR (-O2):
define void @_m_empty() {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int main() {
  FILE *fptr = NULL;
  fptr = fopen("myfile.txt", "w");
  fprintf(fptr, "hello you awsome c made files");
  fclose(fptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xeb2(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
lea    0xecc(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
lea    0xebf(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"myfile.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"hello you awsome c made files\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
store i32* null, i32** %2
%3 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32*, i32** %2
%7 = call i32 @fclose(i32* %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"myfile.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"hello you awsome c made files\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i64 29, i64 1, i32* %1)
%3 = tail call i32 @fclose(i32* %1)
ret i32 0
}
/* Type definitions */
struct lemon {
  int dummy;
};

/* Variables and functions */
int input_getchar(struct lemon *);
void lexer_scan_line_comment(struct lemon *lemon, int c) {
  while (c != '\n') {
    c = input_getchar(lemon);
  }
}


x86 assembly (clang, -O0):
<lexer_scan_line_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
je     113a <lexer_scan_line_comment+0x2a>
mov    -0x8(%rbp),%rdi
call   1030 <input_getchar@plt>
mov    %eax,-0xc(%rbp)
jmp    111f <lexer_scan_line_comment+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_scan_line_comment>:
push   %rbx
cmp    $0xa,%esi
je     112d <lexer_scan_line_comment+0x1d>
mov    %rdi,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <input_getchar@plt>
cmp    $0xa,%eax
jne    1120 <lexer_scan_line_comment+0x10>
pop    %rbx
ret

LLVM IR (-O0):
%struct.lemon = type { i32 }
define void @lexer_scan_line_comment(%struct.lemon* %0, i32 %1) {
%3 = alloca %struct.lemon*
%4 = alloca i32
store %struct.lemon* %0, %struct.lemon** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %8, %2
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load %struct.lemon*, %struct.lemon** %3
%10 = call i32 @input_getchar(%struct.lemon* %9)
store i32 %10, i32* %4
br label %5
11: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.lemon = type { i32 }
define void @lexer_scan_line_comment(%struct.lemon* %0, i32 %1) {
%3 = icmp eq i32 %1, 10
br i1 %3, label %7, label %4
4: ; preds = %2, %4
%5 = tail call i32 @input_getchar(%struct.lemon* %0)
%6 = icmp eq i32 %5, 10
br i1 %6, label %7, label %4
7: ; preds = %4, %2
ret void
}
/* Variables and functions */
scalar_t__ toupper(int);
void upcase(char *str) {
  char *p;
  for (p = str; *p; p++) {
    *p = (char)toupper((int)*p);
  }
}


x86 assembly (clang, -O0):
<upcase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1156 <upcase+0x46>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <upcase+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upcase>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1136 <upcase+0x26>
mov    %rdi,%rbx
add    $0x1,%rbx
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1120 <upcase+0x10>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @upcase(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %11, %4 ], [ %2, %1 ]
%6 = phi i8* [ %10, %4 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
%8 = tail call i64 @toupper(i32 %7)
%9 = trunc i64 %8 to i8
store i8 %9, i8* %6
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %1
ret void
}
/* Variables and functions */
int __syscall(char *, int /*<<< orphan*/, int /*<<< orphan*/,
              int /*<<< orphan*/, int);
int chdir(char *dir) { return __syscall(dir, 0, 0, 0, 12); }


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

x86 assembly (clang, -O2):
<chdir>:
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0xc,%r8d
jmp    1030 <__syscall@plt>

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

LLVM IR (-O2):
define i32 @chdir(i8* %0) {
%2 = tail call i32 @__syscall(i8* %0, i32 0, i32 0, i32 0, i32 12)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main() {
  int TID;
#pragma omp parallel
  {
#pragma omp single
    printf("Number of threads is %d\n", 1);
  }
#pragma omp parallel default(none) private(TID)
  {
    TID = 0;
#pragma omp critical(print_tid)
    { printf("I am thread %d\n", TID); }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xed8(%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
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Number of threads is %d\0A\00"
@.str.1 = [16 x i8] c"I am thread %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %4)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Number of threads is %d\0A\00"
@.str.1 = [16 x i8] c"I am thread %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 0)
ret i32 0
}
/* Type definitions */
struct system {
  int dummy;
};

/* Variables and functions */
void *malloc(int);
void *default_alloc(struct system *sys, int size) { return malloc(size); }


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

x86 assembly (clang, -O2):
<default_alloc>:
mov    %esi,%edi
jmp    1030 <malloc@plt>

LLVM IR (-O0):
%struct.system = type { i32 }
define i8* @default_alloc(%struct.system* %0, i32 %1) {
%3 = alloca %struct.system*
%4 = alloca i32
store %struct.system* %0, %struct.system** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = call i8* @malloc(i32 %5)
ret i8* %6
}

LLVM IR (-O2):
%struct.system = type { i32 }
define noalias i8* @default_alloc(%struct.system* nocapture readnone %0, i32 %1) {
%3 = tail call i8* @malloc(i32 %1)
ret i8* %3
}
int roundup(int size) {
  static int multsize = 4 * sizeof(int);
  if (size % multsize != 0)
    size += multsize - (size % multsize);
  return size;
}


x86 assembly (clang, -O0):
<roundup>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  0x2f0f(%rip)
cmp    $0x0,%edx
je     1138 <roundup+0x38>
mov    0x2f00(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  0x2ef3(%rip)
mov    -0x8(%rbp),%eax
sub    %edx,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<roundup>:
lea    0xf(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff0,%eax
mov    %edi,%ecx
sub    %eax,%ecx
mov    $0x10,%eax
sub    %ecx,%eax
test   %ecx,%ecx
cmove  %ecx,%eax
add    %edi,%eax
ret

LLVM IR (-O0):
@roundup.multsize = internal global i32 16
define i32 @roundup(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @roundup.multsize
%5 = srem i32 %3, %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i32, i32* @roundup.multsize
%9 = load i32, i32* %2
%10 = load i32, i32* @roundup.multsize
%11 = srem i32 %9, %10
%12 = sub nsw i32 %8, %11
%13 = load i32, i32* %2
%14 = add nsw i32 %13, %12
store i32 %14, i32* %2
br label %15
15: ; preds = %7, %1
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @roundup(i32 %0) {
%2 = srem i32 %0, 16
%3 = icmp eq i32 %2, 0
%4 = sub nsw i32 16, %2
%5 = select i1 %3, i32 0, i32 %4
%6 = add nsw i32 %5, %0
ret i32 %6
}
/* Variables and functions */
double cos(double);
double cos_deg(double value) { return (cos(value * 3.14159265 / 180.0)); }


x86 assembly (clang, -O0):
<cos_deg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xee3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xece(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cos_deg>:
mulsd  0xee8(%rip),%xmm0
divsd  0xee8(%rip),%xmm0
jmp    1030 <cos@plt>

LLVM IR (-O0):
define double @cos_deg(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fmul double %3, 0x400921FB53C8D4F1
%5 = fdiv double %4, 1.800000e+02
%6 = call double @cos(double %5)
ret double %6
}

LLVM IR (-O2):
define double @cos_deg(double %0) {
%2 = fmul double %0, 0x400921FB53C8D4F1
%3 = fdiv double %2, 1.800000e+02
%4 = tail call double @cos(double %3)
ret double %4
}
int do_847() { return 847; }


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

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

LLVM IR (-O0):
define i32 @do_847() {
ret i32 847
}

LLVM IR (-O2):
define i32 @do_847() {
ret i32 847
}
/* Variables and functions */
int close(int);
int closeSocket(int s) { return close(s); }


x86 assembly (clang, -O0):
<closeSocket>:
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):
<closeSocket>:
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define i32 @closeSocket(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret i32 %2
}
int max(int p, int q) { return (p > q) ? p : q; }


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

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

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

LLVM IR (-O2):
define i32 @max(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
%4 = select i1 %3, i32 %0, i32 %1
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stdout;
void sayhello(const char *msg) { fprintf(stdout, "hello: %s\n", msg); }


x86 assembly (clang, -O0):
<sayhello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xed0(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sayhello>:
mov    %rdi,%rdx
mov    0x2ec6(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [11 x i8] c"hello: %s\0A\00"
define void @sayhello(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stdout
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [11 x i8] c"hello: %s\0A\00"
define void @sayhello(i8* %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
__attribute__((constructor)) void pwnable_init(void) {
  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);
}


x86 assembly (clang, -O0):
<pwnable_init>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    0x2ec4(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwnable_init>:
push   %rbx
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
mov    0x2ec7(%rip),%rbx
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
pop    %rbx
jmp    1030 <setvbuf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@stderr = global i32 0
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @pwnable_init, i8* null }]
define void @pwnable_init() {
%1 = load i32, i32* @stdout
%2 = load i32, i32* @_IONBF
%3 = call i32 @setvbuf(i32 %1, i32* null, i32 %2, i32 0)
%4 = load i32, i32* @stderr
%5 = load i32, i32* @_IONBF
%6 = call i32 @setvbuf(i32 %4, i32* null, i32 %5, i32 0)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@stderr = global i32 0
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @pwnable_init, i8* null }]
define void @pwnable_init() {
%1 = load i32, i32* @stdout
%2 = load i32, i32* @_IONBF
%3 = tail call i32 @setvbuf(i32 %1, i32* null, i32 %2, i32 0)
%4 = load i32, i32* @stderr
%5 = load i32, i32* @_IONBF
%6 = tail call i32 @setvbuf(i32 %4, i32* null, i32 %5, i32 0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
off_t lseek(int fd, off_t offset, int whence) { return 0; }


x86 assembly (clang, -O0):
<lseek>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @lseek(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
ret i32 0
}

LLVM IR (-O2):
define i32 @lseek(i32 %0, i32 %1, i32 %2) {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t read(int, void *, size_t);
int /*<<< orphan*/ stderr;
size_t file_read(void *buf, size_t bufsz, int fd) {
  size_t r;
  r = read(fd, buf, bufsz);
  if (!r)
    fprintf(stderr, "EOF\n");
  return r;
}


x86 assembly (clang, -O0):
<file_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <read@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1167 <file_read+0x47>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_read>:
push   %rbx
mov    %edx,%eax
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    %eax,%edi
call   1030 <read@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114d <file_read+0x2d>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"EOF\0A\00"
define i64 @file_read(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i8*, i8** %4
%10 = load i64, i64* %5
%11 = call i64 @read(i32 %8, i8* %9, i64 %10)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp ne i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %3
%18 = load i64, i64* %7
ret i64 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"EOF\0A\00"
define i64 @file_read(i8* nocapture %0, i64 %1, i32 %2) {
%4 = tail call i64 @read(i32 %2, i8* %0, i64 %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %3
ret i64 %4
}
/* Type definitions */
struct drm_file {
  int dummy;
};
struct drm_device {
  int dummy;
};

/* Variables and functions */
int drm_agp_acquire(struct drm_device *);
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
                          struct drm_file *file_priv) {
  return drm_agp_acquire(dev);
}


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

x86 assembly (clang, -O2):
<drm_agp_acquire_ioctl>:
jmp    1030 <drm_agp_acquire@plt>

LLVM IR (-O0):
%struct.drm_device = type { i32 }
%struct.drm_file = type { i32 }
define i32 @drm_agp_acquire_ioctl(%struct.drm_device* %0, i8* %1, %struct.drm_file* %2) {
%4 = alloca %struct.drm_device*
%5 = alloca i8*
%6 = alloca %struct.drm_file*
store %struct.drm_device* %0, %struct.drm_device** %4
store i8* %1, i8** %5
store %struct.drm_file* %2, %struct.drm_file** %6
%7 = load %struct.drm_device*, %struct.drm_device** %4
%8 = call i32 @drm_agp_acquire(%struct.drm_device* %7)
ret i32 %8
}

LLVM IR (-O2):
%struct.drm_device = type { i32 }
%struct.drm_file = type { i32 }
define i32 @drm_agp_acquire_ioctl(%struct.drm_device* %0, i8* nocapture readnone %1, %struct.drm_file* nocapture readnone %2) {
%4 = tail call i32 @drm_agp_acquire(%struct.drm_device* %0)
ret i32 %4
}
void module1_section3_topic4() {}


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

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

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

LLVM IR (-O2):
define void @module1_section3_topic4() {
ret void
}
/* Variables and functions */
double M_PI;
double sin(double);
double sinc(double x) {
  double val = 1.0;
  if (x != 0) {
    val = sin(M_PI * x) / (M_PI * x);
  }
  return val;
}


x86 assembly (clang, -O0):
<sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1147 <sinc+0x37>
jp     1147 <sinc+0x37>
jmp    1175 <sinc+0x65>
mov    0x2e9a(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
mov    0x2e85(%rip),%rax
movsd  (%rax),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1125 <sinc+0x15>
jnp    114f <sinc+0x3f>
mov    0x2ebc(%rip),%rbx
movsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rbx),%xmm1
divsd  %xmm1,%xmm0
jmp    1157 <sinc+0x47>
movsd  0xea9(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @sinc(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
store double 1.000000e+00, double* %3
%4 = load double, double* %2
%5 = fcmp une double %4, 0.000000e+00
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load double, double* @M_PI
%8 = load double, double* %2
%9 = fmul double %7, %8
%10 = call double @sin(double %9)
%11 = load double, double* @M_PI
%12 = load double, double* %2
%13 = fmul double %11, %12
%14 = fdiv double %10, %13
store double %14, double* %3
br label %15
15: ; preds = %6, %1
%16 = load double, double* %3
ret double %16
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @sinc(double %0) {
%2 = fcmp une double %0, 0.000000e+00
br i1 %2, label %3, label %10
3: ; preds = %1
%4 = load double, double* @M_PI
%5 = fmul double %4, %0
%6 = tail call double @sin(double %5)
%7 = load double, double* @M_PI
%8 = fmul double %7, %0
%9 = fdiv double %6, %8
br label %10
10: ; preds = %3, %1
%11 = phi double [ %9, %3 ], [ 1.000000e+00, %1 ]
ret double %11
}