xunge/DecIR huggingface dataset:
int _dotpnrsu2(int src1, unsigned int src2) {
  short ls1 = src1 & 0XFFFF;
  unsigned short ls2 = src2 & 0XFFFF;
  short hs1 = src1 >> 16;
  unsigned short hs2 = src2 >> 16;
  int result = (((long long)(int)(hs1 * hs2)) - ((long long)(int)(ls1 * ls2)) +
                (1 << 15)) >>
               16;
  return result;
}


x86 assembly (clang, -O0):
<_dotpnrsu2>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %ax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    %ax,-0xe(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
mov    %ax,-0x10(%rbp)
movswl -0xe(%rbp),%eax
movzwl -0x10(%rbp),%ecx
imul   %ecx,%eax
cltq
movswl -0xa(%rbp),%ecx
movzwl -0xc(%rbp),%edx
imul   %edx,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
add    $0x8000,%rax
sar    $0x10,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dotpnrsu2>:
movzwl %si,%ecx
shr    $0x10,%esi
movswl %di,%edx
sar    $0x10,%edi
imul   %esi,%edi
movslq %edi,%rax
imul   %edx,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
add    $0x8000,%rax
shr    $0x10,%rax
ret

LLVM IR (-O0):
define i32 @_dotpnrsu2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = and i32 %10, 65535
%12 = trunc i32 %11 to i16
store i16 %12, i16* %5
%13 = load i32, i32* %4
%14 = and i32 %13, 65535
%15 = trunc i32 %14 to i16
store i16 %15, i16* %6
%16 = load i32, i32* %3
%17 = ashr i32 %16, 16
%18 = trunc i32 %17 to i16
store i16 %18, i16* %7
%19 = load i32, i32* %4
%20 = lshr i32 %19, 16
%21 = trunc i32 %20 to i16
store i16 %21, i16* %8
%22 = load i16, i16* %7
%23 = sext i16 %22 to i32
%24 = load i16, i16* %8
%25 = zext i16 %24 to i32
%26 = mul nsw i32 %23, %25
%27 = sext i32 %26 to i64
%28 = load i16, i16* %5
%29 = sext i16 %28 to i32
%30 = load i16, i16* %6
%31 = zext i16 %30 to i32
%32 = mul nsw i32 %29, %31
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %27, %33
%35 = add nsw i64 %34, 32768
%36 = ashr i64 %35, 16
%37 = trunc i64 %36 to i32
store i32 %37, i32* %9
%38 = load i32, i32* %9
ret i32 %38
}

LLVM IR (-O2):
define i32 @_dotpnrsu2(i32 %0, i32 %1) {
%3 = lshr i32 %1, 16
%4 = ashr i32 %0, 16
%5 = mul nsw i32 %3, %4
%6 = sext i32 %5 to i64
%7 = shl i32 %0, 16
%8 = ashr exact i32 %7, 16
%9 = and i32 %1, 65535
%10 = mul nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = sub nsw i64 32768, %11
%13 = add nsw i64 %12, %6
%14 = ashr i64 %13, 16
%15 = trunc i64 %14 to i32
ret i32 %15
}
int ft_isspace(int c) { return ((9 <= c && c <= 13) || c == 32); }


x86 assembly (clang, -O0):
<ft_isspace>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0x9,%eax
cmp    -0x4(%rbp),%eax
jg     1124 <ft_isspace+0x24>
mov    $0x1,%al
cmpl   $0xd,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jle    112e <ft_isspace+0x2e>
cmpl   $0x20,-0x4(%rbp)
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_isspace>:
lea    -0x9(%rdi),%eax
cmp    $0x5,%eax
setb   %al
cmp    $0x20,%edi
sete   %cl
or     %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @ft_isspace(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sle i32 9, %3
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 13
br i1 %7, label %11, label %8
8: ; preds = %5, %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 32
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
ret i32 %13
}

LLVM IR (-O2):
define i32 @ft_isspace(i32 %0) {
%2 = add i32 %0, -9
%3 = icmp ult i32 %2, 5
%4 = icmp eq i32 %0, 32
%5 = or i1 %4, %3
%6 = zext i1 %5 to i32
ret i32 %6
}
ffs(mask) register long mask;
{
  register int cnt;
  if (mask == 0)
    return (0);
  for (cnt = 1; !(mask & 1); cnt++)
    mask >>= 1;
  return (cnt);
}


