xunge/DecIR huggingface dataset:
void vec2_inverse(float *dst) {
  dst[0] = 1.0 / dst[0];
  dst[1] = 1.0 / dst[1];
}


x86 assembly (clang, -O0):
<vec2_inverse>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xee4(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xebf(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec2_inverse>:
movss  0xef8(%rip),%xmm0
movaps %xmm0,%xmm1
divss  (%rdi),%xmm1
movss  %xmm1,(%rdi)
divss  0x4(%rdi),%xmm0
movss  %xmm0,0x4(%rdi)
ret

LLVM IR (-O0):
define void @vec2_inverse(float* %0) {
%2 = alloca float*
store float* %0, float** %2
%3 = load float*, float** %2
%4 = getelementptr inbounds float, float* %3, i64 0
%5 = load float, float* %4
%6 = fpext float %5 to double
%7 = fdiv double 1.000000e+00, %6
%8 = fptrunc double %7 to float
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 0
store float %8, float* %10
%11 = load float*, float** %2
%12 = getelementptr inbounds float, float* %11, i64 1
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = fdiv double 1.000000e+00, %14
%16 = fptrunc double %15 to float
%17 = load float*, float** %2
%18 = getelementptr inbounds float, float* %17, i64 1
store float %16, float* %18
ret void
}

LLVM IR (-O2):
define void @vec2_inverse(float* nocapture %0) {
%2 = load float, float* %0
%3 = fdiv float 1.000000e+00, %2
store float %3, float* %0
%4 = getelementptr inbounds float, float* %0, i64 1
%5 = load float, float* %4
%6 = fdiv float 1.000000e+00, %5
store float %6, float* %4
ret void
}
/* Variables and functions */
int binarySearch(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int p[] = {1, 3, 5, 6, 9};
  int target = 9;
  int low = 0;
  int high = 4;
  printf("%d\n", binarySearch(p, low, high, target));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x9,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x4,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1040 <binarySearch@plt>
mov    %eax,%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@__const.main.p = [5 x i32] [i32 1, i32 3, i32 5, i32 6, i32 9]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @binarySearch(i32* %3, i32 0, i32 4, i32 9)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
ret i32 0
}
/* Variables and functions */
void *up_cast(void *);
void *uc(void *ptr) { return up_cast(ptr); }


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

x86 assembly (clang, -O2):
<uc>:
jmp    1030 <up_cast@plt>

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

LLVM IR (-O2):
define i8* @uc(i8* %0) {
%2 = tail call i8* @up_cast(i8* %0)
ret i8* %2
}
/* Variables and functions */
unsigned long strtoxl(char const *, char **, int, int);
unsigned long strtoul(const char *p, char **end, int base) {
  return strtoxl(p, end, base, 1);
}


x86 assembly (clang, -O0):
<strtoul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x1,%ecx
call   1030 <strtoxl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoul>:
mov    $0x1,%ecx
jmp    1030 <strtoxl@plt>

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

LLVM IR (-O2):
define i64 @strtoul(i8* %0, i8** %1, i32 %2) {
%4 = tail call i64 @strtoxl(i8* %0, i8** %1, i32 %2, i32 1)
ret i64 %4
}
/* Variables and functions */
int /*<<< orphan*/ set_io_bit(int, int);
void TOSH_SET_CC_RSTN_PIN() { set_io_bit(-4, 5); }


x86 assembly (clang, -O0):
<TOSH_SET_CC_RSTN_PIN>:
push   %rbp
mov    %rsp,%rbp
mov    $0xfffffffc,%edi
mov    $0x5,%esi
call   1030 <set_io_bit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<TOSH_SET_CC_RSTN_PIN>:
mov    $0xfffffffc,%edi
mov    $0x5,%esi
jmp    1030 <set_io_bit@plt>

LLVM IR (-O0):
define void @TOSH_SET_CC_RSTN_PIN() {
%1 = call i32 @set_io_bit(i32 -4, i32 5)
ret void
}

LLVM IR (-O2):
define void @TOSH_SET_CC_RSTN_PIN() {
%1 = tail call i32 @set_io_bit(i32 -4, i32 5)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ putchar(char);
void aprint(double arr[], int nm) {
  for (int j = 0; j < nm; ++j)
    printf("%lf ", arr[j]);
  putchar('\n');
}


x86 assembly (clang, -O0):
<aprint>:
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 <aprint+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 <aprint+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aprint>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1157 <aprint+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 <aprint+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%lf \00"
define void @aprint(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 ([5 x i8], [5 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 = [5 x i8] c"%lf \00"
define void @aprint(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %8
6: ; preds = %8, %2
%7 = tail call i32 @putchar(i8 signext 10)
ret void
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %13, %8 ]
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %11)
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %6, label %8
}
/* Variables and functions */
int _isatty(int);
int platform_istty(int fd) { return _isatty(fd); }


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

x86 assembly (clang, -O2):
<platform_istty>:
jmp    1030 <_isatty@plt>

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

LLVM IR (-O2):
define i32 @platform_istty(i32 %0) {
%2 = tail call i32 @_isatty(i32 %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 2 && strcmp(argv[1], "--version") == 0) {
    printf("VERSION_HEADER 1.2.3 VERSION_FOOTER\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    116a <main+0x4a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    116a <main+0x4a>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1147 <main+0x27>
mov    0x8(%rsi),%rdi
lea    0xecf(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1147 <main+0x27>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"--version\00"
@str = [36 x i8] c"VERSION_HEADER 1.2.3 VERSION_FOOTER\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %4, %2
ret i32 0
}
int fun1125() { return 1125; }


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

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

LLVM IR (-O0):
define i32 @fun1125() {
ret i32 1125
}

LLVM IR (-O2):
define i32 @fun1125() {
ret i32 1125
}
/* Variables and functions */
int /*<<< orphan*/ __p3dfft_MOD_p3dfft_btran_c2r(float *, float *);
void p3dfft_btran_c2r(float *A, float *B) {
  __p3dfft_MOD_p3dfft_btran_c2r(A, B);
}


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

x86 assembly (clang, -O2):
<p3dfft_btran_c2r>:
jmp    1030 <__p3dfft_MOD_p3dfft_btran_c2r@plt>

LLVM IR (-O0):
define void @p3dfft_btran_c2r(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 = call i32 @__p3dfft_MOD_p3dfft_btran_c2r(float* %5, float* %6)
ret void
}

LLVM IR (-O2):
define void @p3dfft_btran_c2r(float* %0, float* %1) {
%3 = tail call i32 @__p3dfft_MOD_p3dfft_btran_c2r(float* %0, float* %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ eiki_abort();
int /*<<< orphan*/ eiki_print_s(char const *);
void eiki_assertion_failed(const char *msg) {
  eiki_print_s(msg);
  eiki_abort();
}


x86 assembly (clang, -O0):
<eiki_assertion_failed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <eiki_print_s@plt>
mov    $0x0,%al
call   1040 <eiki_abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @eiki_assertion_failed(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @eiki_print_s(i8* %3)
%5 = call i32 (...) @eiki_abort()
ret void
}

LLVM IR (-O2):
define void @eiki_assertion_failed(i8* %0) {
%2 = tail call i32 @eiki_print_s(i8* %0)
%3 = tail call i32 (...) @eiki_abort()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ injector();
void doit() { injector(); }


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

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

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

LLVM IR (-O2):
define void @doit() {
%1 = tail call i32 (...) @injector()
ret void
}
double change_interval(double (*func)(double, void *), void *params, double z,
                       double a, double b) {
  return (b - a) / 2 * func(z * (b - a) / 2 + (b + a) / 2, params);
}


x86 assembly (clang, -O0):
<change_interval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xecf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe91(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rdi
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_interval>:
push   %rax
mov    %rdi,%rax
movapd %xmm2,%xmm3
subsd  %xmm1,%xmm3
movsd  0xeec(%rip),%xmm4
mulsd  %xmm3,%xmm0
mulsd  %xmm4,%xmm3
movsd  %xmm3,(%rsp)
mulsd  %xmm4,%xmm0
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm4
addsd  %xmm4,%xmm0
mov    %rsi,%rdi
call   *%rax
mulsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @change_interval(double (double, i8*)* %0, i8* %1, double %2, double %3, double %4) {
%6 = alloca double (double, i8*)*
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double (double, i8*)* %0, double (double, i8*)** %6
store i8* %1, i8** %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%11 = load double, double* %10
%12 = load double, double* %9
%13 = fsub double %11, %12
%14 = fdiv double %13, 2.000000e+00
%15 = load double (double, i8*)*, double (double, i8*)** %6
%16 = load double, double* %8
%17 = load double, double* %10
%18 = load double, double* %9
%19 = fsub double %17, %18
%20 = fmul double %16, %19
%21 = fdiv double %20, 2.000000e+00
%22 = load double, double* %10
%23 = load double, double* %9
%24 = fadd double %22, %23
%25 = fdiv double %24, 2.000000e+00
%26 = fadd double %21, %25
%27 = load i8*, i8** %7
%28 = call double %15(double %26, i8* %27)
%29 = fmul double %14, %28
ret double %29
}

LLVM IR (-O2):
define double @change_interval(double (double, i8*)* nocapture %0, i8* %1, double %2, double %3, double %4) {
%6 = fsub double %4, %3
%7 = fmul double %6, 5.000000e-01
%8 = fmul double %6, %2
%9 = fmul double %8, 5.000000e-01
%10 = fadd double %3, %4
%11 = fmul double %10, 5.000000e-01
%12 = fadd double %11, %9
%13 = tail call double %0(double %12, i8* %1)
%14 = fmul double %7, %13
ret double %14
}
int is_hex(char c) {
  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
         (c >= 'a' && c <= 'f');
}


x86 assembly (clang, -O0):
<is_hex>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1129 <is_hex+0x29>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x39,%ecx
mov    %al,-0x2(%rbp)
jle    116d <is_hex+0x6d>
movsbl -0x1(%rbp),%eax
cmp    $0x41,%eax
jl     1148 <is_hex+0x48>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x46,%ecx
mov    %al,-0x2(%rbp)
jle    116d <is_hex+0x6d>
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x61,%ecx
mov    %al,-0x3(%rbp)
jl     1167 <is_hex+0x67>
movsbl -0x1(%rbp),%eax
cmp    $0x66,%eax
setle  %al
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_hex>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
setb   %al
and    $0xdf,%dil
add    $0xbf,%dil
cmp    $0x6,%dil
setb   %cl
or     %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @is_hex(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = icmp sge i32 %4, 48
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp sle i32 %8, 57
br i1 %9, label %28, label %10
10: ; preds = %6, %1
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 65
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp sle i32 %16, 70
br i1 %17, label %28, label %18
18: ; preds = %14, %10
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 97
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 102
br label %26
26: ; preds = %22, %18
%27 = phi i1 [ false, %18 ], [ %25, %22 ]
br label %28
28: ; preds = %26, %14, %6
%29 = phi i1 [ true, %14 ], [ true, %6 ], [ %27, %26 ]
%30 = zext i1 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
define i32 @is_hex(i8 signext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
%4 = and i8 %0, -33
%5 = add i8 %4, -65
%6 = icmp ult i8 %5, 6
%7 = or i1 %3, %6
%8 = zext i1 %7 to i32
ret i32 %8
}
int MemAddrHash64(void *addr) {
  struct uptr_addr {
    unsigned long val1 : 16;
    unsigned long val2 : 16;
    unsigned long val3 : 16;
    unsigned long val4 : 16;
  } *uladdr = (struct uptr_addr *)&addr;
  return (uladdr->val1 ^ uladdr->val2 ^ uladdr->val3 ^ uladdr->val4) &
         (1024 - 1);
}


x86 assembly (clang, -O0):
<MemAddrHash64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
and    $0xffff,%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
shr    $0x10,%rcx
and    $0xffff,%rcx
xor    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
shr    $0x20,%rcx
and    $0xffff,%rcx
xor    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
shr    $0x30,%rcx
xor    %ecx,%eax
and    $0x3ff,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<MemAddrHash64>:
mov    %edi,%ecx
shr    $0x10,%ecx
xor    %edi,%ecx
mov    %rdi,%rax
shr    $0x20,%rax
shr    $0x30,%rdi
xor    %edi,%eax
xor    %ecx,%eax
and    $0x3ff,%eax
ret

LLVM IR (-O0):
%struct.uptr_addr = type { i64 }
define i32 @MemAddrHash64(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.uptr_addr*
store i8* %0, i8** %2
%4 = bitcast i8** %2 to %struct.uptr_addr*
store %struct.uptr_addr* %4, %struct.uptr_addr** %3
%5 = load %struct.uptr_addr*, %struct.uptr_addr** %3
%6 = bitcast %struct.uptr_addr* %5 to i64*
%7 = load i64, i64* %6
%8 = and i64 %7, 65535
%9 = trunc i64 %8 to i32
%10 = load %struct.uptr_addr*, %struct.uptr_addr** %3
%11 = bitcast %struct.uptr_addr* %10 to i64*
%12 = load i64, i64* %11
%13 = lshr i64 %12, 16
%14 = and i64 %13, 65535
%15 = trunc i64 %14 to i32
%16 = xor i32 %9, %15
%17 = load %struct.uptr_addr*, %struct.uptr_addr** %3
%18 = bitcast %struct.uptr_addr* %17 to i64*
%19 = load i64, i64* %18
%20 = lshr i64 %19, 32
%21 = and i64 %20, 65535
%22 = trunc i64 %21 to i32
%23 = xor i32 %16, %22
%24 = load %struct.uptr_addr*, %struct.uptr_addr** %3
%25 = bitcast %struct.uptr_addr* %24 to i64*
%26 = load i64, i64* %25
%27 = lshr i64 %26, 48
%28 = trunc i64 %27 to i32
%29 = xor i32 %23, %28
%30 = and i32 %29, 1023
ret i32 %30
}

LLVM IR (-O2):
%struct.uptr_addr = type { i64 }
define i32 @MemAddrHash64(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = lshr i32 %3, 16
%5 = xor i32 %4, %3
%6 = lshr i64 %2, 32
%7 = trunc i64 %6 to i32
%8 = xor i32 %5, %7
%9 = lshr i64 %2, 48
%10 = trunc i64 %9 to i32
%11 = xor i32 %8, %10
%12 = and i32 %11, 1023
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void chk(char *fun, int sts) {
  if (sts != 0)
    printf("%s failed\n", fun);
}


x86 assembly (clang, -O0):
<chk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1139 <chk+0x29>
mov    -0x8(%rbp),%rsi
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk>:
test   %esi,%esi
je     1126 <chk+0x16>
mov    %rdi,%rax
lea    0xee2(%rip),%rdi
mov    %rax,%rsi
jmp    1030 <printf@plt>
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"%s failed\0A\00"
define void @chk(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %6
6: ; preds = %4, %2
ret void
}
/* Variables and functions */
double sin(double);
double c_sin(double arg0) { return sin(arg0); }


x86 assembly (clang, -O0):
<c_sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_sin>:
jmp    1030 <sin@plt>

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

LLVM IR (-O2):
define double @c_sin(double %0) {
%2 = tail call double @sin(double %0)
ret double %2
}
int atoi(char *arg) {
  int i, n;
  n = 0;
  for (i = 0; arg[i] != '\0'; ++i) {
    n = n * 10 + (arg[i] - '0');
  }
  return n;
}


x86 assembly (clang, -O0):
<atoi>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1151 <atoi+0x51>
imul   $0xa,-0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <atoi+0x16>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<atoi>:
mov    (%rdi),%cl
test   %cl,%cl
je     1128 <atoi+0x28>
add    $0x1,%rdi
xor    %eax,%eax
nopl   0x0(%rax)
movsbl %cl,%ecx
lea    (%rax,%rax,4),%eax
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1110 <atoi+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @atoi(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %12, %4 ], [ 0, %1 ]
%6 = phi i8 [ %14, %4 ], [ %2, %1 ]
%7 = phi i32 [ %11, %4 ], [ 0, %1 ]
%8 = sext i8 %6 to i32
%9 = mul nsw i32 %7, 10
%10 = add i32 %9, -48
%11 = add i32 %10, %8
%12 = add nuw nsw i64 %5, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %4
16: ; preds = %4, %1
%17 = phi i32 [ 0, %1 ], [ %11, %4 ]
ret i32 %17
}
/* Variables and functions */
int /*<<< orphan*/ ALWAYS_ASSERT(int);
int /*<<< orphan*/ C67_asm(char *, int, int, int /*<<< orphan*/);
int abs(int);
void C67_ADDK(int n, int r) {
  ALWAYS_ASSERT(abs(n) < 32767);
  C67_asm("ADDK", n, r, 0);
}


x86 assembly (clang, -O0):
<C67_ADDK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x7fff,%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <ALWAYS_ASSERT@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9b(%rip),%rdi
xor    %ecx,%ecx
call   1040 <C67_asm@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C67_ADDK>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
mov    %esi,%ebp
xor    %edi,%edi
cmp    $0x7fff,%eax
setb   %dil
call   1040 <ALWAYS_ASSERT@plt>
lea    0xebb(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <C67_asm@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"ADDK\00"
define void @C67_ADDK(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 = call i32 @abs(i32 %5)
%7 = icmp slt i32 %6, 32767
%8 = zext i1 %7 to i32
%9 = call i32 @ALWAYS_ASSERT(i32 %8)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 @C67_asm(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"ADDK\00"
define void @C67_ADDK(i32 %0, i32 %1) {
%3 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%4 = icmp ult i32 %3, 32767
%5 = zext i1 %4 to i32
%6 = tail call i32 @ALWAYS_ASSERT(i32 %5)
%7 = tail call i32 @C67_asm(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 0)
ret void
}
int b() {
  printf("%s(0): %p\n", __func__, __builtin_return_address(0));
  while (1) {
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<b>:
push   %rbp
mov    %rsp,%rbp
mov    0x8(%rbp),%rdx
lea    0xed1(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <sleep@plt>
jmp    113d <b+0x1d>

x86 assembly (clang, -O2):
<b>:
push   %rax
mov    0x8(%rsp),%rdx
lea    0xed3(%rip),%rdi
lea    0xed7(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <sleep@plt>
jmp    1140 <b+0x20>

LLVM IR (-O0):
@.str = [11 x i8] c"%s(0): %p\0A\00"
@__func__.b = [2 x i8] c"b\00"
define i32 @b() {
%1 = call i8* @llvm.returnaddress(i32 0)
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__func__.b, i64 0, i64 0), i8* %1)
br label %3
3: ; preds = %0, %3
%4 = call i32 (i32, ...) bitcast (i32 (...)* @sleep to i32 (i32, ...)*)(i32 1)
br label %3
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s(0): %p\0A\00"
@__func__.b = [2 x i8] c"b\00"
define i32 @b() {
%1 = tail call i8* @llvm.returnaddress(i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @__func__.b, i64 0, i64 0), i8* %1)
br label %3
3: ; preds = %0, %3
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @sleep to i32 (i32, ...)*)(i32 1)
br label %3
}
/* Variables and functions */
void *malloc(int);
void *jdns_alloc(int size) { return malloc(size); }


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

x86 assembly (clang, -O2):
<jdns_alloc>:
jmp    1030 <malloc@plt>

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

LLVM IR (-O2):
define noalias i8* @jdns_alloc(i32 %0) {
%2 = tail call i8* @malloc(i32 %0)
ret i8* %2
}
int acmpRead(unsigned int channel) {
  return (*((volatile unsigned int *const)(0x4001105c + (channel * 4)))) &
         (1 << 15);
}


x86 assembly (clang, -O0):
<acmpRead>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
add    $0x4001105c,%eax
mov    %eax,%eax
mov    (%rax),%eax
and    $0x8000,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<acmpRead>:
lea    0x4001105c(,%rdi,4),%ecx
mov    $0x8000,%eax
and    (%rcx),%eax
ret

LLVM IR (-O0):
define i32 @acmpRead(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = mul i32 %3, 4
%5 = add i32 1073811548, %4
%6 = zext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load volatile i32, i32* %7
%9 = and i32 %8, 32768
ret i32 %9
}

LLVM IR (-O2):
define i32 @acmpRead(i32 %0) {
%2 = shl i32 %0, 2
%3 = add i32 %2, 1073811548
%4 = zext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
%6 = load volatile i32, i32* %5
%7 = and i32 %6, 32768
ret i32 %7
}
unsigned short GET_UAA16BE(void *p, unsigned int i) {
  unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
  return (unsigned short)_p[0] << 8 | (unsigned short)_p[1];
}


x86 assembly (clang, -O0):
<GET_UAA16BE>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
movzwl %ax,%eax
shl    $0x8,%eax
mov    -0x18(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
movzwl %cx,%ecx
or     %ecx,%eax
movzwl %ax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GET_UAA16BE>:
mov    %esi,%eax
movzwl (%rdi,%rax,2),%eax
rol    $0x8,%ax
ret

LLVM IR (-O0):
define zeroext i16 @GET_UAA16BE(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i16*
%8 = load i32, i32* %4
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i16, i16* %7, i64 %9
%11 = bitcast i16* %10 to i8*
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i16
%16 = zext i16 %15 to i32
%17 = shl i32 %16, 8
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i16
%22 = zext i16 %21 to i32
%23 = or i32 %17, %22
%24 = trunc i32 %23 to i16
ret i16 %24
}

LLVM IR (-O2):
define zeroext i16 @GET_UAA16BE(i8* nocapture %0, i32 %1) {
%3 = bitcast i8* %0 to i16*
%4 = zext i32 %1 to i64
%5 = getelementptr inbounds i16, i16* %3, i64 %4
%6 = bitcast i16* %5 to i8*
%7 = load i8, i8* %6
%8 = zext i8 %7 to i16
%9 = shl nuw i16 %8, 8
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i16
%13 = or i16 %9, %12
ret i16 %13
}
/* Type definitions */
typedef int /*<<< orphan*/ CTLOG;

/* Variables and functions */
int CTLOG_new_from_base64_ex(int /*<<< orphan*/ **, char const *, char const *,
                             int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int CTLOG_new_from_base64(CTLOG **ct_log, const char *pkey_base64,
                          const char *name) {
  return CTLOG_new_from_base64_ex(ct_log, pkey_base64, name, NULL, NULL);
}


x86 assembly (clang, -O0):
<CTLOG_new_from_base64>:
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
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1030 <CTLOG_new_from_base64_ex@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CTLOG_new_from_base64>:
xor    %ecx,%ecx
xor    %r8d,%r8d
jmp    1030 <CTLOG_new_from_base64_ex@plt>

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

LLVM IR (-O2):
define i32 @CTLOG_new_from_base64(i32** %0, i8* %1, i8* %2) {
%4 = tail call i32 @CTLOG_new_from_base64_ex(i32** %0, i8* %1, i8* %2, i32* null, i32* null)
ret i32 %4
}
unsigned _counter_packed_size(unsigned x) {
  if (x > 0x3FFF) {
    if (x > 0x1FFFFF) {
      if (x > 0xFFFFFFF)
        return 5;
      return 4;
    }
    return 3;
  }
  if (x > 0x7F)
    return 2;
  return 1;
}


x86 assembly (clang, -O0):
<_counter_packed_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x3fff,-0x8(%rbp)
jbe    1152 <_counter_packed_size+0x52>
cmpl   $0x1fffff,-0x8(%rbp)
jbe    1146 <_counter_packed_size+0x46>
cmpl   $0xfffffff,-0x8(%rbp)
jbe    113a <_counter_packed_size+0x3a>
movl   $0x5,-0x4(%rbp)
jmp    116f <_counter_packed_size+0x6f>
movl   $0x4,-0x4(%rbp)
jmp    116f <_counter_packed_size+0x6f>
movl   $0x3,-0x4(%rbp)
jmp    116f <_counter_packed_size+0x6f>
cmpl   $0x7f,-0x8(%rbp)
jbe    1168 <_counter_packed_size+0x68>
movl   $0x2,-0x4(%rbp)
jmp    116f <_counter_packed_size+0x6f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_counter_packed_size>:
cmp    $0x4000,%edi
jb     1124 <_counter_packed_size+0x24>
mov    $0x3,%eax
cmp    $0x200000,%edi
jb     112f <_counter_packed_size+0x2f>
xor    %eax,%eax
cmp    $0x10000000,%edi
setae  %al
or     $0x4,%eax
ret
xor    %eax,%eax
cmp    $0x7f,%edi
seta   %al
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @_counter_packed_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ugt i32 %4, 16383
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp ugt i32 %7, 2097151
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp ugt i32 %10, 268435455
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 5, i32* %2
br label %20
13: ; preds = %9
store i32 4, i32* %2
br label %20
14: ; preds = %6
store i32 3, i32* %2
br label %20
15: ; preds = %1
%16 = load i32, i32* %3
%17 = icmp ugt i32 %16, 127
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 2, i32* %2
br label %20
19: ; preds = %15
store i32 1, i32* %2
br label %20
20: ; preds = %19, %18, %14, %13, %12
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @_counter_packed_size(i32 %0) {
%2 = icmp ugt i32 %0, 16383
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = icmp ugt i32 %0, 2097151
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = icmp ugt i32 %0, 268435455
%7 = select i1 %6, i32 5, i32 4
br label %11
8: ; preds = %1
%9 = icmp ugt i32 %0, 127
%10 = select i1 %9, i32 2, i32 1
br label %11
11: ; preds = %8, %3, %5
%12 = phi i32 [ %7, %5 ], [ 3, %3 ], [ %10, %8 ]
ret i32 %12
}
int digits(val)
int val;
{
  register int cnt = 0;
  while (val > 0) {
    cnt++;
    val /= 10;
  }
  return (cnt);
}


x86 assembly (clang, -O0):
<digits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1134 <digits+0x34>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    110e <digits+0xe>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<digits>:
xor    %eax,%eax
test   %edi,%edi
jle    1124 <digits+0x24>
mov    $0xcccccccd,%ecx
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
mov    %edi,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
cmp    $0x9,%edi
mov    %edx,%edi
ja     1110 <digits+0x10>
ret

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

LLVM IR (-O2):
define i32 @digits(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %9
3: ; preds = %1, %3
%4 = phi i32 [ %6, %3 ], [ 0, %1 ]
%5 = phi i32 [ %7, %3 ], [ %0, %1 ]
%6 = add nuw nsw i32 %4, 1
%7 = udiv i32 %5, 10
%8 = icmp ult i32 %5, 10
br i1 %8, label %9, label %3
9: ; preds = %3, %1
%10 = phi i32 [ 0, %1 ], [ %6, %3 ]
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(void) {
  fputs("UBSAN TEST START\n", stderr);
  const int t = 0;
  struct s {
    int x;
    int g[t];
  };
  fputs("UBSAN TEST END\n", stderr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%esi
lea    0xed1(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x0,-0x8(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
lea    0xec7(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec8(%rip),%rbx
mov    (%rbx),%esi
lea    0xedf(%rip),%rdi
call   1030 <fputs@plt>
mov    (%rbx),%esi
lea    0xee3(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"UBSAN TEST START\0A\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"UBSAN TEST END\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @stderr
%4 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 0, i32* %2
%5 = load i32, i32* @stderr
%6 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %5)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"UBSAN TEST START\0A\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"UBSAN TEST END\0A\00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @stderr
%4 = tail call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ debug_init();
int /*<<< orphan*/ handle_libdl();
int /*<<< orphan*/ setup_hash_tables();
void gotcha_init() {
  static int gotcha_initialized = 0;
  if (gotcha_initialized) {
    return;
  }
  gotcha_initialized = 1;
  debug_init();
  setup_hash_tables();
  handle_libdl();
}


x86 assembly (clang, -O0):
<gotcha_init>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2f01(%rip)
je     1146 <gotcha_init+0x16>
jmp    1165 <gotcha_init+0x35>
movl   $0x1,0x2eec(%rip)
mov    $0x0,%al
call   1030 <debug_init@plt>
mov    $0x0,%al
call   1040 <setup_hash_tables@plt>
mov    $0x0,%al
call   1050 <handle_libdl@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gotcha_init>:
push   %rax
cmpb   $0x0,0x2f04(%rip)
je     113c <gotcha_init+0xc>
pop    %rax
ret
movb   $0x1,0x2ef9(%rip)
xor    %eax,%eax
call   1030 <debug_init@plt>
xor    %eax,%eax
call   1040 <setup_hash_tables@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <handle_libdl@plt>

LLVM IR (-O0):
@gotcha_init.gotcha_initialized = internal global i32 0
define void @gotcha_init() {
%1 = load i32, i32* @gotcha_init.gotcha_initialized
%2 = icmp ne i32 %1, 0
br i1 %2, label %3, label %4
3: ; preds = %0
br label %8
4: ; preds = %0
store i32 1, i32* @gotcha_init.gotcha_initialized
%5 = call i32 (...) @debug_init()
%6 = call i32 (...) @setup_hash_tables()
%7 = call i32 (...) @handle_libdl()
br label %8
8: ; preds = %4, %3
ret void
}

LLVM IR (-O2):
@gotcha_init.gotcha_initialized = internal unnamed_addr global i1 false
define void @gotcha_init() {
%1 = load i1, i1* @gotcha_init.gotcha_initialized
br i1 %1, label %6, label %2
2: ; preds = %0
store i1 true, i1* @gotcha_init.gotcha_initialized
%3 = tail call i32 (...) @debug_init()
%4 = tail call i32 (...) @setup_hash_tables()
%5 = tail call i32 (...) @handle_libdl()
br label %6
6: ; preds = %0, %2
ret void
}
void SetExperimentalDebug() {}


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

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

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

LLVM IR (-O2):
define void @SetExperimentalDebug() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ soundblaster_deinit();
void audio_deinit(void) { soundblaster_deinit(); }


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

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

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

LLVM IR (-O2):
define void @audio_deinit() {
%1 = tail call i32 (...) @soundblaster_deinit()
ret void
}
int asc_sort(a, b) const char **a;
const char **b;
{ return (strcmp(*a, *b)); }


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

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

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

LLVM IR (-O2):
define i32 @asc_sort(i8** nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %0
%4 = load i8*, i8** %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(1) %4)
ret i32 %5
}
/* Variables and functions */
bool nrf52_errata_173(void) { return false; }


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

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

LLVM IR (-O0):
define i32 @nrf52_errata_173() {
ret i32 0
}

LLVM IR (-O2):
define i32 @nrf52_errata_173() {
ret i32 0
}
/* Variables and functions */
void *malloc(unsigned int);
int /*<<< orphan*/ r3_fatal(char *);
void *r3_mem_alloc(unsigned int sz) {
  void *p = malloc(sz);
  if (p == NULL)
    r3_fatal("no memory");
  return p;
}


x86 assembly (clang, -O0):
<r3_mem_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114e <r3_mem_alloc+0x2e>
lea    0xeb7(%rip),%rdi
call   1030 <r3_fatal@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r3_mem_alloc>:
push   %rbx
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    113a <r3_mem_alloc+0x1a>
lea    0xecb(%rip),%rdi
call   1030 <r3_fatal@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"no memory\00"
define i8* @r3_mem_alloc(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i8* @malloc(i32 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @r3_fatal(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %3
ret i8* %11
}

LLVM IR (-O2):
@.str = [10 x i8] c"no memory\00"
define noalias i8* @r3_mem_alloc(i32 %0) {
%2 = tail call i8* @malloc(i32 %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @r3_fatal(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
ret i8* %2
}
/* Type definitions */
typedef int int32_t;

/* Variables and functions */
int32_t get_rd(int32_t instruction) { return (instruction & 0x0000f800) >> 11; }


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

x86 assembly (clang, -O2):
<get_rd>:
mov    %edi,%eax
shr    $0xb,%eax
and    $0x1f,%eax
ret

LLVM IR (-O0):
define i32 @get_rd(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 63488
%5 = ashr i32 %4, 11
ret i32 %5
}

LLVM IR (-O2):
define i32 @get_rd(i32 %0) {
%2 = lshr i32 %0, 11
%3 = and i32 %2, 31
ret i32 %3
}
/* Variables and functions */
int yas_mma8453q_read_reg(unsigned char, unsigned char *, int);
int yas_mma8453q_read_reg_byte(unsigned char adr) {
  unsigned char buf;
  int err;
  err = yas_mma8453q_read_reg(adr, &buf, 1);
  if (err == 0) {
    return buf;
  }
  return 0;
}


x86 assembly (clang, -O0):
<yas_mma8453q_read_reg_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
lea    -0x6(%rbp),%rsi
mov    $0x1,%edx
movzbl -0x5(%rbp),%edi
call   1030 <yas_mma8453q_read_reg@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1149 <yas_mma8453q_read_reg_byte+0x39>
movzbl -0x6(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1150 <yas_mma8453q_read_reg_byte+0x40>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yas_mma8453q_read_reg_byte>:
push   %rax
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1030 <yas_mma8453q_read_reg@plt>
xor    %ecx,%ecx
test   %eax,%eax
movzbl 0x7(%rsp),%eax
cmovne %ecx,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @yas_mma8453q_read_reg_byte(i8 zeroext %0) {
%2 = alloca i8
%3 = call i32 @yas_mma8453q_read_reg(i8 zeroext %0, i8* %2, i32 1)
%4 = icmp eq i32 %3, 0
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = select i1 %4, i32 %6, i32 0
ret i32 %7
}