xunge/DecIR huggingface dataset:
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int write_var_len(long, int /*<<< orphan*/ *);
int delta_time(double beat, int nticks, FILE *fp) {
  double dval = beat * nticks;
  long val = (long)dval;
  return write_var_len(val, fp);
}


x86 assembly (clang, -O0):
<delta_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <write_var_len@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delta_time>:
cvtsi2sd %edi,%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
jmp    1030 <write_var_len@plt>

LLVM IR (-O0):
define i32 @delta_time(double %0, i32 %1, i32* %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32*
%7 = alloca double
%8 = alloca i64
store double %0, double* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load double, double* %4
%10 = load i32, i32* %5
%11 = sitofp i32 %10 to double
%12 = fmul double %9, %11
store double %12, double* %7
%13 = load double, double* %7
%14 = fptosi double %13 to i64
store i64 %14, i64* %8
%15 = load i64, i64* %8
%16 = load i32*, i32** %6
%17 = call i32 @write_var_len(i64 %15, i32* %16)
ret i32 %17
}

LLVM IR (-O2):
define i32 @delta_time(double %0, i32 %1, i32* %2) {
%4 = sitofp i32 %1 to double
%5 = fmul double %4, %0
%6 = fptosi double %5 to i64
%7 = tail call i32 @write_var_len(i64 %6, i32* %2)
ret i32 %7
}
/* Type definitions */
struct timer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ myusleep(long);
void usleep_since_timer_start(struct timer *t, long usec) { myusleep(usec); }


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

x86 assembly (clang, -O2):
<usleep_since_timer_start>:
mov    %rsi,%rdi
jmp    1030 <myusleep@plt>

LLVM IR (-O0):
%struct.timer = type { i32 }
define void @usleep_since_timer_start(%struct.timer* %0, i64 %1) {
%3 = alloca %struct.timer*
%4 = alloca i64
store %struct.timer* %0, %struct.timer** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = call i32 @myusleep(i64 %5)
ret void
}

LLVM IR (-O2):
%struct.timer = type { i32 }
define void @usleep_since_timer_start(%struct.timer* nocapture readnone %0, i64 %1) {
%3 = tail call i32 @myusleep(i64 %1)
ret void
}
/* Variables and functions */
scalar_t__ testcase();
int main(void) {
  int x;
  x = testcase() ? 1 : 0;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <testcase@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i64 (...) @testcase()
%4 = icmp ne i64 %3, 0
%5 = zext i1 %4 to i64
%6 = select i1 %4, i32 1, i32 0
store i32 %6, i32* %2
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @testcase()
ret i32 0
}
/* Variables and functions */
size_t ft_strlen(const char *s) {
  int i;
  i = 0;
  while (s && s[i] != '\0')
    i++;
  return (i);
}


