xunge/DecIR huggingface dataset:
int even_one(unsigned x) { return !!(x & 0x55555555); }


x86 assembly (clang, -O0):
<even_one>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x55555555,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<even_one>:
xor    %eax,%eax
test   $0x55555555,%edi
setne  %al
ret

LLVM IR (-O0):
define i32 @even_one(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 1431655765
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
%7 = xor i1 %6, true
%8 = zext i1 %7 to i32
ret i32 %8
}

LLVM IR (-O2):
define i32 @even_one(i32 %0) {
%2 = and i32 %0, 1431655765
%3 = icmp ne i32 %2, 0
%4 = zext i1 %3 to i32
ret i32 %4
}
long testflag(long c) { return (0); }


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

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

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

LLVM IR (-O2):
define i64 @testflag(i64 %0) {
ret i64 0
}
/* Type definitions */
typedef int /*<<< orphan*/ __m256i;

/* Variables and functions */
int /*<<< orphan*/ _mm256_ror_epi32(int /*<<< orphan*/, int);
__attribute__((always_)) __m256i rot8_256(__m256i x) {
  return _mm256_ror_epi32(x, 8);
}


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

x86 assembly (clang, -O2):
<rot8_256>:
mov    $0x8,%esi
jmp    1030 <_mm256_ror_epi32@plt>

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

LLVM IR (-O2):
define i32 @rot8_256(i32 %0) {
%2 = tail call i32 @_mm256_ror_epi32(i32 %0, i32 8)
ret i32 %2
}
/* Variables and functions */
int _f(int, int /*<<< orphan*/, double const, double const *);
double _I_12(const double omega, const double vertices_omegas[4]) {
  return _f(2, 0, omega, vertices_omegas) / 3;
}


x86 assembly (clang, -O0):
<_I_12>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <_f@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_I_12>:
push   %rax
mov    %rdi,%rdx
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <_f@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @_I_12(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
store double %0, double* %3
store double* %1, double** %4
%5 = load double, double* %3
%6 = load double*, double** %4
%7 = call i32 @_f(i32 2, i32 0, double %5, double* %6)
%8 = sdiv i32 %7, 3
%9 = sitofp i32 %8 to double
ret double %9
}

