xunge/DecIR huggingface dataset:
long mstime_to_unixtime(double d) {
  long ms_epoch = -2209161600;
  double one_day = 86400;
  long secs = d * one_day;
  long unix_time = ms_epoch + secs;
  return unix_time;
}


x86 assembly (clang, -O0):
<mstime_to_unixtime>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movabs $0xffffffff7c52de80,%rax
ff ff ff
mov    %rax,-0x10(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mstime_to_unixtime>:
mulsd  0xef8(%rip),%xmm0
cvttsd2si %xmm0,%rcx
movabs $0xffffffff7c52de80,%rax
ff ff ff
add    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @mstime_to_unixtime(double %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca double
%5 = alloca i64
%6 = alloca i64
store double %0, double* %2
store i64 -2209161600, i64* %3
store double 8.640000e+04, double* %4
%7 = load double, double* %2
%8 = load double, double* %4
%9 = fmul double %7, %8
%10 = fptosi double %9 to i64
store i64 %10, i64* %5
%11 = load i64, i64* %3
%12 = load i64, i64* %5
%13 = add nsw i64 %11, %12
store i64 %13, i64* %6
%14 = load i64, i64* %6
ret i64 %14
}

LLVM IR (-O2):
define i64 @mstime_to_unixtime(double %0) {
%2 = fmul double %0, 8.640000e+04
%3 = fptosi double %2 to i64
%4 = add nsw i64 %3, -2209161600
ret i64 %4
}
/* Type definitions */
typedef int uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
uint32_t thumbcat(uint16_t first, uint16_t second) {
  return (((uint32_t)first) << 16) | ((uint32_t)second);
}


x86 assembly (clang, -O0):
<thumbcat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x10,%eax
mov    -0x10(%rbp),%rcx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<thumbcat>:
mov    %rsi,%rax
shl    $0x10,%edi
or     %edi,%eax
ret

LLVM IR (-O0):
define i32 @thumbcat(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 = trunc i64 %5 to i32
%7 = shl i32 %6, 16
%8 = load i64, i64* %4
%9 = trunc i64 %8 to i32
%10 = or i32 %7, %9
ret i32 %10
}

LLVM IR (-O2):
define i32 @thumbcat(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = shl i32 %3, 16
%5 = trunc i64 %1 to i32
%6 = or i32 %4, %5
ret i32 %6
}
void compute_add_sources_ac_s3_cuda_(long *Mesh_pointer, int *phase_is_innerf,
                                     int *NSOURCESf,
                                     double *h_stf_pre_compute) {}


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

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

LLVM IR (-O0):
define void @compute_add_sources_ac_s3_cuda_(i64* %0, i32* %1, i32* %2, double* %3) {
%5 = alloca i64*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
store i64* %0, i64** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store double* %3, double** %8
ret void
}

LLVM IR (-O2):
define void @compute_add_sources_ac_s3_cuda_(i64* nocapture %0, i32* nocapture %1, i32* nocapture %2, double* nocapture %3) {
ret void
}
double do_fprem(void) {
  double res = 0.0;
  __asm__ __volatile__("ffree %%st(0)\n\t"
                       "ffree %%st(1)\n\t"
                       "fldpi\n\t"
                       "fldln2\n\t"
                       "fprem\n\t"
                       "fstpl 0(%0)"
                       :
                       : "r"(&res));
  return res;
}


x86 assembly (clang, -O0):
<do_fprem>:
push   %rbp
mov    %rsp,%rbp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
lea    -0x8(%rbp),%rax
ffree  %st(0)
ffree  %st(1)
fldpi
fldln2
fprem
fstpl  (%rax)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_fprem>:
movq   $0x0,-0x8(%rsp)
lea    -0x8(%rsp),%rax
ffree  %st(0)
ffree  %st(1)
fldpi
fldln2
fprem
fstpl  (%rax)
movsd  -0x8(%rsp),%xmm0
ret

LLVM IR (-O0):
define double @do_fprem() {
%1 = alloca double
store double 0.000000e+00, double* %1
%2 = load double, double* %1
ret double %2
}

LLVM IR (-O2):
define double @do_fprem() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = load double, double* %1
ret double %3
}
void tegra_dvfs_rail_enable(struct dvfs_rail *rail) { return; }


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

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

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

