xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ init(char *);
scalar_t__ malloc(int);
int main(int argc, const char *argv[]) {
  char *p;
  init(p);
  p = (char *)malloc(42);
  if (argc > 0) {
    if (!p) {
      exit(1);
    }
  } else {
    if (!p)
      exit(2);
  }
  p[0] = '\0';
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <init@plt>
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1181 <main+0x51>
cmpq   $0x0,-0x18(%rbp)
jne    117c <main+0x4c>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    119b <main+0x6b>
cmpq   $0x0,-0x18(%rbp)
jne    1196 <main+0x66>
mov    $0x2,%edi
call   1050 <exit@plt>
jmp    119b <main+0x6b>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %edi,%ebx
call   1030 <init@plt>
mov    $0x2a,%edi
call   1040 <malloc@plt>
test   %ebx,%ebx
jle    1155 <main+0x25>
test   %rax,%rax
jne    115a <main+0x2a>
mov    $0x1,%edi
call   1050 <exit@plt>
test   %rax,%rax
je     1161 <main+0x31>
movb   $0x0,(%rax)
xor    %eax,%eax
pop    %rbx
ret
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
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 = load i8*, i8** %6
%8 = call i32 @init(i8* %7)
%9 = call i64 @malloc(i32 42)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %13
br label %25
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %19
br label %25
25: ; preds = %24, %18
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 0
store i8 0, i8* %27
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @init(i8* undef)
%4 = tail call i64 @malloc(i32 42)
%5 = icmp sgt i32 %0, 0
%6 = icmp eq i64 %4, 0
br i1 %5, label %7, label %10
7: ; preds = %2
br i1 %6, label %8, label %13
8: ; preds = %7
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
br i1 %6, label %11, label %13
11: ; preds = %10
%12 = tail call i32 @exit(i32 2)
unreachable
13: ; preds = %10, %7
%14 = inttoptr i64 %4 to i8*
store i8 0, i8* %14
ret i32 0
}
signed int f24(signed int v_foo) {
  signed int v_and = v_foo & 254;
  signed int v_parta = ((unsigned int)v_and) >> 3;
  signed int v_partb = v_and << 29;
  signed int v_rotl = v_parta | v_partb;
  return v_rotl;
}


x86 assembly (clang, -O0):
<f24>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfe,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1d,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f24>:
mov    %edi,%eax
and    $0xfe,%eax
rol    $0x1d,%eax
ret

LLVM IR (-O0):
define i32 @f24(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = and i32 %7, 254
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = lshr i32 %9, 3
store i32 %10, i32* %4
%11 = load i32, i32* %3
%12 = shl i32 %11, 29
store i32 %12, i32* %5
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = or i32 %13, %14
store i32 %15, i32* %6
%16 = load i32, i32* %6
ret i32 %16
}