x86 assembly (clang, -O0):
<ffs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    111f <ffs+0x1f>
movl   $0x0,-0x4(%rbp)
jmp    1164 <ffs+0x64>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1144 <ffs+0x44>
jmp    115e <ffs+0x5e>
mov    -0x10(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <ffs+0x26>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffs>:
test   %rdi,%rdi
je     1130 <ffs+0x30>
mov    $0x1,%eax
test   $0x1,%dil
jne    112f <ffs+0x2f>
mov    $0x1,%eax
mov    %rdi,%rcx
nopl   0x0(%rax,%rax,1)
sar    %rcx
add    $0x1,%eax
test   $0x2,%dil
mov    %rcx,%rdi
je     1120 <ffs+0x20>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @ffs(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %22
8: ; preds = %1
store i32 1, i32* %4
br label %9
9: ; preds = %17, %8
%10 = load i64, i64* %3
%11 = and i64 %10, 1
%12 = icmp ne i64 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i64, i64* %3
%16 = ashr i64 %15, 1
store i64 %16, i64* %3
br label %17
17: ; preds = %14
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %9
20: ; preds = %9
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %7
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @ffs(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = and i64 %0, 1
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3, %6
%7 = phi i32 [ %10, %6 ], [ 1, %3 ]
%8 = phi i64 [ %9, %6 ], [ %0, %3 ]
%9 = ashr i64 %8, 1
%10 = add nuw nsw i32 %7, 1
%11 = and i64 %8, 2
%12 = icmp eq i64 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %6, %3, %1
%14 = phi i32 [ 0, %1 ], [ 1, %3 ], [ %10, %6 ]
ret i32 %14
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ wheatLog(int, char *, char const *, char const *, int);
int /*<<< orphan*/ wheat_stacktrace(int);
void wheat_assert(const char *cond, const char *file, int line, int panic) {
  wheatLog(4, "assert '%s' failed @ (%s, %d)", cond, file, line);
  if (panic) {
    wheat_stacktrace(1);
    abort();
  }
}


x86 assembly (clang, -O0):
<wheat_assert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    $0x4,%edi
lea    0xea2(%rip),%rsi
call   1040 <wheatLog@plt>
cmpl   $0x0,-0x18(%rbp)
je     117e <wheat_assert+0x4e>
mov    $0x1,%edi
call   1050 <wheat_stacktrace@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wheat_assert>:
push   %rbx
mov    %ecx,%ebx
mov    %edx,%r8d
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xebd(%rip),%rsi
mov    $0x4,%edi
call   1040 <wheatLog@plt>
test   %ebx,%ebx
jne    1153 <wheat_assert+0x23>
pop    %rbx
ret
mov    $0x1,%edi
call   1050 <wheat_stacktrace@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"assert '%s' failed @ (%s, %d)\00"
define void @wheat_assert(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i32 @wheatLog(i32 4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i32 %11)
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = call i32 @wheat_stacktrace(i32 1)
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"assert '%s' failed @ (%s, %d)\00"
define void @wheat_assert(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @wheatLog(i32 4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %2)
%6 = icmp eq i32 %3, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @wheat_stacktrace(i32 1)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %4
ret void
}
unsigned singleIf(unsigned y) {
  unsigned ret = 0;
  if (y) {
    ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<singleIf>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     111f <singleIf+0x1f>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<singleIf>:
xor    %eax,%eax
test   %edi,%edi
setne  %al
ret

LLVM IR (-O0):
define i32 @singleIf(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %3
br label %7
7: ; preds = %6, %1
%8 = load i32, i32* %3
ret i32 %8
}

LLVM IR (-O2):
define i32 @singleIf(i32 %0) {
%2 = icmp ne i32 %0, 0
%3 = zext i1 %2 to i32
ret i32 %3
}
double simple_atof(const char *str) {
  double result = 0.0;
  return result;
}


x86 assembly (clang, -O0):
<simple_atof>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_atof>:
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @simple_atof(i8* %0) {
%2 = alloca i8*
%3 = alloca double
store i8* %0, i8** %2
store double 0.000000e+00, double* %3
%4 = load double, double* %3
ret double %4
}

LLVM IR (-O2):
define double @simple_atof(i8* nocapture readnone %0) {
ret double 0.000000e+00
}
/* Variables and functions */
int /*<<< orphan*/ test_audio_detect();
int /*<<< orphan*/ test_conversions();
int /*<<< orphan*/ test_double_convert();
int /*<<< orphan*/ test_endswap();
int /*<<< orphan*/ test_file_io();
int /*<<< orphan*/ test_float_convert();
int /*<<< orphan*/ test_ima_oki_adpcm();
int /*<<< orphan*/ test_log_printf();
int main(void) {
  test_conversions();
  test_endswap();
  test_float_convert();
  test_double_convert();
  test_log_printf();
  test_file_io();
  test_audio_detect();
  test_ima_oki_adpcm();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <test_conversions@plt>
mov    $0x0,%al
call   10a0 <test_endswap@plt>
mov    $0x0,%al
call   1090 <test_float_convert@plt>
mov    $0x0,%al
call   1070 <test_double_convert@plt>
mov    $0x0,%al
call   1030 <test_log_printf@plt>
mov    $0x0,%al
call   1060 <test_file_io@plt>
mov    $0x0,%al
call   1040 <test_audio_detect@plt>
mov    $0x0,%al
call   1080 <test_ima_oki_adpcm@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <test_conversions@plt>
xor    %eax,%eax
call   10a0 <test_endswap@plt>
xor    %eax,%eax
call   1090 <test_float_convert@plt>
xor    %eax,%eax
call   1070 <test_double_convert@plt>
xor    %eax,%eax
call   1030 <test_log_printf@plt>
xor    %eax,%eax
call   1060 <test_file_io@plt>
xor    %eax,%eax
call   1040 <test_audio_detect@plt>
xor    %eax,%eax
call   1080 <test_ima_oki_adpcm@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @test_conversions()
%3 = call i32 (...) @test_endswap()
%4 = call i32 (...) @test_float_convert()
%5 = call i32 (...) @test_double_convert()
%6 = call i32 (...) @test_log_printf()
%7 = call i32 (...) @test_file_io()
%8 = call i32 (...) @test_audio_detect()
%9 = call i32 (...) @test_ima_oki_adpcm()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @test_conversions()
%2 = tail call i32 (...) @test_endswap()
%3 = tail call i32 (...) @test_float_convert()
%4 = tail call i32 (...) @test_double_convert()
%5 = tail call i32 (...) @test_log_printf()
%6 = tail call i32 (...) @test_file_io()
%7 = tail call i32 (...) @test_audio_detect()
%8 = tail call i32 (...) @test_ima_oki_adpcm()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int const);
void prnArr(const int size, const int *const arr) {
  for (int i = 0; i < size; i++) {
    printf("%d ", arr[i]);
  }
}


x86 assembly (clang, -O0):
<prnArr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1157 <prnArr+0x47>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <prnArr+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prnArr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1145 <prnArr+0x35>
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebx,%ebx
lea    0xed5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <prnArr+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define void @prnArr(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %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* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %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
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @prnArr(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %7
6: ; preds = %7, %2
ret void
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %12, %7 ]
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = load i32, i32* %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %5
br i1 %13, label %6, label %7
}
float dummy_fontheight(int id) {
  id = id;
  return 1.0;
}


x86 assembly (clang, -O0):
<dummy_fontheight>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movss  0xeeb(%rip),%xmm0
pop    %rbp
ret

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

LLVM IR (-O0):
define float @dummy_fontheight(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
store i32 %3, i32* %2
ret float 1.000000e+00
}

LLVM IR (-O2):
define float @dummy_fontheight(i32 %0) {
ret float 1.000000e+00
}
/* Variables and functions */
int *malloc(int);
void f(void) {
  int *x = malloc(10 * sizeof(int));
  x[10] = 0;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x28,%edi
call   1030 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,0x28(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
mov    $0x28,%edi
jmp    1030 <malloc@plt>

LLVM IR (-O0):
define void @f() {
%1 = alloca i32*
%2 = call i32* @malloc(i32 40)
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = getelementptr inbounds i32, i32* %3, i64 10
store i32 0, i32* %4
ret void
}

LLVM IR (-O2):
define void @f() {
%1 = tail call i32* @malloc(i32 40)
ret void
}
/* Variables and functions */
long _POSIX_VERSION;
long int get_posix_version() { return (1 == 1) ? _POSIX_VERSION : 0; }


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

x86 assembly (clang, -O2):
<get_posix_version>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%rax
ret

LLVM IR (-O0):
@_POSIX_VERSION = global i64 0
define i64 @get_posix_version() {
%1 = load i64, i64* @_POSIX_VERSION
ret i64 %1
}

LLVM IR (-O2):
@_POSIX_VERSION = global i64 0
define i64 @get_posix_version() {
%1 = load i64, i64* @_POSIX_VERSION
ret i64 %1
}
/* Variables and functions */
int /*<<< orphan*/ vram_adr(unsigned int);
int /*<<< orphan*/ vram_put(unsigned char const);
void print_str(unsigned int adr, const unsigned char *str) {
  vram_adr(adr);
  while (*str) {
    vram_put((*str) + 0x80);
    str++;
  }
}


x86 assembly (clang, -O0):
<print_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <vram_adr@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1169 <print_str+0x49>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0x80,%eax
movzbl %al,%edi
call   1030 <vram_put@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <print_str+0x17>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_str>:
push   %rbx
mov    %rsi,%rbx
call   1040 <vram_adr@plt>
mov    (%rbx),%al
test   %al,%al
je     1155 <print_str+0x35>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    $0x80,%al
movzbl %al,%edi
call   1030 <vram_put@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <print_str+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @print_str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = call i32 @vram_adr(i32 %5)
br label %7
7: ; preds = %11, %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = add nsw i32 %14, 128
%16 = trunc i32 %15 to i8
%17 = call i32 @vram_put(i8 zeroext %16)
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
br label %7
20: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @print_str(i32 %0, i8* nocapture %1) {
%3 = tail call i32 @vram_adr(i32 %0)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i8 [ %12, %6 ], [ %4, %2 ]
%8 = phi i8* [ %11, %6 ], [ %1, %2 ]
%9 = xor i8 %7, -128
%10 = tail call i32 @vram_put(i8 zeroext %9)
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %2
ret void
}
int CalcDV11(s)
char *s;
{
  int res;
  res = _calcDV11(s, 2, 9);
  res = (res % 11);
  res = 11 - res;
  if (res > 9)
    res = 1;
  return res + 48;
}


x86 assembly (clang, -O0):
<CalcDV11>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
mov    $0x9,%edx
mov    $0x0,%al
call   1030 <_calcDV11@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0xb,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jle    115e <CalcDV11+0x4e>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcDV11>:
push   %rax
mov    $0x2,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1030 <_calcDV11@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
sub    %ecx,%eax
mov    $0x3b,%ecx
sub    %eax,%ecx
cmp    $0x2,%eax
mov    $0x31,%eax
cmovge %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @CalcDV11(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @_calcDV11 to i32 (i8*, i32, i32, ...)*)(i8* %4, i32 2, i32 9)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = srem i32 %6, 11
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = sub nsw i32 11, %8
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 9
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 1, i32* %3
br label %13
13: ; preds = %12, %1
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 48
ret i32 %15
}

LLVM IR (-O2):
define i32 @CalcDV11(i8* %0) {
%2 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @_calcDV11 to i32 (i8*, i32, i32, ...)*)(i8* %0, i32 2, i32 9)
%3 = srem i32 %2, 11
%4 = icmp sgt i32 %3, 1
%5 = sub nsw i32 59, %3
%6 = select i1 %4, i32 %5, i32 49
ret i32 %6
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
scalar_t__ fread(int *, int, int, int /*<<< orphan*/ *);
int fgetc(FILE *stream) {
  int c = 0;
  if (fread(&c, sizeof(char), 1, stream) == 0) {
    return EOF;
  }
  return c;
}


x86 assembly (clang, -O0):
<fgetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
jne    1152 <fgetc+0x42>
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1158 <fgetc+0x48>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgetc>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rcx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
test   %rax,%rax
jne    1143 <fgetc+0x33>
mov    0x2ea5(%rip),%rbx
mov    (%rbx),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fgetc(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
%5 = load i32*, i32** %3
%6 = call i64 @fread(i32* %4, i32 1, i32 1, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* @EOF
store i32 %9, i32* %2
br label %12
10: ; preds = %1
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @fgetc(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i64 @fread(i32* %2, i32 1, i32 1, i32* %0)
%5 = icmp eq i64 %4, 0
%6 = load i32, i32* @EOF
%7 = load i32, i32* %2
%8 = select i1 %5, i32 %6, i32 %7
ret i32 %8
}
/* Type definitions */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_fac_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_init_set_si(int /*<<< orphan*/, int);
int mpz_sizeinbase(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  mpz_t a;
  mpz_init_set_si(a, 14);
  mpz_fac_ui(a, 140000);
  int size = mpz_sizeinbase(a, 10);
  printf("%d\n", size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
mov    $0xe,%esi
call   1060 <mpz_init_set_si@plt>
mov    -0x14(%rbp),%edi
mov    $0x222e0,%esi
call   1050 <mpz_fac_ui@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1040 <mpz_sizeinbase@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xe,%esi
call   1060 <mpz_init_set_si@plt>
mov    $0x222e0,%esi
call   1050 <mpz_fac_ui@plt>
mov    $0xa,%esi
call   1040 <mpz_sizeinbase@plt>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %6
%9 = call i32 @mpz_init_set_si(i32 %8, i32 14)
%10 = load i32, i32* %6
%11 = call i32 @mpz_fac_ui(i32 %10, i32 140000)
%12 = load i32, i32* %6
%13 = call i32 @mpz_sizeinbase(i32 %12, i32 10)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init_set_si(i32 undef, i32 14)
%4 = tail call i32 @mpz_fac_ui(i32 undef, i32 140000)
%5 = tail call i32 @mpz_sizeinbase(i32 undef, i32 10)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}
void GrOffScreen1BPPFlush(void *pvDisplayData) { ; }


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

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

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

LLVM IR (-O2):
define void @GrOffScreen1BPPFlush(i8* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isupper(int);
void t_isupper_0xf6() {
  Assert_real((isupper(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_isupper.c",
              1235, ("isupper should be 0 for 0xf6"));
}


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

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

LLVM IR (-O0):
@.str = [168 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_isupper.c\00"
@.str.1 = [29 x i8] c"isupper should be 0 for 0xf6\00"
define void @t_isupper_0xf6() {
%1 = call i64 @isupper(i32 246)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 1235, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 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_isupper.c\00"
@.str.1 = [29 x i8] c"isupper should be 0 for 0xf6\00"
define void @t_isupper_0xf6() {
%1 = tail call i64 @isupper(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 ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 1235, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
unsigned long ape2long(unsigned char *p) {
  return (((unsigned long)p[0] << 0) | ((unsigned long)p[1] << 8) |
          ((unsigned long)p[2] << 16) | ((unsigned long)p[3] << 24));
}


x86 assembly (clang, -O0):
<ape2long>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x0,%rax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%rcx
or     %rcx,%rax
mov    -0x8(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x10,%rcx
or     %rcx,%rax
mov    -0x8(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
shl    $0x18,%rcx
or     %rcx,%rax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i64 @ape2long(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = zext i8 %5 to i64
%7 = shl nuw nsw i64 %6, 8
%8 = or i64 %7, %3
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i64
%12 = shl nuw nsw i64 %11, 16
%13 = or i64 %8, %12
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = zext i8 %15 to i64
%17 = shl nuw nsw i64 %16, 24
%18 = or i64 %13, %17
ret i64 %18
}
/* Variables and functions */
int /*<<< orphan*/ video_update_through_line(int);
void display_screen() { video_update_through_line(262); }


x86 assembly (clang, -O0):
<display_screen>:
push   %rbp
mov    %rsp,%rbp
mov    $0x106,%edi
call   1030 <video_update_through_line@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_screen>:
mov    $0x106,%edi
jmp    1030 <video_update_through_line@plt>

LLVM IR (-O0):
define void @display_screen() {
%1 = call i32 @video_update_through_line(i32 262)
ret void
}

LLVM IR (-O2):
define void @display_screen() {
%1 = tail call i32 @video_update_through_line(i32 262)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *realloc(void *, size_t);
int /*<<< orphan*/ stderr;
void *xrealloc(void *old_ptr, size_t size) {
  void *ptr = realloc(old_ptr, size);
  if (!ptr) {
    fprintf(stderr, "Out of memory, realloc\n");
    exit(1);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<xrealloc>:
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   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117b <xrealloc+0x4b>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrealloc>:
push   %rax
call   1040 <realloc@plt>
test   %rax,%rax
je     113d <xrealloc+0xd>
pop    %rcx
ret
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Out of memory, realloc\0A\00"
define i8* @xrealloc(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = load i64, i64* %4
%8 = call i8* @realloc(i8* %6, i64 %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8*, i8** %5
ret i8* %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Out of memory, realloc\0A\00"
define noalias i8* @xrealloc(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @realloc(i8* %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
ret i8* %3
}
/* Type definitions */
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ sg_str_toi(char *, size_t, char **);
int sg_str_toi_buf(char *s, size_t n, void *buf) {
  int32_t v;
  char *e;
  v = sg_str_toi(s, n, &e);
  if (s + n != e)
    return -1;
  *((int32_t *)buf) = v;
  return 0;
}


x86 assembly (clang, -O0):
<sg_str_toi_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <sg_str_toi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1156 <sg_str_toi_buf+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1166 <sg_str_toi_buf+0x56>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sg_str_toi_buf>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x8(%rsp),%rdx
call   1030 <sg_str_toi@plt>
add    %r15,%rbx
mov    $0xffffffff,%ecx
cmp    0x8(%rsp),%rbx
jne    1140 <sg_str_toi_buf+0x30>
mov    %eax,(%r14)
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @sg_str_toi_buf(i8* %0, i64 %1, i8* nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 @sg_str_toi(i8* %0, i64 %1, i8** %4)
%7 = getelementptr inbounds i8, i8* %0, i64 %1
%8 = load i8*, i8** %4
%9 = icmp eq i8* %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = bitcast i8* %2 to i32*
store i32 %6, i32* %11
br label %12
12: ; preds = %3, %10
%13 = phi i32 [ 0, %10 ], [ -1, %3 ]
ret i32 %13
}
/* Variables and functions */
void *ft_memset(void *b, int c, size_t len) {
  size_t i;
  unsigned char *tmp;
  i = 0;
  tmp = (unsigned char *)b;
  while (i < len) {
    tmp[i] = (unsigned char)c;
    i++;
  }
  return (b);
}


x86 assembly (clang, -O0):
<ft_memset>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    114e <ft_memset+0x4e>
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    111f <ft_memset+0x1f>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_memset>:
push   %rbx
mov    %rdi,%rbx
test   %rdx,%rdx
je     1121 <ft_memset+0x11>
mov    %rbx,%rdi
call   1030 <memset@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @ft_memset(i8* returned writeonly %0, i32 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = trunc i32 %1 to i8
br label %7
7: ; preds = %5, %3
ret i8* %0
}
float get_biggest(float a, float b, float c) {
  if (a > b && a > c) {
    return a;
  } else if (b > a && b > c) {
    return b;
  }
  return c;
}


x86 assembly (clang, -O0):
<get_biggest>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1140 <get_biggest+0x40>
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    1140 <get_biggest+0x40>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    117c <get_biggest+0x7c>
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    116d <get_biggest+0x6d>
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    116d <get_biggest+0x6d>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    117c <get_biggest+0x7c>
jmp    1172 <get_biggest+0x72>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_biggest>:
movaps %xmm1,%xmm3
maxss  %xmm2,%xmm3
movaps %xmm0,%xmm4
cmpltss %xmm1,%xmm4
andps  %xmm4,%xmm3
andnps %xmm2,%xmm4
orps   %xmm3,%xmm4
cmpltss %xmm0,%xmm1
cmpltss %xmm0,%xmm2
andps  %xmm2,%xmm0
andnps %xmm4,%xmm2
orps   %xmm2,%xmm0
andps  %xmm1,%xmm0
andnps %xmm4,%xmm1
orps   %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @get_biggest(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%8 = load float, float* %5
%9 = load float, float* %6
%10 = fcmp ogt float %8, %9
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load float, float* %5
%13 = load float, float* %7
%14 = fcmp ogt float %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load float, float* %5
store float %16, float* %4
br label %30
17: ; preds = %11, %3
%18 = load float, float* %6
%19 = load float, float* %5
%20 = fcmp ogt float %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load float, float* %6
%23 = load float, float* %7
%24 = fcmp ogt float %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load float, float* %6
store float %26, float* %4
br label %30
27: ; preds = %21, %17
br label %28
28: ; preds = %27
%29 = load float, float* %7
store float %29, float* %4
br label %30
30: ; preds = %28, %25, %15
%31 = load float, float* %4
ret float %31
}

LLVM IR (-O2):
define float @get_biggest(float %0, float %1, float %2) {
%4 = fcmp ogt float %0, %1
%5 = fcmp ogt float %0, %2
%6 = and i1 %4, %5
%7 = fcmp ogt float %1, %0
%8 = fcmp ogt float %1, %2
%9 = and i1 %7, %8
%10 = select i1 %9, float %1, float %2
%11 = select i1 %6, float %0, float %10
ret float %11
}
int test_imm_00uint64_midword_mem(unsigned long long *val) {
  return ((*val >> 16) & (0x00 << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
mov    $0xffffffd8,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_00uint64_midword_mem(i64* nocapture readnone %0) {
ret i32 -40
}
char *sub() {
  char buf[10];
  return buf;
}


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

x86 assembly (clang, -O2):
<sub>:
lea    -0xa(%rsp),%rax
ret

LLVM IR (-O0):
define i8* @sub() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
ret i8* %2
}

LLVM IR (-O2):
define noalias i8* @sub() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
ret i8* %2
}
int square(int arg) { return arg * arg; }


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

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

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

LLVM IR (-O2):
define i32 @square(i32 %0) {
%2 = mul nsw i32 %0, %0
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ wdt_reset();
void feed_watchdog_cb(unsigned long time) { wdt_reset(); }


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

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

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

LLVM IR (-O2):
define void @feed_watchdog_cb(i64 %0) {
%2 = tail call i32 (...) @wdt_reset()
ret void
}
int test_imm_8Eint16_mem(short *val) {
  return ((*val) & (-0x8E << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_8Eint16_mem>:
movzwl (%rdi),%eax
test   $0xff72,%eax
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_8Eint16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, -142
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void nrerror(char *error_text) {
  fprintf(stderr, "Numerical Recipes run-time error...\n");
  fprintf(stderr, "%s\n", error_text);
  fprintf(stderr, "...now exiting to system...\n");
  exit(1);
}


x86 assembly (clang, -O0):
<nrerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<nrerror>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb2(%rip),%r14
mov    (%r14),%edi
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xedc(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xecc(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"Numerical Recipes run-time error...\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [29 x i8] c"...now exiting to system...\0A\00"
define void @nrerror(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %2
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"Numerical Recipes run-time error...\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [29 x i8] c"...now exiting to system...\0A\00"
define void @nrerror(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
}
int ptr_equal(char *a, char *b) { return a == b; }


x86 assembly (clang, -O0):
<ptr_equal>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptr_equal>:
xor    %eax,%eax
cmp    %rsi,%rdi
sete   %al
ret

LLVM IR (-O0):
define i32 @ptr_equal(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** %4
%7 = icmp eq i8* %5, %6
%8 = zext i1 %7 to i32
ret i32 %8
}

LLVM IR (-O2):
define i32 @ptr_equal(i8* readnone %0, i8* readnone %1) {
%3 = icmp eq i8* %0, %1
%4 = zext i1 %3 to i32
ret i32 %4
}