x86 assembly (clang, -O0):
<ft_strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1134 <ft_strlen+0x34>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1144 <ft_strlen+0x44>
jmp    1152 <ft_strlen+0x52>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <ft_strlen+0xf>
movslq -0xc(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_strlen>:
test   %rdi,%rdi
je     111e <ft_strlen+0x1e>
mov    $0xffffffffffffffff,%rax
nopl   0x0(%rax)
cmpb   $0x0,0x1(%rdi,%rax,1)
lea    0x1(%rax),%rax
jne    1110 <ft_strlen+0x10>
mov    %eax,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i64 @ft_strlen(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1, %3
%4 = phi i64 [ %8, %3 ], [ 0, %1 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = add nuw i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = and i64 %4, 4294967295
br label %11
11: ; preds = %9, %1
%12 = phi i64 [ 0, %1 ], [ %10, %9 ]
ret i64 %12
}
void *user_ptr(void *block) { return ((char *)block) + (0); }


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

x86 assembly (clang, -O2):
<user_ptr>:
mov    %rdi,%rax
ret

LLVM IR (-O0):
define i8* @user_ptr(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
ret i8* %4
}

LLVM IR (-O2):
define i8* @user_ptr(i8* readnone returned %0) {
ret i8* %0
}
const char *version_get_revision() { return ""; }


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

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

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @version_get_revision() {
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @version_get_revision() {
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}
/* Variables and functions */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main() {
  char ch_key;
  while (1) {
    ch_key = getchar();
    if (EOF == ch_key) {
      printf("exit");
      break;
    } else {
      putchar(ch_key);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
mov    0x2e98(%rip),%rax
movsbl (%rax),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    1170 <main+0x40>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
jmp    117e <main+0x4e>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea9(%rip),%rbx
cmp    %al,(%rbx)
je     1163 <main+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %al,(%rbx)
jne    1150 <main+0x20>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %0, %15
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = load i8, i8* @EOF
%6 = sext i8 %5 to i32
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %6, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %16
12: ; preds = %3
%13 = load i8, i8* %2
%14 = call i32 @putchar(i8 signext %13)
br label %15
15: ; preds = %12
br label %3
16: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [5 x i8] c"exit\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %2, %1
br i1 %3, label %4, label %6
4: ; preds = %6, %0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i32 0
6: ; preds = %0, %6
%7 = phi i8 [ %9, %6 ], [ %1, %0 ]
%8 = tail call i32 @putchar(i8 signext %7)
%9 = tail call signext i8 (...) @getchar()
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %10, %9
br i1 %11, label %4, label %6
}
int is_hex_digit(ch)
int ch;
{
  if (isdigit(ch))
    return (1);
  switch (clower(ch)) {
  case 'a':
  case 'b':
  case 'c':
  case 'd':
  case 'e':
  case 'f':
    return (1);
  default:
    return (0);
  }
}


x86 assembly (clang, -O0):
<is_hex_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1148 <is_hex_digit+0x28>
movl   $0x1,-0x4(%rbp)
jmp    1176 <is_hex_digit+0x56>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
call   1040 <clower@plt>
add    $0xffffff9f,%eax
sub    $0x5,%eax
ja     116f <is_hex_digit+0x4f>
jmp    1163 <is_hex_digit+0x43>
movl   $0x1,-0x4(%rbp)
jmp    1176 <is_hex_digit+0x56>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_hex_digit>:
lea    -0x30(%rdi),%ecx
mov    $0x1,%eax
cmp    $0xa,%ecx
jb     1136 <is_hex_digit+0x26>
push   %rax
xor    %eax,%eax
call   1030 <clower@plt>
mov    %eax,%ecx
add    $0xffffff9f,%ecx
xor    %eax,%eax
cmp    $0x6,%ecx
setb   %al
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @is_hex_digit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @isdigit(i32 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %2
br label %13
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 (i32, ...) bitcast (i32 (...)* @clower to i32 (i32, ...)*)(i32 %9)
switch i32 %10, label %12 [
i32 97, label %11
i32 98, label %11
i32 99, label %11
i32 100, label %11
i32 101, label %11
i32 102, label %11
]
11: ; preds = %8, %8, %8, %8, %8, %8
store i32 1, i32* %2
br label %13
12: ; preds = %8
store i32 0, i32* %2
br label %13
13: ; preds = %12, %11, %7
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
define i32 @is_hex_digit(i32 %0) {
%2 = add i32 %0, -48
%3 = icmp ult i32 %2, 10
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @clower to i32 (i32, ...)*)(i32 %0)
%6 = add i32 %5, -97
%7 = icmp ult i32 %6, 6
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %4, %1
%10 = phi i32 [ 1, %1 ], [ %8, %4 ]
ret i32 %10
}
/* Variables and functions */
int max(int, int);
int gb(int x) { return (x > 9) ? max(gb(x / 10), (x % 10) + 1) : x + 1; }


x86 assembly (clang, -O0):
<gb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x9,-0x4(%rbp)
jle    1166 <gb+0x46>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <gb@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
call   1030 <max@plt>
mov    %eax,-0x8(%rbp)
jmp    116f <gb+0x4f>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gb>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
cmp    $0xa,%edi
jl     115f <gb+0x3f>
mov    %r14d,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
call   1040 <gb@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ecx
neg    %ecx
lea    (%r14,%rcx,1),%esi
add    $0x1,%esi
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <max@plt>
add    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @gb(i32 %0) {
%2 = icmp sgt i32 %0, 9
br i1 %2, label %5, label %11
3: ; preds = %11, %5
%4 = phi i32 [ %10, %5 ], [ %12, %11 ]
ret i32 %4
5: ; preds = %1
%6 = udiv i32 %0, 10
%7 = tail call i32 @gb(i32 %6)
%8 = urem i32 %0, 10
%9 = add nuw nsw i32 %8, 1
%10 = tail call i32 @max(i32 %7, i32 %9)
br label %3
11: ; preds = %1
%12 = add nsw i32 %0, 1
br label %3
}
void alarm_handler(int sig) {}


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

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

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

LLVM IR (-O2):
define void @alarm_handler(i32 %0) {
ret void
}
/* Variables and functions */
scalar_t__ flock;
int main(int argc, char **argv) {
  void *p;
  (void)argc;
  (void)argv;
  p = (void *)(flock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@flock = global i64 0
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 i32, i32* %4
%8 = load i8**, i8*** %5
%9 = load i64, i64* @flock
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
ret i32 0
}

LLVM IR (-O2):
@flock = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
ret i32 0
}
double vde_forw_pendulum_sign(double x) { return x < 0 ? -1 : x > 0 ? 1 : x; }


x86 assembly (clang, -O0):
<vde_forw_pendulum_sign>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1129 <vde_forw_pendulum_sign+0x29>
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1161 <vde_forw_pendulum_sign+0x61>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    114d <vde_forw_pendulum_sign+0x4d>
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1157 <vde_forw_pendulum_sign+0x57>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<vde_forw_pendulum_sign>:
xorpd  %xmm1,%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm0,%xmm2
movsd  0xeeb(%rip),%xmm3
andpd  %xmm2,%xmm3
andnpd %xmm0,%xmm2
orpd   %xmm3,%xmm2
cmpltsd %xmm1,%xmm0
movapd %xmm0,%xmm1
andnpd %xmm2,%xmm1
movsd  0xed2(%rip),%xmm2
andpd  %xmm2,%xmm0
orpd   %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @vde_forw_pendulum_sign(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %5, label %6
5: ; preds = %1
br label %14
6: ; preds = %1
%7 = load double, double* %2
%8 = fcmp ogt double %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %6
br label %12
10: ; preds = %6
%11 = load double, double* %2
br label %12
12: ; preds = %10, %9
%13 = phi double [ 1.000000e+00, %9 ], [ %11, %10 ]
br label %14
14: ; preds = %12, %5
%15 = phi double [ -1.000000e+00, %5 ], [ %13, %12 ]
ret double %15
}

LLVM IR (-O2):
define double @vde_forw_pendulum_sign(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fcmp ogt double %0, 0.000000e+00
%4 = select i1 %3, double 1.000000e+00, double %0
%5 = select i1 %2, double -1.000000e+00, double %4
ret double %5
}
int pivot(int arr[], int i, int j) { return j; }


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

x86 assembly (clang, -O2):
<pivot>:
mov    %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @pivot(i32* nocapture readnone %0, i32 %1, i32 returned %2) {
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ f1(int **);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int *p;
  f1(&p);
  printf("set heap\n");
  *p = 4;
  printf("the heap %d\n", *p);
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <f1@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
call   1060 <f1@plt>
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
movl   $0x4,(%rax)
lea    0xe9a(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [13 x i8] c"the heap %d\0A\00"
@str = [9 x i8] c"set heap\00"
define i32 @main() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
%3 = call i32 @f1(i32** %1)
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%5 = load i32*, i32** %1
store i32 4, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 4)
%7 = load i32*, i32** %1
%8 = call i32 @free(i32* %7)
ret i32 0
}
void toggleCollection() { __asm__ __volatile__("fnop"); }


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

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

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

LLVM IR (-O2):
define void @toggleCollection() {
tail call void asm sideeffect "fnop", "~{dirflag},~{fpsr},~{flags}"()
ret void
}
void foo308(int p) {}


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

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

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

LLVM IR (-O2):
define void @foo308(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ console_tx_hex8(unsigned char);
void print_spew_hex8(unsigned char value) { console_tx_hex8(value); }


x86 assembly (clang, -O0):
<print_spew_hex8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <console_tx_hex8@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_spew_hex8>:
jmp    1030 <console_tx_hex8@plt>

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

LLVM IR (-O2):
define void @print_spew_hex8(i8 zeroext %0) {
%2 = tail call i32 @console_tx_hex8(i8 zeroext %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ find(char *);
void find_noindex_medium_test() {
  find("benchmarks"
       ".single.medium");
}


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

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

LLVM IR (-O0):
@.str = [25 x i8] c"benchmarks.single.medium\00"
define void @find_noindex_medium_test() {
%1 = call i32 @find(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"benchmarks.single.medium\00"
define void @find_noindex_medium_test() {
%1 = tail call i32 @find(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
ret void
}
int isum1(int a, int b) { return a + b; }


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

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

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

LLVM IR (-O2):
define i32 @isum1(i32 %0, i32 %1) {
%3 = add nsw i32 %1, %0
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ setup();
int /*<<< orphan*/ testAddSub();
int /*<<< orphan*/ testDiv();
int /*<<< orphan*/ testDiv2();
int /*<<< orphan*/ testEcc();
int /*<<< orphan*/ testInverse();
int /*<<< orphan*/ testMul();
int /*<<< orphan*/ testSanity();
int main(void) {
  setup();
  testSanity();
  testAddSub();
  testMul();
  testDiv2();
  testDiv();
  testInverse();
  testEcc();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   10a0 <setup@plt>
mov    $0x0,%al
call   1050 <testSanity@plt>
mov    $0x0,%al
call   1060 <testAddSub@plt>
mov    $0x0,%al
call   1040 <testMul@plt>
mov    $0x0,%al
call   1090 <testDiv2@plt>
mov    $0x0,%al
call   1030 <testDiv@plt>
mov    $0x0,%al
call   1070 <testInverse@plt>
mov    $0x0,%al
call   1080 <testEcc@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   10a0 <setup@plt>
xor    %eax,%eax
call   1050 <testSanity@plt>
xor    %eax,%eax
call   1060 <testAddSub@plt>
xor    %eax,%eax
call   1040 <testMul@plt>
xor    %eax,%eax
call   1090 <testDiv2@plt>
xor    %eax,%eax
call   1030 <testDiv@plt>
xor    %eax,%eax
call   1070 <testInverse@plt>
xor    %eax,%eax
call   1080 <testEcc@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = call i32 (...) @setup()
%2 = call i32 (...) @testSanity()
%3 = call i32 (...) @testAddSub()
%4 = call i32 (...) @testMul()
%5 = call i32 (...) @testDiv2()
%6 = call i32 (...) @testDiv()
%7 = call i32 (...) @testInverse()
%8 = call i32 (...) @testEcc()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @setup()
%2 = tail call i32 (...) @testSanity()
%3 = tail call i32 (...) @testAddSub()
%4 = tail call i32 (...) @testMul()
%5 = tail call i32 (...) @testDiv2()
%6 = tail call i32 (...) @testDiv()
%7 = tail call i32 (...) @testInverse()
%8 = tail call i32 (...) @testEcc()
ret i32 0
}
/* Type definitions */
struct sembuf {
  int dummy;
};

/* Variables and functions */
int semop(int, struct sembuf *, int);
int applySemaphoreOperation(int semaphoreId, struct sembuf *operations) {
  return semop(semaphoreId, operations, 1);
}


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

x86 assembly (clang, -O2):
<applySemaphoreOperation>:
mov    $0x1,%edx
jmp    1030 <semop@plt>

LLVM IR (-O0):
%struct.sembuf = type { i32 }
define i32 @applySemaphoreOperation(i32 %0, %struct.sembuf* %1) {
%3 = alloca i32
%4 = alloca %struct.sembuf*
store i32 %0, i32* %3
store %struct.sembuf* %1, %struct.sembuf** %4
%5 = load i32, i32* %3
%6 = load %struct.sembuf*, %struct.sembuf** %4
%7 = call i32 @semop(i32 %5, %struct.sembuf* %6, i32 1)
ret i32 %7
}

LLVM IR (-O2):
%struct.sembuf = type { i32 }
define i32 @applySemaphoreOperation(i32 %0, %struct.sembuf* %1) {
%3 = tail call i32 @semop(i32 %0, %struct.sembuf* %1, i32 1)
ret i32 %3
}
/* Variables and functions */
int rand_num(int);
int rand_dir() {
  switch (rand_num(4)) {
  case 0:
    return '{';
  case 1:
    return '}';
  case 2:
    return '!';
  case 3:
    return 'i';
  }
  return (-1);
}


x86 assembly (clang, -O0):
<rand_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1030 <rand_num@plt>
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1175 <rand_dir+0x65>
mov    -0x10(%rbp),%rax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x7b,-0x4(%rbp)
jmp    117c <rand_dir+0x6c>
movl   $0x7d,-0x4(%rbp)
jmp    117c <rand_dir+0x6c>
movl   $0x21,-0x4(%rbp)
jmp    117c <rand_dir+0x6c>
movl   $0x69,-0x4(%rbp)
jmp    117c <rand_dir+0x6c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_dir>:
push   %rax
mov    $0x4,%edi
call   1030 <rand_num@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x3,%ecx
ja     1134 <rand_dir+0x24>
movslq %ecx,%rax
lea    0xecf(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @rand_dir() {
%1 = alloca i32
%2 = call i32 @rand_num(i32 4)
switch i32 %2, label %7 [
i32 0, label %3
i32 1, label %4
i32 2, label %5
i32 3, label %6
]
3: ; preds = %0
store i32 123, i32* %1
br label %8
4: ; preds = %0
store i32 125, i32* %1
br label %8
5: ; preds = %0
store i32 33, i32* %1
br label %8
6: ; preds = %0
store i32 105, i32* %1
br label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %8
8: ; preds = %7, %6, %5, %4, %3
%9 = load i32, i32* %1
ret i32 %9
}

LLVM IR (-O2):
@switch.table.rand_dir = [4 x i32] [i32 123, i32 125, i32 33, i32 105]
define i32 @rand_dir() {
%1 = tail call i32 @rand_num(i32 4)
%2 = icmp ult i32 %1, 4
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.rand_dir, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %0, %3
%8 = phi i32 [ %6, %3 ], [ -1, %0 ]
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ DAY_2;
char *nl_langinfo(int /*<<< orphan*/);
char *langinfo_day_2() { return nl_langinfo(DAY_2); }


x86 assembly (clang, -O0):
<langinfo_day_2>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ecd(%rip),%rax
mov    (%rax),%edi
call   1030 <nl_langinfo@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<langinfo_day_2>:
mov    0x2ed1(%rip),%rax
mov    (%rax),%edi
jmp    1030 <nl_langinfo@plt>

LLVM IR (-O0):
@DAY_2 = global i32 0
define i8* @langinfo_day_2() {
%1 = load i32, i32* @DAY_2
%2 = call i8* @nl_langinfo(i32 %1)
ret i8* %2
}

LLVM IR (-O2):
@DAY_2 = global i32 0
define i8* @langinfo_day_2() {
%1 = load i32, i32* @DAY_2
%2 = tail call i8* @nl_langinfo(i32 %1)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
extern void putint(int x) { printf("%d\n", x); }


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

x86 assembly (clang, -O2):
<putint>:
mov    %edi,%esi
lea    0xee7(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @putint(i32 %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ parse(long, int *, int *, int *);
int get_pyear(long day) {
  int y, m, d;
  parse(day, &y, &m, &d);
  return y;
}


x86 assembly (clang, -O0):
<get_pyear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1030 <parse@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pyear>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1030 <parse@plt>
mov    0xc(%rsp),%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define i32 @get_pyear(i64 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @parse(i64 %0, i32* %2, i32* %3, i32* %4)
%9 = load i32, i32* %2
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ do_not_optimize_away();
scalar_t__ errno;
void *malloc(int);
int main() {
  void *p;
  errno = 0;
  p = malloc(-1);
  if (errno != 0)
    do_not_optimize_away();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaa(%rip),%rax
movq   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e8e(%rip),%rax
cmpq   $0x0,(%rax)
je     1163 <main+0x43>
mov    $0x0,%al
call   1040 <do_not_optimize_away@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    0x2ed9(%rip),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
ret

LLVM IR (-O0):
@errno = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i64 0, i64* @errno
%3 = call i8* @malloc(i32 -1)
store i8* %3, i8** %2
%4 = load i64, i64* @errno
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (...) @do_not_optimize_away()
br label %8
8: ; preds = %6, %0
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
define i32 @main() {
store i64 0, i64* @errno
ret i32 0
}
/* Variables and functions */
int yahoo_M1ObfuscatedTableCommon(int, int, unsigned char *);
int yahoo_f01_4c(int Salt, int Parameter) {
  static unsigned char LUT[32] = {
      0x16, 0x02, 0x06, 0x0E, 0x0D, 0x1C, 0x08, 0x0A, 0x0F, 0x13, 0x0B,
      0x18, 0x07, 0x04, 0x14, 0x01, 0x1B, 0x05, 0x17, 0x1E, 0x11, 0x1A,
      0x10, 0x1F, 0x12, 0x19, 0x1D, 0x03, 0x0C, 0x00, 0x09, 0x15,
  };
  return yahoo_M1ObfuscatedTableCommon(Salt, Parameter, LUT);
}


x86 assembly (clang, -O0):
<yahoo_f01_4c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0x2f05(%rip),%rdx
call   1030 <yahoo_M1ObfuscatedTableCommon@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yahoo_f01_4c>:
lea    0x2f19(%rip),%rdx
jmp    1030 <yahoo_M1ObfuscatedTableCommon@plt>

LLVM IR (-O0):
@yahoo_f01_4c.LUT = internal global [32 x i8] c"\16\02\06\0E\0D\1C\08\0A\0F\13\0B\18\07\04\14\01\1B\05\17\1E\11\1A\10\1F\12\19\1D\03\0C\00\09\15"
define i32 @yahoo_f01_4c(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = call i32 @yahoo_M1ObfuscatedTableCommon(i32 %5, i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @yahoo_f01_4c.LUT, i64 0, i64 0))
ret i32 %7
}

LLVM IR (-O2):
@yahoo_f01_4c.LUT = internal global [32 x i8] c"\16\02\06\0E\0D\1C\08\0A\0F\13\0B\18\07\04\14\01\1B\05\17\1E\11\1A\10\1F\12\19\1D\03\0C\00\09\15"
define i32 @yahoo_f01_4c(i32 %0, i32 %1) {
%3 = tail call i32 @yahoo_M1ObfuscatedTableCommon(i32 %0, i32 %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @yahoo_f01_4c.LUT, i64 0, i64 0))
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ print_stat();
void on_sigint(int arg) { print_stat(); }


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

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

LLVM IR (-O0):
define void @on_sigint(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @print_stat()
ret void
}

LLVM IR (-O2):
define void @on_sigint(i32 %0) {
%2 = tail call i32 (...) @print_stat()
ret void
}
void nseel_asm_above_end(void) {}


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

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

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

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

/* Variables and functions */
int /*<<< orphan*/ recv(int, void *, size_t, int /*<<< orphan*/);
ssize_t myread_swift_fwd(int fd, void *buf, size_t len) {
  return recv(fd, buf, len, 0);
}


x86 assembly (clang, -O0):
<myread_swift_fwd>:
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
call   1030 <recv@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myread_swift_fwd>:
xor    %ecx,%ecx
jmp    1030 <recv@plt>

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

LLVM IR (-O2):
define i32 @myread_swift_fwd(i32 %0, i8* %1, i64 %2) {
%4 = tail call i32 @recv(i32 %0, i8* %1, i64 %2, i32 0)
ret i32 %4
}
/* Type definitions */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ show_stat_info(char *, struct stat *);
int stat(char *, struct stat *);
extern void do_stat(char *filename) {
  struct stat stat_buf;
  if ((stat(filename, &stat_buf) == -1)) {
    perror(filename);
    exit(EXIT_FAILURE);
  } else {
    show_stat_info(filename, &stat_buf);
  }
}


x86 assembly (clang, -O0):
<do_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1179 <do_stat+0x39>
mov    -0x8(%rbp),%rdi
call   1050 <perror@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <show_stat_info@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_stat>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
je     116a <do_stat+0x2a>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <show_stat_info@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <perror@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
define void @do_stat(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @stat(i8* %4, %struct.stat* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @perror(i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @show_stat_info(i8* %13, %struct.stat* %3)
br label %15
15: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
define void @do_stat(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = tail call i32 @perror(i8* %0)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = call i32 @show_stat_info(i8* %0, %struct.stat* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ HAL_IncTick();
void SysTick_Handler(void) { HAL_IncTick(); }


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

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

LLVM IR (-O0):
define void @SysTick_Handler() {
%1 = call i32 (...) @HAL_IncTick()
ret void
}

LLVM IR (-O2):
define void @SysTick_Handler() {
%1 = tail call i32 (...) @HAL_IncTick()
ret void
}
int isPrefix(const char *s, const char *pref) {
  while (*pref) {
    if (*pref != *s)
      return 0;
    pref++;
    s++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isPrefix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1158 <isPrefix+0x58>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     113b <isPrefix+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    115f <isPrefix+0x5f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    110c <isPrefix+0xc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrefix>:
mov    (%rsi),%cl
mov    $0x1,%eax
test   %cl,%cl
je     1122 <isPrefix+0x22>
xor    %edx,%edx
nopl   (%rax)
cmp    (%rdi,%rdx,1),%cl
jne    1123 <isPrefix+0x23>
movzbl 0x1(%rsi,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1110 <isPrefix+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @isPrefix(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2, %11
%6 = phi i8 [ %14, %11 ], [ %3, %2 ]
%7 = phi i8* [ %12, %11 ], [ %1, %2 ]
%8 = phi i8* [ %13, %11 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %6, %9
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %11, %2
%17 = phi i32 [ 1, %2 ], [ 1, %11 ], [ 0, %5 ]
ret i32 %17
}
/* Type definitions */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
void bit_clear32(volatile uint32_t *ptr, uint8_t bit) { *ptr &= ~(1 << (bit)); }


x86 assembly (clang, -O0):
<bit_clear32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
xor    $0xffffffff,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    %edx,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_clear32>:
mov    %esi,%ecx
mov    $0xfffffffe,%eax
rol    %cl,%eax
and    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @bit_clear32(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = shl i32 1, %5
%7 = xor i32 %6, -1
%8 = load i32*, i32** %3
%9 = load volatile i32, i32* %8
%10 = and i32 %9, %7
store volatile i32 %10, i32* %8
ret void
}

LLVM IR (-O2):
define void @bit_clear32(i32* %0, i32 %1) {
%3 = shl nuw i32 1, %1
%4 = xor i32 %3, -1
%5 = load volatile i32, i32* %0
%6 = and i32 %5, %4
store volatile i32 %6, i32* %0
ret void
}
int item_index(unsigned short item) { return (31 - (item >> 11)) & 0x1f; }


x86 assembly (clang, -O0):
<item_index>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%ecx
sar    $0xb,%ecx
mov    $0x1f,%eax
sub    %ecx,%eax
and    $0x1f,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<item_index>:
mov    %edi,%eax
xor    $0xf800,%eax
shr    $0xb,%eax
ret

LLVM IR (-O0):
define i32 @item_index(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
%5 = ashr i32 %4, 11
%6 = sub nsw i32 31, %5
%7 = and i32 %6, 31
ret i32 %7
}

LLVM IR (-O2):
define i32 @item_index(i16 zeroext %0) {
%2 = xor i16 %0, -1
%3 = lshr i16 %2, 11
%4 = zext i16 %3 to i32
ret i32 %4
}
void OpenSSLDie(void) {}


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

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

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

LLVM IR (-O2):
define void @OpenSSLDie() {
ret void
}
int test_imm_39int64_lowword_mem(long long *val) {
  return ((*val) & (0x39 << 0)) ? -20 : -40;
}


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

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

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

LLVM IR (-O2):
define i32 @test_imm_39int64_lowword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 57
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int foo(int x, int y) {
  if (x)
    y = 0;
  if (y)
    goto lab;
  y = 0;
lab:
  return y;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     111b <foo+0x1b>
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     112a <foo+0x2a>
jmp    1131 <foo+0x31>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @foo(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 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
store i32 0, i32* %4
br label %8
8: ; preds = %7, %2
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %13
12: ; preds = %8
store i32 0, i32* %4
br label %13
13: ; preds = %12, %11
%14 = load i32, i32* %4
ret i32 %14
}

LLVM IR (-O2):
define i32 @foo(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = select i1 %3, i32 %1, i32 0
ret i32 %4
}
/* Variables and functions */
char *malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
size_t my_strnlen(char const *, size_t);
char *my_strndup(const char *s, size_t n) {
  size_t len = my_strnlen(s, n);
  char *ret = malloc(len + 1);
  if (ret) {
    memcpy(ret, s, len);
    ret[len] = '\0';
  }
  return ret;
}


x86 assembly (clang, -O0):
<my_strndup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <my_strnlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118a <my_strndup+0x5a>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strndup>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <my_strnlen@plt>
mov    %rax,%r15
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1164 <my_strndup+0x34>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <memcpy@plt>
movb   $0x0,(%rbx,%r15,1)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @my_strndup(i8* %0, i64 %1) {
%3 = tail call i64 @my_strnlen(i8* %0, i64 %1)
%4 = add i64 %3, 1
%5 = tail call i8* @malloc(i64 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @memcpy(i8* %5, i8* %0, i64 %3)
%9 = getelementptr inbounds i8, i8* %5, i64 %3
store i8 0, i8* %9
br label %10
10: ; preds = %7, %2
ret i8* %5
}