LLVM IR (-O2):
%struct.dvfs_rail = type opaque
define void @tegra_dvfs_rail_enable(%struct.dvfs_rail* nocapture %0) {
ret void
}
/* Variables and functions */
long long fun_stub_base_ll_stub(int);
int /*<<< orphan*/ printf(char *, long long);
long long fun_stub_base_ll_call(int a) {
  printf("fun_stub_base_v_call:a = %d \n", a);
  long long x = fun_stub_base_ll_stub(a);
  printf("fun_stub_base_v_stub return %lld\n", x);
  return x;
}


x86 assembly (clang, -O0):
<fun_stub_base_ll_call>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rsi
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <fun_stub_base_ll_stub@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun_stub_base_ll_call>:
push   %rbx
movslq %edi,%rbx
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1040 <fun_stub_base_ll_stub@plt>
mov    %rax,%rbx
lea    0xeda(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"fun_stub_base_v_call:a = %d \0A\00"
@.str.1 = [34 x i8] c"fun_stub_base_v_stub return %lld\0A\00"
define i64 @fun_stub_base_ll_call(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %5)
%7 = load i32, i32* %2
%8 = call i64 @fun_stub_base_ll_stub(i32 %7)
store i64 %8, i64* %3
%9 = load i64, i64* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %3
ret i64 %11
}

LLVM IR (-O2):
@.str = [30 x i8] c"fun_stub_base_v_call:a = %d \0A\00"
@.str.1 = [34 x i8] c"fun_stub_base_v_stub return %lld\0A\00"
define i64 @fun_stub_base_ll_call(i32 %0) {
%2 = sext i32 %0 to i64
%3 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %2)
%4 = tail call i64 @fun_stub_base_ll_stub(i32 %0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %4)
ret i64 %4
}
/* Type definitions */
typedef int uint32_t;
struct timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
uint32_t calc_ms(struct timespec before, struct timespec after) {
  return (after.tv_sec - before.tv_sec) * 1000 +
         (after.tv_nsec - before.tv_nsec) / 1000000;
}


x86 assembly (clang, -O0):
<calc_ms>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
imul   $0x3e8,%eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_ms>:
mov    %rsi,%rax
sub    %edi,%esi
shr    $0x20,%rdi
shr    $0x20,%rax
imul   $0x3e8,%esi,%ecx
sub    %edi,%eax
cltq
imul   $0x431bde83,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rax
add    %edx,%eax
add    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @calc_ms(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = lshr i64 %0, 32
%5 = trunc i64 %4 to i32
%6 = trunc i64 %1 to i32
%7 = lshr i64 %1, 32
%8 = trunc i64 %7 to i32
%9 = sub nsw i32 %6, %3
%10 = mul nsw i32 %9, 1000
%11 = sub nsw i32 %8, %5
%12 = sdiv i32 %11, 1000000
%13 = add nsw i32 %12, %10
ret i32 %13
}
/* Variables and functions */
unsigned int stb_hashptr(void *);
unsigned int stb_rehash_improved(unsigned int v) {
  return stb_hashptr((void *)(size_t)v);
}


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

x86 assembly (clang, -O2):
<stb_rehash_improved>:
mov    %edi,%edi
jmp    1030 <stb_hashptr@plt>

LLVM IR (-O0):
define i32 @stb_rehash_improved(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = zext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = call i32 @stb_hashptr(i8* %5)
ret i32 %6
}

LLVM IR (-O2):
define i32 @stb_rehash_improved(i32 %0) {
%2 = zext i32 %0 to i64
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @stb_hashptr(i8* %3)
ret i32 %4
}
/* Type definitions */
struct stat {
  int /*<<< orphan*/ st_dev;
};
typedef int /*<<< orphan*/ dev_t;