LLVM IR (-O2):
define double @_I_12(double %0, double* %1) {
%3 = tail call i32 @_f(i32 2, i32 0, double %0, double* %1)
%4 = sdiv i32 %3, 3
%5 = sitofp i32 %4 to double
ret double %5
}
/* Type definitions */
struct compile_state {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *cgdebug_fp(struct compile_state *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
void cgdebug_flush(struct compile_state *state) {
  FILE *fp;
  fp = cgdebug_fp(state);
  if (fp) {
    fflush(fp);
  }
}


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

x86 assembly (clang, -O2):
<cgdebug_flush>:
push   %rax
call   1040 <cgdebug_fp@plt>
test   %rax,%rax
je     1134 <cgdebug_flush+0x14>
mov    %rax,%rdi
pop    %rax
jmp    1030 <fflush@plt>
pop    %rax
ret

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

LLVM IR (-O2):
%struct.compile_state = type { i32 }
define void @cgdebug_flush(%struct.compile_state* %0) {
%2 = tail call i32* @cgdebug_fp(%struct.compile_state* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @fflush(i32* %2)
br label %6
6: ; preds = %4, %1
ret void
}
void ignoreit(int sig) { ; }


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

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

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

LLVM IR (-O2):
define void @ignoreit(i32 %0) {
ret void
}
void scale_v3f(float scalar, float *x) {
  x[0] *= scalar;
  x[1] *= scalar;
  x[2] *= scalar;
}


x86 assembly (clang, -O0):
<scale_v3f>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
movss  %xmm0,0x4(%rax)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x8(%rax),%xmm0
movss  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_v3f>:
movss  (%rdi),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rdi)
movss  0x4(%rdi),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rdi)
mulss  0x8(%rdi),%xmm0
movss  %xmm0,0x8(%rdi)
ret

LLVM IR (-O0):
define void @scale_v3f(float %0, float* %1) {
%3 = alloca float
%4 = alloca float*
store float %0, float* %3
store float* %1, float** %4
%5 = load float, float* %3
%6 = load float*, float** %4
%7 = getelementptr inbounds float, float* %6, i64 0
%8 = load float, float* %7
%9 = fmul float %8, %5
store float %9, float* %7
%10 = load float, float* %3
%11 = load float*, float** %4
%12 = getelementptr inbounds float, float* %11, i64 1
%13 = load float, float* %12
%14 = fmul float %13, %10
store float %14, float* %12
%15 = load float, float* %3
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 2
%18 = load float, float* %17
%19 = fmul float %18, %15
store float %19, float* %17
ret void
}

LLVM IR (-O2):
define void @scale_v3f(float %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = fmul float %3, %0
store float %4, float* %1
%5 = getelementptr inbounds float, float* %1, i64 1
%6 = load float, float* %5
%7 = fmul float %6, %0
store float %7, float* %5
%8 = getelementptr inbounds float, float* %1, i64 2
%9 = load float, float* %8
%10 = fmul float %9, %0
store float %10, float* %8
ret void
}
/* Variables and functions */
int /*<<< orphan*/ serial_outc(int);
void board_putc(int ch) { serial_outc(ch); }


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

x86 assembly (clang, -O2):
<board_putc>:
jmp    1030 <serial_outc@plt>

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

LLVM IR (-O2):
define void @board_putc(i32 %0) {
%2 = tail call i32 @serial_outc(i32 %0)
ret void
}
/* Type definitions */
typedef int int8_t;
typedef int int16_t;

/* Variables and functions */
int8_t qadd7(int8_t i, int8_t j) {
  int16_t t = i + j;
  if (t > 127)
    t = 127;
  return t;
}


x86 assembly (clang, -O0):
<qadd7>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jle    1124 <qadd7+0x24>
movl   $0x7f,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<qadd7>:
lea    (%rdi,%rsi,1),%ecx
cmp    $0x7f,%ecx
mov    $0x7f,%eax
cmovl  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @qadd7(i32 %0, i32 %1) {
%3 = add nsw i32 %1, %0
%4 = icmp slt i32 %3, 127
%5 = select i1 %4, i32 %3, i32 127
ret i32 %5
}
/* Variables and functions */
int sancus_get_drl(long, long, long, int *);
scalar_t__ sancus_get_ls(char const *, long *);
bool sancus_get_drls(const char *s, long a, long b, int *out) {
  long v;
  bool ret = false;
  if (sancus_get_ls(s, &v))
    ret = sancus_get_drl(v, a, b, out);
  return ret;
}


x86 assembly (clang, -O0):
<sancus_get_drls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <sancus_get_ls@plt>
cmp    $0x0,%rax
je     116e <sancus_get_drls+0x4e>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <sancus_get_drl@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sancus_get_drls>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <sancus_get_ls@plt>
test   %rax,%rax
je     1156 <sancus_get_drls+0x36>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <sancus_get_drl@plt>
jmp    1158 <sancus_get_drls+0x38>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @sancus_get_drls(i8* %0, i64 %1, i64 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32* %3, i32** %8
store i32 0, i32* %10
%11 = load i8*, i8** %5
%12 = call i64 @sancus_get_ls(i8* %11, i64* %9)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %4
%15 = load i64, i64* %9
%16 = load i64, i64* %6
%17 = load i64, i64* %7
%18 = load i32*, i32** %8
%19 = call i32 @sancus_get_drl(i64 %15, i64 %16, i64 %17, i32* %18)
store i32 %19, i32* %10
br label %20
20: ; preds = %14, %4
%21 = load i32, i32* %10
ret i32 %21
}

LLVM IR (-O2):
define i32 @sancus_get_drls(i8* %0, i64 %1, i64 %2, i32* %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = call i64 @sancus_get_ls(i8* %0, i64* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i64, i64* %5
%11 = call i32 @sancus_get_drl(i64 %10, i64 %1, i64 %2, i32* %3)
br label %12
12: ; preds = %9, %4
%13 = phi i32 [ %11, %9 ], [ 0, %4 ]
ret i32 %13
}
/* Variables and functions */
int makefilename(char *, size_t, char const *, char const *);
int c0x_mkfilename(char *path, size_t max, const char *dir, const char *file) {
  return (makefilename(path, max, dir, file));
}


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

x86 assembly (clang, -O2):
<c0x_mkfilename>:
jmp    1030 <makefilename@plt>

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

LLVM IR (-O2):
define i32 @c0x_mkfilename(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = tail call i32 @makefilename(i8* %0, i64 %1, i8* %2, i8* %3)
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, double const);
int /*<<< orphan*/ putchar(char);
void show_array(const double ar[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    printf("%8.3f  ", ar[i]);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<show_array>:
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    1169 <show_array+0x49>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <show_array+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1157 <show_array+0x37>
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xec5(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <show_array+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"%8.3f \00"
define void @show_array(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %11, %6 ]
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %9)
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, %5
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 @putchar(i8 signext 10)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ mvm_program_timer(int);
void xnarch_program_timer_shot(unsigned long delay) {
  mvm_program_timer(delay ?: 1);
}


x86 assembly (clang, -O0):
<xnarch_program_timer_shot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     113b <xnarch_program_timer_shot+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1149 <xnarch_program_timer_shot+0x39>
mov    $0x1,%eax
mov    %rax,-0x18(%rbp)
jmp    1149 <xnarch_program_timer_shot+0x39>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1030 <mvm_program_timer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xnarch_program_timer_shot>:
test   %rdi,%rdi
mov    $0x1,%eax
cmove  %eax,%edi
jmp    1030 <mvm_program_timer@plt>

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

LLVM IR (-O2):
define void @xnarch_program_timer_shot(i64 %0) {
%2 = icmp eq i64 %0, 0
%3 = trunc i64 %0 to i32
%4 = select i1 %2, i32 1, i32 %3
%5 = tail call i32 @mvm_program_timer(i32 %4)
ret void
}
/* Variables and functions */
scalar_t__ errno;
unsigned long strtoul(char const *, char **, int);
long parse_number(const char *p, int base) {
  char *end;
  unsigned long result;
  errno = 0;
  result = strtoul(p, &end, base);
  if (errno || *end)
    return -1;
  return result;
}


x86 assembly (clang, -O0):
<parse_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2eba(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x20(%rbp),%rsi
call   1030 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e98(%rip),%rax
cmpq   $0x0,(%rax)
jne    1162 <parse_number+0x52>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116f <parse_number+0x5f>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1177 <parse_number+0x67>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_number>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%edx
mov    0x2ec2(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
call   1030 <strtoul@plt>
mov    $0xffffffffffffffff,%rcx
cmpq   $0x0,(%rbx)
jne    114b <parse_number+0x3b>
mov    0x8(%rsp),%rcx
xor    %edx,%edx
cmp    (%rcx),%dl
sbb    %rcx,%rcx
or     %rax,%rcx
mov    %rcx,%rax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@errno = global i64 0
define i64 @parse_number(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%5 = call i64 @strtoul(i8* %0, i8** %3, i32 %1)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, i64 %5, i64 -1
br label %13
13: ; preds = %8, %2
%14 = phi i64 [ -1, %2 ], [ %12, %8 ]
ret i64 %14
}
/* Variables and functions */
int div_23n5(int);
int /*<<< orphan*/ puts(int);
void test() {
  puts(div_23n5(2) == 0);
  puts(div_23n5(3) == 0);
  puts(div_23n5(6) == 1);
  puts(div_23n5(12) == 1);
  puts(div_23n5(30) == 0);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
mov    $0x2,%edi
call   1040 <div_23n5@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1040 <div_23n5@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <puts@plt>
mov    $0x6,%edi
call   1040 <div_23n5@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <puts@plt>
mov    $0xc,%edi
call   1040 <div_23n5@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <puts@plt>
mov    $0x1e,%edi
call   1040 <div_23n5@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <puts@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rax
mov    $0x2,%edi
call   1040 <div_23n5@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <puts@plt>
mov    $0x3,%edi
call   1040 <div_23n5@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <puts@plt>
mov    $0x6,%edi
call   1040 <div_23n5@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <puts@plt>
mov    $0xc,%edi
call   1040 <div_23n5@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <puts@plt>
mov    $0x1e,%edi
call   1040 <div_23n5@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
define void @test() {
%1 = call i32 @div_23n5(i32 2)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @puts(i32 %3)
%5 = call i32 @div_23n5(i32 3)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @puts(i32 %7)
%9 = call i32 @div_23n5(i32 6)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @puts(i32 %11)
%13 = call i32 @div_23n5(i32 12)
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i32
%16 = call i32 @puts(i32 %15)
%17 = call i32 @div_23n5(i32 30)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @puts(i32 %19)
ret void
}

LLVM IR (-O2):
define void @test() {
%1 = tail call i32 @div_23n5(i32 2)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @puts(i32 %3)
%5 = tail call i32 @div_23n5(i32 3)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @puts(i32 %7)
%9 = tail call i32 @div_23n5(i32 6)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @puts(i32 %11)
%13 = tail call i32 @div_23n5(i32 12)
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i32
%16 = tail call i32 @puts(i32 %15)
%17 = tail call i32 @div_23n5(i32 30)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @puts(i32 %19)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isxdigit(int);
void t_isxdigit_0xf6() {
  Assert_real((isxdigit(246) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isxdigit.c",
              1235, ("isxdigit should be 0 for 0xf6"));
}


x86 assembly (clang, -O0):
<t_isxdigit_0xf6>:
push   %rbp
mov    %rsp,%rbp
mov    $0xf6,%edi
call   1030 <isxdigit@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xebf(%rip),%rsi
mov    $0x4d3,%edx
lea    0xf5c(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_isxdigit_0xf6>:
push   %rax
mov    $0xf6,%edi
call   1030 <isxdigit@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf67(%rip),%rcx
mov    $0x4d3,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0xf6\00"
define void @t_isxdigit_0xf6() {
%1 = call i64 @isxdigit(i32 246)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 1235, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0xf6\00"
define void @t_isxdigit_0xf6() {
%1 = tail call i64 @isxdigit(i32 246)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 1235, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int srt_char_to_digit(const char c) {
  int ret = -1;
  switch (c) {
  case '0':
    ret = 0;
    break;
  case '1':
    ret = 1;
    break;
  case '2':
    ret = 2;
    break;
  case '3':
    ret = 3;
    break;
  case '4':
    ret = 4;
    break;
  case '5':
    ret = 5;
    break;
  case '6':
    ret = 6;
    break;
  case '7':
    ret = 7;
    break;
  case '8':
    ret = 8;
    break;
  case '9':
    ret = 9;
    break;
  default:
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<srt_char_to_digit>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     11b3 <srt_char_to_digit+0xb3>
mov    -0x10(%rbp),%rax
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x1,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x2,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x3,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x4,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x5,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x6,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x7,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x8,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
movl   $0x9,-0x8(%rbp)
jmp    11b8 <srt_char_to_digit+0xb8>
jmp    11b8 <srt_char_to_digit+0xb8>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<srt_char_to_digit>:
lea    -0x30(%rdi),%ecx
cmp    $0xa,%ecx
mov    $0xffffffff,%eax
cmovb  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @srt_char_to_digit(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 -1, i32* %3
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %16 [
i32 48, label %6
i32 49, label %7
i32 50, label %8
i32 51, label %9
i32 52, label %10
i32 53, label %11
i32 54, label %12
i32 55, label %13
i32 56, label %14
i32 57, label %15
]
6: ; preds = %1
store i32 0, i32* %3
br label %17
7: ; preds = %1
store i32 1, i32* %3
br label %17
8: ; preds = %1
store i32 2, i32* %3
br label %17
9: ; preds = %1
store i32 3, i32* %3
br label %17
10: ; preds = %1
store i32 4, i32* %3
br label %17
11: ; preds = %1
store i32 5, i32* %3
br label %17
12: ; preds = %1
store i32 6, i32* %3
br label %17
13: ; preds = %1
store i32 7, i32* %3
br label %17
14: ; preds = %1
store i32 8, i32* %3
br label %17
15: ; preds = %1
store i32 9, i32* %3
br label %17
16: ; preds = %1
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @srt_char_to_digit(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -48
%4 = icmp ult i32 %3, 10
%5 = select i1 %4, i32 %3, i32 -1
ret i32 %5
}
void x86_nop(int i, unsigned tar, unsigned arg1, unsigned arg2) {}


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

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

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

LLVM IR (-O2):
define void @x86_nop(i32 %0, i32 %1, i32 %2, i32 %3) {
ret void
}
int ft_ll_len(long long n) {
  int len;
  len = 0;
  if (n == 0)
    return (1);
  if (n < 0) {
    ++len;
    n *= -1;
  }
  while (n) {
    ++len;
    n /= 10;
  }
  return (len);
}


x86 assembly (clang, -O0):
<ft_ll_len>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1126 <ft_ll_len+0x26>
movl   $0x1,-0x4(%rbp)
jmp    1179 <ft_ll_len+0x79>
cmpq   $0x0,-0x10(%rbp)
jge    1143 <ft_ll_len+0x43>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
imul   $0xffffffffffffffff,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1148 <ft_ll_len+0x48>
cmpq   $0x0,-0x10(%rbp)
je     1173 <ft_ll_len+0x73>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    1148 <ft_ll_len+0x48>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_ll_len>:
test   %rdi,%rdi
je     1147 <ft_ll_len+0x47>
mov    %rdi,%rcx
shr    $0x3f,%rcx
mov    %rdi,%rsi
neg    %rsi
cmovs  %rdi,%rsi
movabs $0x6666666666666667,%rdi
66 66 66
add    $0x1,%ecx
mov    %rsi,%rax
imul   %rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    $0x9,%rsi
cmp    $0x12,%rsi
mov    %rdx,%rsi
ja     1120 <ft_ll_len+0x20>
mov    %ecx,%eax
ret
mov    $0x1,%ecx
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @ft_ll_len(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = lshr i64 %0, 63
%5 = trunc i64 %4 to i32
%6 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
br label %7
7: ; preds = %3, %7
%8 = phi i32 [ %10, %7 ], [ %5, %3 ]
%9 = phi i64 [ %11, %7 ], [ %6, %3 ]
%10 = add nuw nsw i32 %8, 1
%11 = sdiv i64 %9, 10
%12 = add i64 %9, 9
%13 = icmp ult i64 %12, 19
br i1 %13, label %14, label %7
14: ; preds = %7, %1
%15 = phi i32 [ 1, %1 ], [ %10, %7 ]
ret i32 %15
}
/* Variables and functions */
int /*<<< orphan*/ __quick_sort(int *, int /*<<< orphan*/, int);
void quick_sort(int arr[], int len) { __quick_sort(arr, 0, len - 1); }


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

x86 assembly (clang, -O2):
<quick_sort>:
lea    -0x1(%rsi),%edx
xor    %esi,%esi
jmp    1030 <__quick_sort@plt>

LLVM IR (-O0):
define void @quick_sort(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 = sub nsw i32 %6, 1
%8 = call i32 @__quick_sort(i32* %5, i32 0, i32 %7)
ret void
}

LLVM IR (-O2):
define void @quick_sort(i32* %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = tail call i32 @__quick_sort(i32* %0, i32 0, i32 %3)
ret void
}
void PerfxAtomicPtr_Set(void **ptr, void *new_ptr) {
  *ptr = new_ptr;
  __sync_synchronize();
}


x86 assembly (clang, -O0):
<PerfxAtomicPtr_Set>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mfence
pop    %rbp
ret

x86 assembly (clang, -O2):
<PerfxAtomicPtr_Set>:
mov    %rsi,(%rdi)
mfence
ret

LLVM IR (-O0):
define void @PerfxAtomicPtr_Set(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = load i8**, i8*** %3
store i8* %5, i8** %6
fence seq_cst
ret void
}

LLVM IR (-O2):
define void @PerfxAtomicPtr_Set(i8** nocapture writeonly %0, i8* %1) {
store i8* %1, i8** %0
fence seq_cst
ret void
}
int f_ge_rm1(float a1, float *a2) { return (((a1) >= (*a2))); }


x86 assembly (clang, -O0):
<f_ge_rm1>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
ucomiss (%rax),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_ge_rm1>:
xor    %eax,%eax
ucomiss (%rdi),%xmm0
setae  %al
ret

LLVM IR (-O0):
define i32 @f_ge_rm1(float %0, float* %1) {
%3 = alloca float
%4 = alloca float*
store float %0, float* %3
store float* %1, float** %4
%5 = load float, float* %3
%6 = load float*, float** %4
%7 = load float, float* %6
%8 = fcmp oge float %5, %7
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
define i32 @f_ge_rm1(float %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = fcmp ole float %3, %0
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Variables and functions */
void *calloc(size_t, size_t);
int /*<<< orphan*/ fatal(char *, size_t, size_t);
void *ecalloc(size_t num, size_t size) {
  void *ret;
  if (NULL == (ret = calloc(num, size)))
    fatal("calloc(%zu, %zu) failed:", num, size);
  return ret;
}


x86 assembly (clang, -O0):
<ecalloc>:
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 <calloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1163 <ecalloc+0x43>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xea2(%rip),%rdi
call   1040 <fatal@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecalloc>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114a <ecalloc+0x2a>
lea    0xec1(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <fatal@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"calloc(%zu, %zu) failed:\00"
define i8* @ecalloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = call i8* @calloc(i64 %6, i64 %7)
store i8* %8, i8** %5
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i64, i64* %3
%12 = load i64, i64* %4
%13 = call i32 @fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %12)
br label %14
14: ; preds = %10, %2
%15 = load i8*, i8** %5
ret i8* %15
}

LLVM IR (-O2):
@.str = [25 x i8] c"calloc(%zu, %zu) failed:\00"
define noalias i8* @ecalloc(i64 %0, i64 %1) {
%3 = tail call i8* @calloc(i64 %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1)
br label %7
7: ; preds = %5, %2
ret i8* %3
}
/* Variables and functions */
scalar_t__ malloc(int);
int *init_array(int size) {
  int *arr = (int *)malloc(size * sizeof(int));
  int i;
  for (i = 0; i < size; i++) {
    arr[i] = 0;
  }
  return arr;
}


x86 assembly (clang, -O0):
<init_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    115e <init_array+0x4e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <init_array+0x25>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_array>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x0(,%rbx,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1149 <init_array+0x29>
mov    %ebx,%edx
shl    $0x2,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32* @init_array(i32 %0) {
%2 = shl i32 %0, 2
%3 = tail call i64 @malloc(i32 %2)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = inttoptr i64 %3 to i8*
%7 = zext i32 %0 to i64
%8 = shl nuw nsw i64 %7, 2
br label %9
9: ; preds = %5, %1
%10 = inttoptr i64 %3 to i32*
ret i32* %10
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ ehrpwm_write(int /*<<< orphan*/, int, unsigned char);
int ehrpwm_hr_set_phase(uint8_t module, unsigned char val) {
  ehrpwm_write(module, 0x4, val << 8);
  return 0;
}


x86 assembly (clang, -O0):
<ehrpwm_hr_set_phase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%eax
shl    $0x8,%eax
mov    $0x4,%esi
movzbl %al,%edx
call   1030 <ehrpwm_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ehrpwm_hr_set_phase>:
push   %rax
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <ehrpwm_write@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @ehrpwm_hr_set_phase(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
store i8 %1, i8* %4
%5 = load i32, i32* %3
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = shl i32 %7, 8
%9 = trunc i32 %8 to i8
%10 = call i32 @ehrpwm_write(i32 %5, i32 4, i8 zeroext %9)
ret i32 0
}

LLVM IR (-O2):
define i32 @ehrpwm_hr_set_phase(i32 %0, i8 zeroext %1) {
%3 = tail call i32 @ehrpwm_write(i32 %0, i32 4, i8 zeroext 0)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
void vuln() {
  char name[40];
  printf("Please tell me your name: ");
  gets(name);
}


x86 assembly (clang, -O0):
<vuln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <gets@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vuln>:
sub    $0x28,%rsp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rdi
call   1040 <gets@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please tell me your name: \00"
define void @vuln() {
%1 = alloca [40 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = call i32 @gets(i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Please tell me your name: \00"
define void @vuln() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
ret void
}
/* Variables and functions */
int close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ stderr;
int gpio_close(int fd) {
  int err = close(fd);
  if (err != 0) {
    fprintf(stderr, "Failed closing descriptor %d! Error %d.\n", fd, err);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<gpio_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1167 <gpio_close+0x47>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xeaa(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    116e <gpio_close+0x4e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_close>:
push   %rbx
mov    %edi,%ebx
call   1030 <close@plt>
test   %eax,%eax
je     114c <gpio_close+0x2c>
mov    0x2ead(%rip),%rcx
mov    (%rcx),%edi
lea    0xec4(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Failed closing descriptor %d! Error %d.\0A\00"
define i32 @gpio_close(i32 %0) {
%2 = tail call i32 @close(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %2)
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ -1, %4 ], [ 0, %1 ]
ret i32 %8
}
/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
void BFD_TIMEVAL2LONGUS(struct timeval *ptv, unsigned long long int *pus) {
  if (ptv && pus) {
    *pus = ptv->tv_sec * (1000000) + ptv->tv_usec;
  }
}


x86 assembly (clang, -O0):
<BFD_TIMEVAL2LONGUS>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     113d <BFD_TIMEVAL2LONGUS+0x3d>
cmpq   $0x0,-0x10(%rbp)
je     113d <BFD_TIMEVAL2LONGUS+0x3d>
mov    -0x8(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x8(%rbp),%rcx
add    0x4(%rcx),%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<BFD_TIMEVAL2LONGUS>:
test   %rdi,%rdi
je     111e <BFD_TIMEVAL2LONGUS+0x1e>
test   %rsi,%rsi
je     111e <BFD_TIMEVAL2LONGUS+0x1e>
movslq (%rdi),%rax
imul   $0xf4240,%rax,%rax
movslq 0x4(%rdi),%rcx
add    %rax,%rcx
mov    %rcx,(%rsi)
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @BFD_TIMEVAL2LONGUS(%struct.timeval* %0, i64* %1) {
%3 = alloca %struct.timeval*
%4 = alloca i64*
store %struct.timeval* %0, %struct.timeval** %3
store i64* %1, i64** %4
%5 = load %struct.timeval*, %struct.timeval** %3
%6 = icmp ne %struct.timeval* %5, null
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = load i64*, i64** %4
%9 = icmp ne i64* %8, null
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load %struct.timeval*, %struct.timeval** %3
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 1000000
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = add nsw i32 %14, %17
%19 = sext i32 %18 to i64
%20 = load i64*, i64** %4
store i64 %19, i64* %20
br label %21
21: ; preds = %10, %7, %2
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @BFD_TIMEVAL2LONGUS(%struct.timeval* %0, i64* writeonly %1) {
%3 = icmp ne %struct.timeval* %0, null
%4 = icmp ne i64* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = mul nsw i32 %8, 1000000
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load i32, i32* %10
%12 = add nsw i32 %9, %11
%13 = sext i32 %12 to i64
store i64 %13, i64* %1
br label %14
14: ; preds = %6, %2
ret void
}
void clear_bit(int nr, void *_addr) {
  char *addr = _addr;
  ((addr))[(nr) / 8] &= ~(1UL << ((nr) % 8));
}


x86 assembly (clang, -O0):
<clear_bit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%esi
shl    %cl,%rsi
xor    $0xffffffffffffffff,%rsi
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
movsbq (%rax,%rcx,1),%rdx
and    %rsi,%rdx
mov    %dl,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_bit>:
mov    %edi,%ecx
lea    0x7(%rcx),%eax
test   %edi,%edi
cmovns %edi,%eax
mov    %eax,%edx
and    $0xfffffff8,%edx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%rdx
sar    $0x3,%eax
cltq
not    %dl
and    %dl,(%rsi,%rax,1)
ret

LLVM IR (-O0):
define void @clear_bit(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
store i8* %6, i8** %5
%7 = load i32, i32* %3
%8 = srem i32 %7, 8
%9 = zext i32 %8 to i64
%10 = shl i64 1, %9
%11 = xor i64 %10, -1
%12 = load i8*, i8** %5
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i64
%19 = and i64 %18, %11
%20 = trunc i64 %19 to i8
store i8 %20, i8* %16
ret void
}

LLVM IR (-O2):
define void @clear_bit(i32 %0, i8* nocapture %1) {
%3 = srem i32 %0, 8
%4 = zext i32 %3 to i64
%5 = shl nuw i64 1, %4
%6 = sdiv i32 %0, 8
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = trunc i64 %5 to i8
%11 = xor i8 %10, -1
%12 = and i8 %9, %11
store i8 %12, i8* %8
ret void
}
/* Type definitions */
struct timeval {
  int tv_usec;
  scalar_t__ tv_sec;
};
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int64_t get_tics() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (int64_t)tv.tv_sec * 1000 * 1000 + tv.tv_usec;
}


x86 assembly (clang, -O0):
<get_tics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x8(%rbp),%rax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
add    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tics>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
imul   $0xf4240,0x10(%rsp),%eax
add    0x8(%rsp),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define i32 @get_tics() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%4 = load i64, i64* %3
%5 = trunc i64 %4 to i32
%6 = mul nsw i32 %5, 1000
%7 = mul nsw i32 %6, 1000
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%9 = load i32, i32* %8
%10 = add nsw i32 %7, %9
ret i32 %10
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define i32 @get_tics() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%5 = load i64, i64* %4
%6 = trunc i64 %5 to i32
%7 = mul i32 %6, 1000000
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = add nsw i32 %7, %9
ret i32 %10
}