LLVM IR (-O2):
define i32 @f24(i32 %0) {
%2 = and i32 %0, 254
%3 = tail call i32 @llvm.fshl.i32(i32 %2, i32 %2, i32 29)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ log_print(int, char *, char *);
int /*<<< orphan*/ sck_cleanup();
void handle_termination(int signo) {
  log_print(0x02, "graceful %s", "shutdown");
  sck_cleanup();
  exit(1);
}


x86 assembly (clang, -O0):
<handle_termination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x2,%edi
lea    0xeb9(%rip),%rsi
lea    0xebe(%rip),%rdx
call   1040 <log_print@plt>
mov    $0x0,%al
call   1030 <sck_cleanup@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<handle_termination>:
push   %rax
lea    0xec8(%rip),%rsi
lea    0xecd(%rip),%rdx
mov    $0x2,%edi
call   1040 <log_print@plt>
xor    %eax,%eax
call   1030 <sck_cleanup@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"graceful %s\00"
@.str.1 = [9 x i8] c"shutdown\00"
define void @handle_termination(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @log_print(i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (...) @sck_cleanup()
%5 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [12 x i8] c"graceful %s\00"
@.str.1 = [9 x i8] c"shutdown\00"
define void @handle_termination(i32 %0) {
%2 = tail call i32 @log_print(i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (...) @sck_cleanup()
%4 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int singleNumber(int *, int);
int main() {
  int nums[5] = {1, 5, 5, 1, 3};
  printf("%d\n", singleNumber(nums, 5));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1030 <singleNumber@plt>
mov    %eax,%esi
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xee6(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
call   1030 <singleNumber@plt>
lea    0xec7(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.nums = [5 x i32] [i32 1, i32 5, i32 5, i32 1, i32 3]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
store i32 0, i32* %1
%3 = bitcast [5 x i32]* %2 to i8*
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%5 = call i32 @singleNumber(i32* %4, i32 5)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}

LLVM IR (-O2):
@__const.main.nums = [5 x i32] [i32 1, i32 5, i32 5, i32 1, i32 3]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @singleNumber(i32* %3, i32 5)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
ret i32 0
}
/* Variables and functions */
int b();
int c();
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int a = b() + c();
  printf("%d \n", a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <b@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <c@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <b@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <c@plt>
add    %eax,%ebx
lea    0xeb6(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = tail call i32 (...) @b()
%2 = tail call i32 (...) @c()
%3 = add nsw i32 %2, %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
ret i32 0
}
/* Variables and functions */
int add(char const *, int);
int syms_add_global(const char *n) { return add(n, 1); }


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

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

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

LLVM IR (-O2):
define i32 @syms_add_global(i8* %0) {
%2 = tail call i32 @add(i8* %0, i32 1)
ret i32 %2
}
int str_length(char *str) {
  int i = 0;
  while (*str != '\0') {
    i++;
    *str++;
  }
  return i;
}


x86 assembly (clang, -O0):
<str_length>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1139 <str_length+0x39>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <str_length+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_length>:
cmpb   $0x0,(%rdi)
je     111c <str_length+0x1c>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,0x1(%rdi,%rax,1)
lea    0x1(%rax),%rax
jne    1110 <str_length+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @str_length(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %7, %4 ], [ 0, %1 ]
%6 = phi i8* [ %8, %4 ], [ %0, %1 ]
%7 = add nuw nsw i32 %5, 1
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4, %1
%12 = phi i32 [ 0, %1 ], [ %7, %4 ]
ret i32 %12
}
unsigned float_i2f(int x) {}


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

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

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

LLVM IR (-O2):
define i32 @float_i2f(i32 %0) {
ret i32 undef
}
/* Variables and functions */
void *func(void *data) {
  int i, ret = 0, num = *(int *)data;
  for (i = 0; i < 100; i++)
    ret += num;
  return (void *)(intptr_t)ret;
}


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1140 <func+0x40>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <func+0x1f>
movslq -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<func>:
imul   $0x64,(%rdi),%eax
cltq
ret

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

LLVM IR (-O2):
define i8* @func(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = mul i32 %3, 100
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
ret i8* %6
}
/* Type definitions */
typedef scalar_t__ uint32_t;

/* Variables and functions */
uint32_t max(uint32_t value1, uint32_t value2) {
  return value1 >= value2 ? value1 : value2;
}


x86 assembly (clang, -O0):
<max>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jl     1127 <max+0x27>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    112f <max+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<max>:
mov    %rdi,%rax
cmp    %rsi,%rdi
cmovl  %rsi,%rax
ret

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

LLVM IR (-O2):
define i64 @max(i64 %0, i64 %1) {
%3 = icmp slt i64 %0, %1
%4 = select i1 %3, i64 %1, i64 %0
ret i64 %4
}
/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, long);
char *subst(char *, char const *, char *);
char *substlong(char *tgt, const char *oldstr, long l) {
  char buf[23];
  snprintf(buf, sizeof buf, "%ld", l);
  return subst(tgt, oldstr, buf);
}


x86 assembly (clang, -O0):
<substlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x17,%esi
lea    0xeb8(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <subst@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substlong>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rcx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec7(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x17,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <subst@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
define i8* @substlong(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [23 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = getelementptr inbounds [23 x i8], [23 x i8]* %7, i64 0, i64 0
%9 = load i64, i64* %6
%10 = call i32 @snprintf(i8* %8, i32 23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = getelementptr inbounds [23 x i8], [23 x i8]* %7, i64 0, i64 0
%14 = call i8* @subst(i8* %11, i8* %12, i8* %13)
ret i8* %14
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
define i8* @substlong(i8* %0, i8* %1, i64 %2) {
%4 = alloca [23 x i8]
%5 = getelementptr inbounds [23 x i8], [23 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %2)
%7 = call i8* @subst(i8* %0, i8* %1, i8* %5)
ret i8* %7
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ivory_serialize_unpack_prim_1_be(int /*<<< orphan*/ const *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
void ivory_serialize_unpack_uint8_be(const uint8_t *src, uint32_t offs,
                                     uint8_t *dst) {
  uint8_t tmp = ivory_serialize_unpack_prim_1_be(src + offs);
  memcpy(dst, &tmp, sizeof(*dst));
}


x86 assembly (clang, -O0):
<ivory_serialize_unpack_uint8_be>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1040 <ivory_serialize_unpack_prim_1_be@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ivory_serialize_unpack_uint8_be>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
movslq %esi,%rax
lea    (%rdi,%rax,4),%rdi
call   1040 <ivory_serialize_unpack_prim_1_be@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @ivory_serialize_unpack_uint8_be(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
%12 = call i32 @ivory_serialize_unpack_prim_1_be(i32* %11)
store i32 %12, i32* %7
%13 = load i32*, i32** %6
%14 = call i32 @memcpy(i32* %13, i32* %7, i32 4)
ret void
}

LLVM IR (-O2):
define void @ivory_serialize_unpack_uint8_be(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = tail call i32 @ivory_serialize_unpack_prim_1_be(i32* %7)
store i32 %8, i32* %4
%9 = call i32 @memcpy(i32* %2, i32* %4, i32 4)
ret void
}
int emac1_ifinbroadcastpkts_set(unsigned int dev_id,
                                union emac1_ifinbroadcastpkts_u *value) {
  return 1;
}


x86 assembly (clang, -O0):
<emac1_ifinbroadcastpkts_set>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
%union.emac1_ifinbroadcastpkts_u = type opaque
define i32 @emac1_ifinbroadcastpkts_set(i32 %0, %union.emac1_ifinbroadcastpkts_u* %1) {
%3 = alloca i32
%4 = alloca %union.emac1_ifinbroadcastpkts_u*
store i32 %0, i32* %3
store %union.emac1_ifinbroadcastpkts_u* %1, %union.emac1_ifinbroadcastpkts_u** %4
ret i32 1
}

LLVM IR (-O2):
%union.emac1_ifinbroadcastpkts_u = type opaque
define i32 @emac1_ifinbroadcastpkts_set(i32 %0, %union.emac1_ifinbroadcastpkts_u* nocapture readnone %1) {
ret i32 1
}
int map_width(int res) {
  int width;
  width = (1 << (res + 1));
  return width;
}


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

x86 assembly (clang, -O2):
<map_width>:
lea    0x1(%rdi),%ecx
mov    $0x1,%eax
shl    %cl,%eax
ret

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

LLVM IR (-O2):
define i32 @map_width(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = shl nuw i32 1, %2
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ read_constexpr();
int /*<<< orphan*/ read_if_generic(int /*<<< orphan*/);
void read_if(void) { read_if_generic(read_constexpr()); }


x86 assembly (clang, -O0):
<read_if>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <read_constexpr@plt>
mov    %eax,%edi
call   1040 <read_if_generic@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_if>:
push   %rax
xor    %eax,%eax
call   1030 <read_constexpr@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <read_if_generic@plt>

LLVM IR (-O0):
define void @read_if() {
%1 = call i32 (...) @read_constexpr()
%2 = call i32 @read_if_generic(i32 %1)
ret void
}

LLVM IR (-O2):
define void @read_if() {
%1 = tail call i32 (...) @read_constexpr()
%2 = tail call i32 @read_if_generic(i32 %1)
ret void
}
/* Variables and functions */
double fmod(double, double);
int /*<<< orphan*/ printf(char *, double);
int main() {
  printf("fmod of 5.3 / 2 is %f\n", fmod(5.3, 2));
  printf("fmod of 18.5 / 4.2 is %f\n", fmod(18.5, 4.2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  0xed9(%rip),%xmm1
call   1040 <fmod@plt>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
movsd  0xea8(%rip),%xmm0
movsd  0xea8(%rip),%xmm1
call   1040 <fmod@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [23 x i8] c"fmod of 5.3 / 2 is %f\0A\00"
@.str.1 = [26 x i8] c"fmod of 18.5 / 4.2 is %f\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call double @fmod(double 5.300000e+00, double 2.000000e+00)
%3 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %2)
%4 = call double @fmod(double 1.850000e+01, double 4.200000e+00)
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %4)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"fmod of 5.3 / 2 is %f\0A\00"
@.str.1 = [26 x i8] c"fmod of 18.5 / 4.2 is %f\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double 0x3FF4CCCCCCCCCCCC)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double 0x3FFB333333333330)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void perror(const char *s) { fprintf(stderr, "%s: %s\n", s, strerror(errno)); }


x86 assembly (clang, -O0):
<perror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    %rax,%rcx
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perror>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb3(%rip),%rax
mov    (%rax),%ebp
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
lea    0xebc(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
define void @perror(i8* %0) {
%2 = load i32, i32* @stderr
%3 = load i32, i32* @errno
%4 = tail call i8* @strerror(i32 %3)
%5 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %4)
ret void
}
/* Variables and functions */
long util_cpu_time();
long ptime() { return util_cpu_time(); }


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

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

LLVM IR (-O0):
define i64 @ptime() {
%1 = call i64 (...) @util_cpu_time()
ret i64 %1
}

LLVM IR (-O2):
define i64 @ptime() {
%1 = tail call i64 (...) @util_cpu_time()
ret i64 %1
}
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ y;
};
typedef TYPE_1__ XWindowAttributes;

/* Variables and functions */
int get_XWindowAttributes_y(void *_p) {
  return (int)((XWindowAttributes *)_p)->y;
}


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

x86 assembly (clang, -O2):
<get_XWindowAttributes_y>:
mov    (%rdi),%eax
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64 }
define i32 @get_XWindowAttributes_y(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = bitcast i8* %3 to %struct.TYPE_2__*
%5 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %4, i32 0, i32 0
%6 = load i64, i64* %5
%7 = trunc i64 %6 to i32
ret i32 %7
}

LLVM IR (-O2):
define i32 @get_XWindowAttributes_y(i8* nocapture %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
%4 = trunc i64 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ Com_Memset(void *, int /*<<< orphan*/, unsigned long);
void *GetMemory(unsigned long);
void *GetClearedMemory(unsigned long size) {
  void *ptr;
  ptr = GetMemory(size);
  Com_Memset(ptr, 0, size);
  return ptr;
}


x86 assembly (clang, -O0):
<GetClearedMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <GetMemory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
call   1040 <Com_Memset@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetClearedMemory>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <GetMemory@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <Com_Memset@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @GetClearedMemory(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i8* @GetMemory(i64 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i64, i64* %2
%8 = call i32 @Com_Memset(i8* %6, i32 0, i64 %7)
%9 = load i8*, i8** %3
ret i8* %9
}

LLVM IR (-O2):
define i8* @GetClearedMemory(i64 %0) {
%2 = tail call i8* @GetMemory(i64 %0)
%3 = tail call i32 @Com_Memset(i8* %2, i32 0, i64 %0)
ret i8* %2
}
double _SCOTCHclockGet(void) { return (1.0e-6L); }


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

x86 assembly (clang, -O2):
<_SCOTCHclockGet>:
movsd  0xef8(%rip),%xmm0
ret

LLVM IR (-O0):
define double @_SCOTCHclockGet() {
ret double 0x3EB0C6F7A0B5ED8D
}

LLVM IR (-O2):
define double @_SCOTCHclockGet() {
ret double 0x3EB0C6F7A0B5ED8D
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int foobar2(int x) {
  printf("I have been invoked!!!! x=%d\n", x * 3);
  return x;
}


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

x86 assembly (clang, -O2):
<foobar2>:
push   %rbx
mov    %edi,%ebx
lea    (%rbx,%rbx,2),%esi
lea    0xee3(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"I have been invoked!!!! x=%d\0A\00"
define i32 @foobar2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = mul nsw i32 %3, 3
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* %2
ret i32 %6
}

LLVM IR (-O2):
@.str = [30 x i8] c"I have been invoked!!!! x=%d\0A\00"
define i32 @foobar2(i32 returned %0) {
%2 = mul nsw i32 %0, 3
%3 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 %0
}
OP(dd, c2) {
  illegal_1();
  op_c2();
}


x86 assembly (clang, -O0):
<OP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <illegal_1@plt>
mov    $0x0,%al
call   1040 <op_c2@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OP>:
push   %rax
xor    %eax,%eax
call   1030 <illegal_1@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <op_c2@plt>

LLVM IR (-O0):
define i32 @OP(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = call i32 (...) @illegal_1()
%7 = call i32 (...) @op_c2()
%8 = load i32, i32* %3
ret i32 %8
}

LLVM IR (-O2):
define i32 @OP(i32 %0, i32 %1) {
%3 = tail call i32 (...) @illegal_1()
%4 = tail call i32 (...) @op_c2()
ret i32 undef
}
/* Type definitions */
typedef int GLushort;
typedef int GLubyte;
typedef int GLshort;
typedef int /*<<< orphan*/ GLdouble;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
GLdouble extractSshort(int isSwap, const void *sitem) {
  GLshort sshort;
  if (isSwap) {
    sshort = (GLushort)(((GLushort)((const GLubyte *)(sitem))[1]) << 8 |
                        ((const GLubyte *)(sitem))[0]);
  } else {
    sshort = *(const GLshort *)sitem;
  }
  assert(sshort <= 32767);
  return (GLdouble)sshort;
}


x86 assembly (clang, -O0):
<extractSshort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1141 <extractSshort+0x31>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
or     (%rcx),%eax
mov    %eax,-0x14(%rbp)
jmp    114a <extractSshort+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x7fff,-0x14(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractSshort>:
push   %rbx
test   %edi,%edi
je     111f <extractSshort+0xf>
mov    0x4(%rsi),%ebx
shl    $0x8,%ebx
or     (%rsi),%ebx
jmp    1121 <extractSshort+0x11>
mov    (%rsi),%ebx
xor    %edi,%edi
cmp    $0x8000,%ebx
setl   %dil
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @extractSshort(i32 %0, i8* nocapture %1) {
%3 = icmp eq i32 %0, 0
%4 = bitcast i8* %1 to i32*
br i1 %3, label %12, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 4
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
%9 = shl i32 %8, 8
%10 = load i32, i32* %4
%11 = or i32 %9, %10
br label %14
12: ; preds = %2
%13 = load i32, i32* %4
br label %14
14: ; preds = %12, %5
%15 = phi i32 [ %11, %5 ], [ %13, %12 ]
%16 = icmp slt i32 %15, 32768
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
ret i32 %15
}
char ft_endianness(void) {
  unsigned int i;
  char *c;
  i = 1;
  c = (char *)&i;
  return (!*c);
}


x86 assembly (clang, -O0):
<ft_endianness>:
push   %rbp
mov    %rsp,%rbp
movl   $0x1,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
movsbl %al,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define signext i8 @ft_endianness() {
ret i8 0
}
unsigned int htonl(unsigned int a) {
  union temp {
    unsigned char a[4];
    unsigned int b;
  } aa;
  union temp bb;
  aa.b = a;
  bb.a[3] = aa.a[0];
  bb.a[2] = aa.a[1];
  bb.a[1] = aa.a[2];
  bb.a[0] = aa.a[3];
  return bb.b;
}


x86 assembly (clang, -O0):
<htonl>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%al
mov    %al,-0xd(%rbp)
mov    -0x7(%rbp),%al
mov    %al,-0xe(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0xf(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @htonl(i32 %0) {
%2 = tail call i32 @llvm.bswap.i32(i32 %0)
ret i32 %2
}
/* Variables and functions */
int getch();
int /*<<< orphan*/ ungetch(int);
void pause(void) {
  while (1) {
    int key = getch();
    switch (key) {
    case (112):
      return;
    case (113): {
      ungetch(key);
      return;
    }
    }
  }
}


x86 assembly (clang, -O0):
<pause>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <getch@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x70,%eax
je     1157 <pause+0x37>
jmp    1146 <pause+0x26>
mov    -0x8(%rbp),%eax
sub    $0x71,%eax
je     115c <pause+0x3c>
jmp    1169 <pause+0x49>
jmp    116e <pause+0x4e>
mov    -0x4(%rbp),%edi
call   1030 <ungetch@plt>
jmp    116e <pause+0x4e>
jmp    1128 <pause+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pause>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getch@plt>
cmp    $0x70,%eax
je     114c <pause+0x2c>
cmp    $0x71,%eax
jne    1130 <pause+0x10>
mov    $0x71,%edi
pop    %rax
jmp    1030 <ungetch@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @pause() {
%1 = alloca i32
br label %2
2: ; preds = %0, %9
%3 = call i32 (...) @getch()
store i32 %3, i32* %1
%4 = load i32, i32* %1
switch i32 %4, label %9 [
i32 112, label %5
i32 113, label %6
]
5: ; preds = %2
br label %10
6: ; preds = %2
%7 = load i32, i32* %1
%8 = call i32 @ungetch(i32 %7)
br label %10
9: ; preds = %2
br label %2
10: ; preds = %6, %5
ret void
}

LLVM IR (-O2):
define void @pause() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @getch()
switch i32 %2, label %1 [
i32 112, label %5
i32 113, label %3
]
3: ; preds = %1
%4 = tail call i32 @ungetch(i32 113)
br label %5
5: ; preds = %1, %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _itoa(int);
int /*<<< orphan*/ quote_out(char **, int /*<<< orphan*/);
void quote_out_int(char **p, int s) { quote_out(p, _itoa(s)); }


x86 assembly (clang, -O0):
<quote_out_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <_itoa@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1030 <quote_out@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quote_out_int>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
call   1040 <_itoa@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1030 <quote_out@plt>

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

LLVM IR (-O2):
define void @quote_out_int(i8** %0, i32 %1) {
%3 = tail call i32 @_itoa(i32 %1)
%4 = tail call i32 @quote_out(i8** %0, i32 %3)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ GetLine(char *, int);
scalar_t__ IsPalindrome(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  char s[1000];
  printf("Enter a string to test if palindrome: ");
  GetLine(s, 1000);
  printf(IsPalindrome(s) ? "yes\n" : "no\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
lea    0xebe(%rip),%rdi
call   1050 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <GetLine@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <IsPalindrome@plt>
mov    %rax,%rcx
lea    0xebe(%rip),%rdi
lea    0xeb2(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xec1(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <GetLine@plt>
mov    %rbx,%rdi
call   1030 <IsPalindrome@plt>
test   %rax,%rax
lea    0xec6(%rip),%rax
lea    0xeba(%rip),%rdi
cmove  %rax,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Enter a string to test if palindrome: \00"
@.str.1 = [5 x i8] c"yes\0A\00"
@.str.2 = [4 x i8] c"no\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = call i32 @GetLine(i8* %3, i32 1000)
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = call i64 @IsPalindrome(i8* %5)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%10 = call i32 @printf(i8* %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Enter a string to test if palindrome: \00"
@.str.1 = [5 x i8] c"yes\0A\00"
@.str.2 = [4 x i8] c"no\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @GetLine(i8* %2, i32 1000)
%5 = call i64 @IsPalindrome(i8* %2)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%8 = call i32 @printf(i8* dereferenceable(1) %7)
ret i32 0
}
signed char store_weight(int weight) {
  if (weight > 1024)
    weight = 1024;
  else if (weight < -1024)
    weight = -1024;
  if (weight > 0)
    weight -= (weight + 64) >> 7;
  return (weight + 4) >> 3;
}


x86 assembly (clang, -O0):
<store_weight>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x400,-0x4(%rbp)
jle    1120 <store_weight+0x20>
movl   $0x400,-0x4(%rbp)
jmp    1139 <store_weight+0x39>
cmpl   $0xfffffc00,-0x4(%rbp)
jge    1134 <store_weight+0x34>
movl   $0xfffffc00,-0x4(%rbp)
jmp    1139 <store_weight+0x39>
cmpl   $0x0,-0x4(%rbp)
jle    1154 <store_weight+0x54>
mov    -0x4(%rbp),%ecx
add    $0x40,%ecx
sar    $0x7,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4,%eax
sar    $0x3,%eax
movsbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_weight>:
cmp    $0xfffffc01,%edi
mov    $0xfffffc00,%eax
cmovge %edi,%eax
cmp    $0x400,%eax
mov    $0x400,%ecx
cmovl  %eax,%ecx
lea    0x40(%rcx),%edx
shr    $0x7,%edx
xor    %esi,%esi
test   %eax,%eax
cmovg  %edx,%esi
neg    %esi
lea    (%rcx,%rsi,1),%eax
add    $0x4,%eax
shr    $0x3,%eax
ret

LLVM IR (-O0):
define signext i8 @store_weight(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 1024
br i1 %4, label %5, label %6
5: ; preds = %1
store i32 1024, i32* %2
br label %11
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, -1024
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 -1024, i32* %2
br label %10
10: ; preds = %9, %6
br label %11
11: ; preds = %10, %5
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 64
%17 = ashr i32 %16, 7
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, %17
store i32 %19, i32* %2
br label %20
20: ; preds = %14, %11
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 4
%23 = ashr i32 %22, 3
%24 = trunc i32 %23 to i8
ret i8 %24
}

LLVM IR (-O2):
define signext i8 @store_weight(i32 %0) {
%2 = icmp sgt i32 %0, -1024
%3 = select i1 %2, i32 %0, i32 -1024
%4 = icmp slt i32 %3, 1024
%5 = select i1 %4, i32 %3, i32 1024
%6 = icmp sgt i32 %3, 0
%7 = add nsw i32 %5, 64
%8 = lshr i32 %7, 7
%9 = select i1 %6, i32 %8, i32 0
%10 = add nsw i32 %5, 4
%11 = sub nsw i32 %10, %9
%12 = lshr i32 %11, 3
%13 = trunc i32 %12 to i8
ret i8 %13
}
/* Variables and functions */
int syscall(int, int, char *, int);
int write(int fd, char *buf, int nbytes) {
  return syscall(35, fd, buf, nbytes);
}


x86 assembly (clang, -O0):
<write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    $0x23,%edi
call   1030 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write>:
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %edi,%esi
mov    $0x23,%edi
jmp    1030 <syscall@plt>

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

LLVM IR (-O2):
define i32 @write(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @syscall(i32 35, i32 %0, i8* %1, i32 %2)
ret i32 %4
}
void putfloat(void) {}


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

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

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

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

/* Variables and functions */
void cast2_Good() {
  int32_t arr[4];
  *(((char *)arr) + 4) = 123;
}


x86 assembly (clang, -O0):
<cast2_Good>:
push   %rbp
mov    %rsp,%rbp
movb   $0x7b,-0xc(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @cast2_Good() {
%1 = alloca [4 x i32]
%2 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%3 = bitcast i32* %2 to i8*
%4 = getelementptr inbounds i8, i8* %3, i64 4
store i8 123, i8* %4
ret void
}

LLVM IR (-O2):
define void @cast2_Good() {
ret void
}
/* Type definitions */
struct statvfs {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ open_rdonly(char *);
int /*<<< orphan*/ statvfs(char *, struct statvfs *);
int execute_statvfs() {
  struct statvfs fileStat;
  close(open_rdonly("syscalls.txt"));
  statvfs("syscalls.txt", &fileStat);
  return 0;
}


x86 assembly (clang, -O0):
<execute_statvfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <open_rdonly@plt>
mov    %eax,%edi
call   1040 <close@plt>
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <statvfs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_statvfs>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rbx
mov    %rbx,%rdi
call   1030 <open_rdonly@plt>
mov    %eax,%edi
call   1040 <close@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <statvfs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statvfs = type { i32 }
@.str = [13 x i8] c"syscalls.txt\00"
define i32 @execute_statvfs() {
%1 = alloca %struct.statvfs
%2 = call i32 @open_rdonly(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @close(i32 %2)
%4 = call i32 @statvfs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %1)
ret i32 0
}

LLVM IR (-O2):
%struct.statvfs = type { i32 }
@.str = [13 x i8] c"syscalls.txt\00"
define i32 @execute_statvfs() {
%1 = alloca %struct.statvfs
%2 = bitcast %struct.statvfs* %1 to i8*
%3 = tail call i32 @open_rdonly(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @close(i32 %3)
%5 = call i32 @statvfs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %1)
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ be16toh(int /*<<< orphan*/);
uint16_t jet_be16toh(uint16_t big_endian_16bits) {
  return be16toh(big_endian_16bits);
}


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

x86 assembly (clang, -O2):
<jet_be16toh>:
jmp    1030 <be16toh@plt>

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

LLVM IR (-O2):
define i32 @jet_be16toh(i32 %0) {
%2 = tail call i32 @be16toh(i32 %0)
ret i32 %2
}
int aft_gsm_get_uart_baud_rate(int reg) {
  reg &= (0x7 << 0x8);
  return (reg >> 0x8);
}


x86 assembly (clang, -O0):
<aft_gsm_get_uart_baud_rate>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x700,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<aft_gsm_get_uart_baud_rate>:
mov    %edi,%eax
shr    $0x8,%eax
and    $0x7,%eax
ret

LLVM IR (-O0):
define i32 @aft_gsm_get_uart_baud_rate(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 1792
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = ashr i32 %5, 8
ret i32 %6
}

LLVM IR (-O2):
define i32 @aft_gsm_get_uart_baud_rate(i32 %0) {
%2 = lshr i32 %0, 8
%3 = and i32 %2, 7
ret i32 %3
}