/* Variables and functions */
int errno;
scalar_t__ fstat(int, struct stat *);
int /*<<< orphan*/ perror(char *);
dev_t get_dev_no_by_fd(int fd) {
  int err = 0;
  struct stat _stat;
  dev_t dev_no = 0;
  if (0 != fstat(fd, &_stat)) {
    err = errno;
    perror("fstat:");
  } else {
    dev_no = _stat.st_dev;
  }
  return dev_no;
}


x86 assembly (clang, -O0):
<get_dev_no_by_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <fstat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1170 <get_dev_no_by_fd+0x50>
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <perror@plt>
jmp    1176 <get_dev_no_by_fd+0x56>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dev_no_by_fd>:
push   %rax
mov    %rsp,%rsi
call   1040 <fstat@plt>
test   %rax,%rax
jne    1133 <get_dev_no_by_fd+0x13>
mov    (%rsp),%eax
pop    %rcx
ret
lea    0xec6(%rip),%rdi
call   1030 <perror@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@errno = global i32 0
@.str = [7 x i8] c"fstat:\00"
define i32 @get_dev_no_by_fd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.stat
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %5
%6 = load i32, i32* %2
%7 = call i64 @fstat(i32 %6, %struct.stat* %4)
%8 = icmp ne i64 0, %7
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @errno
store i32 %10, i32* %3
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %15
12: ; preds = %1
%13 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%14 = load i32, i32* %13
store i32 %14, i32* %5
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %5
ret i32 %16
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@errno = global i32 0
@.str = [7 x i8] c"fstat:\00"
define i32 @get_dev_no_by_fd(i32 %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @fstat(i32 %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ 0, %6 ], [ %10, %8 ]
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, void const *, uintptr_t);
char *memcpya(char *target, const void *source, uintptr_t ct) {
  memcpy(target, source, ct);
  return &(target[ct]);
}


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

x86 assembly (clang, -O2):
<memcpya>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1030 <memcpy@plt>
add    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @memcpya(i8* %0, i8* %1, i64 %2) {
%4 = tail call i32 @memcpy(i8* %0, i8* %1, i64 %2)
%5 = getelementptr inbounds i8, i8* %0, i64 %2
ret i8* %5
}
/* Variables and functions */
int /*<<< orphan*/ assert(int);
int main() {
  int x;
  int unknown;
  if (unknown) {
    x = 5;
  } else {
    x = 0;
  }
  assert(x > -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1135 <main+0x25>
movl   $0x5,-0x8(%rbp)
jmp    113c <main+0x2c>
movl   $0x0,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @assert(i32 1)
ret i32 0
}
/* Type definitions */
struct bmp_handle {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bmp_free(struct bmp_handle *);
void bmp_free_list(struct bmp_handle **bmp_list, size_t len) {
  size_t i;
  for (i = 0; i < len; i++) {
    bmp_free(bmp_list[i]);
  }
}


x86 assembly (clang, -O0):
<bmp_free_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1158 <bmp_free_list+0x48>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <bmp_free@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <bmp_free_list+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmp_free_list>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1142 <bmp_free_list+0x32>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   1030 <bmp_free@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <bmp_free_list+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.bmp_handle = type { i32 }
define void @bmp_free_list(%struct.bmp_handle** %0, i64 %1) {
%3 = alloca %struct.bmp_handle**
%4 = alloca i64
%5 = alloca i64
store %struct.bmp_handle** %0, %struct.bmp_handle*** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %16, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load %struct.bmp_handle**, %struct.bmp_handle*** %3
%12 = load i64, i64* %5
%13 = getelementptr inbounds %struct.bmp_handle*, %struct.bmp_handle** %11, i64 %12
%14 = load %struct.bmp_handle*, %struct.bmp_handle** %13
%15 = call i32 @bmp_free(%struct.bmp_handle* %14)
br label %16
16: ; preds = %10
%17 = load i64, i64* %5
%18 = add i64 %17, 1
store i64 %18, i64* %5
br label %6
19: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.bmp_handle = type { i32 }
define void @bmp_free_list(%struct.bmp_handle** nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %11, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %9, %4 ], [ 0, %2 ]
%6 = getelementptr inbounds %struct.bmp_handle*, %struct.bmp_handle** %0, i64 %5
%7 = load %struct.bmp_handle*, %struct.bmp_handle** %6
%8 = tail call i32 @bmp_free(%struct.bmp_handle* %7)
%9 = add nuw i64 %5, 1
%10 = icmp eq i64 %9, %1
br i1 %10, label %11, label %4
11: ; preds = %4, %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int askYesNo(char *question) {
  printf("%s (Y/N)\n> ", question);
  char choice[1];
  scanf("%s", choice);
  if ((choice[0] == 'y') || (choice[0] == 'Y')) {
    return 1;
  } else {
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<askYesNo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x11(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
je     1166 <askYesNo+0x46>
movsbl -0x11(%rbp),%eax
cmp    $0x59,%eax
jne    1172 <askYesNo+0x52>
movl   $0x1,-0x4(%rbp)
jmp    1179 <askYesNo+0x59>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askYesNo>:
push   %rax
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x7(%rsp),%cl
and    $0xdf,%cl
xor    %eax,%eax
cmp    $0x59,%cl
sete   %al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%s (Y/N)\0A> \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @askYesNo(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 121
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 89
br i1 %17, label %18, label %19
18: ; preds = %13, %1
store i32 1, i32* %2
br label %20
19: ; preds = %13
store i32 0, i32* %2
br label %20
20: ; preds = %19, %18
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s (Y/N)\0A> \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @askYesNo(i8* %0) {
%2 = alloca [1 x i8]
%3 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = load i8, i8* %4
%7 = and i8 %6, -33
%8 = icmp eq i8 %7, 89
%9 = zext i1 %8 to i32
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ GL_DEPTH_TEST;
int /*<<< orphan*/ glClearColor(float, float, float, float);
int /*<<< orphan*/ glDisable(int /*<<< orphan*/);
void glInit() {
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  glDisable(GL_DEPTH_TEST);
}


x86 assembly (clang, -O0):
<glInit>:
push   %rbp
mov    %rsp,%rbp
xorps  %xmm3,%xmm3
movaps %xmm3,%xmm0
movaps %xmm3,%xmm1
movaps %xmm3,%xmm2
call   1030 <glClearColor@plt>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
call   1040 <glDisable@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<glInit>:
push   %rax
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
xorps  %xmm3,%xmm3
call   1030 <glClearColor@plt>
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <glDisable@plt>

LLVM IR (-O0):
@GL_DEPTH_TEST = global i32 0
define void @glInit() {
%1 = call i32 @glClearColor(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
%2 = load i32, i32* @GL_DEPTH_TEST
%3 = call i32 @glDisable(i32 %2)
ret void
}

LLVM IR (-O2):
@GL_DEPTH_TEST = global i32 0
define void @glInit() {
%1 = tail call i32 @glClearColor(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
%2 = load i32, i32* @GL_DEPTH_TEST
%3 = tail call i32 @glDisable(i32 %2)
ret void
}
unsigned int ft_sqrt(unsigned int n) {
  unsigned long int res;
  res = 0;
  while (res * res < n)
    res++;
  if (n - (res - 1) * (res - 1) < n - res * res)
    return (res - 1);
  return ((unsigned int)res);
}


x86 assembly (clang, -O0):
<ft_sqrt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
cmp    %rcx,%rax
jae    1135 <ft_sqrt+0x35>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    110f <ft_sqrt+0xf>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
imul   %rdx,%rcx
sub    %rcx,%rax
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%rdx
imul   -0x10(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jae    1177 <ft_sqrt+0x77>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x4(%rbp)
jmp    117e <ft_sqrt+0x7e>
mov    -0x10(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_sqrt>:
mov    %edi,%edx
mov    $0xffffffffffffffff,%rcx
nopl   0x0(%rax)
add    $0x1,%rcx
mov    %rcx,%rsi
imul   %rcx,%rsi
cmp    %rdx,%rsi
jb     1110 <ft_sqrt+0x10>
lea    -0x1(%rcx),%rax
mov    %rax,%rdi
imul   %rax,%rdi
mov    %rdx,%r8
sub    %rdi,%r8
sub    %rsi,%rdx
cmp    %rdx,%r8
cmovae %ecx,%eax
ret

LLVM IR (-O0):
define i32 @ft_sqrt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
store i64 0, i64* %4
br label %5
5: ; preds = %12, %1
%6 = load i64, i64* %4
%7 = load i64, i64* %4
%8 = mul i64 %6, %7
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = icmp ult i64 %8, %10
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i64, i64* %4
%14 = add i64 %13, 1
store i64 %14, i64* %4
br label %5
15: ; preds = %5
%16 = load i32, i32* %3
%17 = zext i32 %16 to i64
%18 = load i64, i64* %4
%19 = sub i64 %18, 1
%20 = load i64, i64* %4
%21 = sub i64 %20, 1
%22 = mul i64 %19, %21
%23 = sub i64 %17, %22
%24 = load i32, i32* %3
%25 = zext i32 %24 to i64
%26 = load i64, i64* %4
%27 = load i64, i64* %4
%28 = mul i64 %26, %27
%29 = sub i64 %25, %28
%30 = icmp ult i64 %23, %29
br i1 %30, label %31, label %35
31: ; preds = %15
%32 = load i64, i64* %4
%33 = sub i64 %32, 1
%34 = trunc i64 %33 to i32
store i32 %34, i32* %2
br label %38
35: ; preds = %15
%36 = load i64, i64* %4
%37 = trunc i64 %36 to i32
store i32 %37, i32* %2
br label %38
38: ; preds = %35, %31
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
define i32 @ft_sqrt(i32 %0) {
%2 = zext i32 %0 to i64
br label %3
3: ; preds = %3, %1
%4 = phi i64 [ 0, %1 ], [ %7, %3 ]
%5 = mul i64 %4, %4
%6 = icmp ult i64 %5, %2
%7 = add i64 %4, 1
br i1 %6, label %3, label %8
8: ; preds = %3
%9 = add i64 %4, -1
%10 = mul i64 %9, %9
%11 = sub i64 %2, %10
%12 = sub i64 %2, %5
%13 = icmp ult i64 %11, %12
%14 = select i1 %13, i64 %9, i64 %4
%15 = trunc i64 %14 to i32
ret i32 %15
}
int _read(int file, char *ptr, int len) { return 0; }


x86 assembly (clang, -O0):
<_read>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @_read(i32 %0, i8* nocapture readnone %1, i32 %2) {
ret i32 0
}
int test_imm_D4uint64_lowword_mem(unsigned long long *val) {
  return ((*val) & (0xD4 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_D4uint64_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, 212
%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_D4uint64_lowword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 212
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
char have_usigned_instruction(char fcode) {
  if (fcode == 0x20 || fcode == 22) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<have_usigned_instruction>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x20,%eax
je     1124 <have_usigned_instruction+0x24>
movsbl -0x2(%rbp),%eax
cmp    $0x16,%eax
jne    112d <have_usigned_instruction+0x2d>
movb   $0x1,-0x1(%rbp)
jmp    1131 <have_usigned_instruction+0x31>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<have_usigned_instruction>:
cmp    $0x20,%dil
sete   %cl
cmp    $0x16,%dil
sete   %al
or     %cl,%al
ret

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

LLVM IR (-O2):
define signext i8 @have_usigned_instruction(i8 signext %0) {
%2 = icmp eq i8 %0, 32
%3 = icmp eq i8 %0, 22
%4 = or i1 %2, %3
%5 = zext i1 %4 to i8
ret i8 %5
}
void cut_music() {}


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

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

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

LLVM IR (-O2):
define void @cut_music() {
ret void
}
double mse_to_standard_mse(double mse) { return mse * 65536.0 / 6.0; }


x86 assembly (clang, -O0):
<mse_to_standard_mse>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef7(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xee2(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<mse_to_standard_mse>:
mulsd  0xef8(%rip),%xmm0
divsd  0xef8(%rip),%xmm0
ret

LLVM IR (-O0):
define double @mse_to_standard_mse(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fmul double %3, 6.553600e+04
%5 = fdiv double %4, 6.000000e+00
ret double %5
}

LLVM IR (-O2):
define double @mse_to_standard_mse(double %0) {
%2 = fmul double %0, 6.553600e+04
%3 = fdiv double %2, 6.000000e+00
ret double %3
}
int length(char s[]) {
  int i = 0;
  while (s[i] != '\0') {
    i++;
  }
  return i;
}


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

x86 assembly (clang, -O2):
<length>:
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x0,(%rdi)
lea    0x1(%rdi),%rdi
jne    1110 <length+0x10>
ret

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

LLVM IR (-O2):
define i32 @length(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = trunc i64 %3 to i32
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ mvprintw(int, int, char *, int);
void led_show(int n, bool on) {
  mvprintw(5, 59 + n * 5, on ? "(#%i)" : " -%i ", n + 1);
}


x86 assembly (clang, -O0):
<led_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
imul   $0x5,-0x4(%rbp),%esi
add    $0x3b,%esi
mov    -0x8(%rbp),%ecx
lea    0xed7(%rip),%rdx
lea    0xeca(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
mov    $0x5,%edi
call   1030 <mvprintw@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_show>:
lea    (%rdi,%rdi,4),%eax
add    $0x3b,%eax
test   %esi,%esi
lea    0xee7(%rip),%rcx
lea    0xeda(%rip),%rdx
cmove  %rcx,%rdx
lea    0x1(%rdi),%ecx
mov    $0x5,%edi
mov    %eax,%esi
jmp    1030 <mvprintw@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"(#%i)\00"
@.str.1 = [6 x i8] c" -%i \00"
define void @led_show(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 = mul nsw i32 %5, 5
%7 = add nsw i32 59, %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = call i32 @mvprintw(i32 5, i32 %7, i8* %11, i32 %13)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"(#%i)\00"
@.str.1 = [6 x i8] c" -%i \00"
define void @led_show(i32 %0, i32 %1) {
%3 = mul nsw i32 %0, 5
%4 = add nsw i32 %3, 59
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%7 = add nsw i32 %0, 1
%8 = tail call i32 @mvprintw(i32 5, i32 %4, i8* %6, i32 %7)
ret void
}
int test_imm_52int64_lowword_mem(long long *val) {
  return ((*val) & (0x52 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_52int64_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, 82
%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_52int64_lowword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 82
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int *malloc(int const);
int /*<<< orphan*/ printf(char *, int, int);
void test1() {
  const int COUNT = 3;
  int *users = malloc(COUNT);
  for (int i = 0; i < COUNT; i++) {
    users[i] = i * i;
    printf("%d:  %d\n", i, users[i]);
  }
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3,-0x4(%rbp)
mov    $0x3,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1188 <test1+0x68>
mov    -0x14(%rbp),%edx
imul   -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <test1+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rbx
mov    $0x3,%edi
call   1040 <malloc@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x4,%edx
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%d: %d\0A\00"
define void @test1() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 3, i32* %1
%4 = call i32* @malloc(i32 3)
store i32* %4, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %23, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = mul nsw i32 %9, %10
%12 = load i32*, i32** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 %11, i32* %15
%16 = load i32, i32* %3
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %21)
br label %23
23: ; preds = %8
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %5
26: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d: %d\0A\00"
define void @test1() {
%1 = tail call i32* @malloc(i32 3)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1, i32 1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2, i32 4)
ret void
}
void X509_issuer_and_serial_cmp(void) {}


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

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

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

LLVM IR (-O2):
define void @X509_issuer_and_serial_cmp() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void say_hello(char *s, int repeat) {
  int i;
  for (i = 0; i < repeat; i++) {
    printf("Hello, %s\n!", s);
  }
}


x86 assembly (clang, -O0):
<say_hello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1150 <say_hello+0x40>
mov    -0x8(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <say_hello+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<say_hello>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1140 <say_hello+0x30>
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xedb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    1130 <say_hello+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Hello, %s\0A!\00"
define void @say_hello(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %13, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
br label %6
16: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello, %s\0A!\00"
define void @say_hello(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %9
4: ; preds = %2, %4
%5 = phi i32 [ %7, %4 ], [ 0, %2 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, %1
br i1 %8, label %9, label %4
9: ; preds = %4, %2
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
void check_access(FILE *led_file, char *addr) {
  if (NULL == led_file) {
    printf("Error accessing file: %s\n\n"
           "Maybe no access rights?\n",
           addr);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_access>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
jne    1156 <check_access+0x36>
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_access>:
test   %rdi,%rdi
je     1126 <check_access+0x6>
ret
push   %rax
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Error accessing file: %s\0A\0AMaybe no access rights?\0A\00"
define void @check_access(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i32*, i32** %3
%6 = icmp eq i32* null, %5
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %2
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"Error accessing file: %s\0A\0AMaybe no access rights?\0A\00"
define void @check_access(i32* readnone %0, i8* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
ret void
}
/* Variables and functions */
scalar_t__ time(int /*<<< orphan*/ *);
void R_time(int *seconds) { *seconds = (int)time(NULL); }


x86 assembly (clang, -O0):
<R_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<R_time>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @R_time(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = load i32*, i32** %2
store i32 %4, i32* %5
ret void
}

LLVM IR (-O2):
define void @R_time(i32* nocapture writeonly %0) {
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
store i32 %3, i32* %0
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_rwlockattr_t;

/* Variables and functions */
int PTHREAD_PROCESS_PRIVATE;
int /*<<< orphan*/ printf(char *, ...);
int pthread_rwlockattr_getpshared(int /*<<< orphan*/ *, int *);
scalar_t__ pthread_rwlockattr_init(int /*<<< orphan*/ *);
int main(void) {
  pthread_rwlockattr_t rwla;
  int pshared;
  int rc = 0;
  printf("process-shared attribute is not available for testing\n");
  return 4;
  if (pthread_rwlockattr_init(&rwla) != 0) {
    printf("Error at pthread_rwlockattr_init()\n");
    return 2;
  }
  rc = pthread_rwlockattr_getpshared(&rwla, &pshared);
  if (rc != 0) {
    printf("Test FAILED: Error at pthread_rwlockattr_getpshared(): %d\n", rc);
    return 1;
  }
  if (pshared != PTHREAD_PROCESS_PRIVATE) {
    printf("Test FAILED: Incorrect default pshared value: %d\n", pshared);
    return 1;
  }
  printf("Test PASSED\n");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [55 x i8] c"process-shared attribute is not available for testing\0A\00"
@PTHREAD_PROCESS_PRIVATE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
ret i32 4
}

LLVM IR (-O2):
@PTHREAD_PROCESS_PRIVATE = global i32 0
@str = [54 x i8] c"process-shared attribute is not available for testing\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
ret i32 4
}
/* Variables and functions */
int /*<<< orphan*/ loop_write(int, char *, int, int);
void backspace_chars(int ttyfd, size_t p) {
  if (ttyfd < 0)
    return;
  while (p > 0) {
    p--;
    loop_write(ttyfd, "\b \b", 3, false);
  }
}


x86 assembly (clang, -O0):
<backspace_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    112e <backspace_chars+0x1e>
jmp    1165 <backspace_chars+0x55>
jmp    1133 <backspace_chars+0x23>
cmpq   $0x0,-0x10(%rbp)
jbe    1165 <backspace_chars+0x55>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    0xeac(%rip),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <loop_write@plt>
jmp    1133 <backspace_chars+0x23>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backspace_chars>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
js     1147 <backspace_chars+0x37>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1147 <backspace_chars+0x37>
mov    %edi,%ebp
lea    0xed7(%rip),%r14
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <loop_write@plt>
add    $0xffffffffffffffff,%rbx
jne    1130 <backspace_chars+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\08 \08\00"
define void @backspace_chars(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
br label %17
8: ; preds = %2
br label %9
9: ; preds = %12, %8
%10 = load i64, i64* %4
%11 = icmp ugt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i64, i64* %4
%14 = add i64 %13, -1
store i64 %14, i64* %4
%15 = load i32, i32* %3
%16 = call i32 @loop_write(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3, i32 0)
br label %9
17: ; preds = %7, %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\08 \08\00"
define void @backspace_chars(i32 %0, i64 %1) {
%3 = icmp sgt i32 %0, -1
%4 = icmp ne i64 %1, 0
%5 = and i1 %3, %4
br i1 %5, label %6, label %11
6: ; preds = %2, %6
%7 = phi i64 [ %8, %6 ], [ %1, %2 ]
%8 = add i64 %7, -1
%9 = tail call i32 @loop_write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3, i32 0)
%10 = icmp eq i64 %8, 0
br i1 %10, label %11, label %6
11: ; preds = %6, %2
ret void
}
void g_type_next_base() {}


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

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

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

LLVM IR (-O2):
define void @g_type_next_base() {
ret void
}
calcsb(dev, devfd, fs) char *dev;
int devfd;
struct fs *fs;
{
  return 0;
}


x86 assembly (clang, -O0):
<calcsb>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.fs = type opaque
define i32 @calcsb(i8* %0, i32 %1, %struct.fs* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.fs*
store i8* %0, i8** %4
store i32 %1, i32* %5
store %struct.fs* %2, %struct.fs** %6
ret i32 0
}

LLVM IR (-O2):
%struct.fs = type opaque
define i32 @calcsb(i8* nocapture readnone %0, i32 %1, %struct.fs* nocapture readnone %2) {
ret i32 0
}
unsigned int f84(unsigned int x, int y __attribute__((unused))) {
  return (x << 1) + (x >> (8 * 4 - 1));
}


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

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

LLVM IR (-O0):
define i32 @f84(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 = shl i32 %5, 1
%7 = load i32, i32* %3
%8 = lshr i32 %7, 31
%9 = add i32 %6, %8
ret i32 %9
}

LLVM IR (-O2):
define i32 @f84(i32 %0, i32 %1) {
%3 = tail call i32 @llvm.fshl.i32(i32 %0, i32 %0, i32 1)
ret i32 %3
}
int truncate(double x) { return (x - (int)x) < 0.75 ? (int)x : (int)(x + 1); }


x86 assembly (clang, -O0):
<truncate>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
cvttsd2si -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
subsd  %xmm0,%xmm1
movsd  0xedd(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    113a <truncate+0x3a>
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    114e <truncate+0x4e>
movsd  0xec6(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncate>:
cvttsd2si %xmm0,%ecx
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  0xee4(%rip),%xmm1
ucomisd %xmm2,%xmm1
addsd  0xee0(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmova  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @truncate(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = load double, double* %2
%5 = fptosi double %4 to i32
%6 = sitofp i32 %5 to double
%7 = fsub double %3, %6
%8 = fcmp olt double %7, 7.500000e-01
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load double, double* %2
%11 = fptosi double %10 to i32
br label %16
12: ; preds = %1
%13 = load double, double* %2
%14 = fadd double %13, 1.000000e+00
%15 = fptosi double %14 to i32
br label %16
16: ; preds = %12, %9
%17 = phi i32 [ %11, %9 ], [ %15, %12 ]
ret i32 %17
}

LLVM IR (-O2):
define i32 @truncate(double %0) {
%2 = fptosi double %0 to i32
%3 = sitofp i32 %2 to double
%4 = fsub double %0, %3
%5 = fcmp olt double %4, 7.500000e-01
%6 = fadd double %0, 1.000000e+00
%7 = fptosi double %6 to i32
%8 = select i1 %5, i32 %2, i32 %7
ret i32 %8
}
void reset_audiodev(void) {}


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

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

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

LLVM IR (-O2):
define void @reset_audiodev() {
ret void
}