xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int getJudgeNo() {
  int judgeNo = 0;
  do {
    printf("Number of judges (min %d and max %d judges)? ", 3, 10);
    scanf("%d", &judgeNo);
  } while ((judgeNo < 3) || (judgeNo > 10));
  return judgeNo;
}


x86 assembly (clang, -O0):
<getJudgeNo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x3,%esi
mov    $0xa,%edx
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x3,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     116e <getJudgeNo+0x4e>
cmpl   $0xa,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    112f <getJudgeNo+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getJudgeNo>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec8(%rip),%r14
lea    0xeef(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0xa,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0xb(%rax),%ecx
cmp    $0xfffffff8,%ecx
jb     1150 <getJudgeNo+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Number of judges (min %d and max %d judges)? \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getJudgeNo() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %11, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 3, i32 10)
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %2
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 3
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 10
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
br i1 %12, label %2, label %13
13: ; preds = %11
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [46 x i8] c"Number of judges (min %d and max %d judges)? \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getJudgeNo() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %3, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 3, i32 10)
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -11
%8 = icmp ult i32 %7, -8
br i1 %8, label %3, label %9
9: ; preds = %3
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ add_client(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ init_sf_source(int);
void new_client(int fd) {
  fcntl(fd, F_SETFL, 0);
  if (init_sf_source(fd) < 0)
    close(fd);
  else
    add_client(fd);
}


x86 assembly (clang, -O0):
<new_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x4(%rbp),%edi
call   1040 <init_sf_source@plt>
cmp    $0x0,%rax
jge    117d <new_client+0x3d>
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
jmp    1185 <new_client+0x45>
mov    -0x4(%rbp),%edi
call   1060 <add_client@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_client>:
push   %rbx
mov    %edi,%ebx
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %ebx,%edi
call   1040 <init_sf_source@plt>
mov    %ebx,%edi
test   %rax,%rax
js     1167 <new_client+0x27>
pop    %rbx
jmp    1060 <add_client@plt>
pop    %rbx
jmp    1050 <close@plt>

LLVM IR (-O0):
@F_SETFL = global i32 0
define void @new_client(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @F_SETFL
%5 = call i32 @fcntl(i32 %3, i32 %4, i32 0)
%6 = load i32, i32* %2
%7 = call i64 @init_sf_source(i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 @close(i32 %10)
br label %15
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i32 @add_client(i32 %13)
br label %15
15: ; preds = %12, %9
ret void
}

LLVM IR (-O2):
@F_SETFL = global i32 0
define void @new_client(i32 %0) {
%2 = load i32, i32* @F_SETFL
%3 = tail call i32 @fcntl(i32 %0, i32 %2, i32 0)
%4 = tail call i64 @init_sf_source(i32 %0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @close(i32 %0)
br label %10
8: ; preds = %1
%9 = tail call i32 @add_client(i32 %0)
br label %10
10: ; preds = %8, %6
ret void
}
int char_length(const char *pointer) { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @char_length(i8* nocapture readnone %0) {
ret i32 1
}
int crtbit(int i) { return 1 << i; }


x86 assembly (clang, -O0):
<crtbit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<crtbit>:
mov    %edi,%ecx
mov    $0x1,%eax
shl    %cl,%eax
ret

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

LLVM IR (-O2):
define i32 @crtbit(i32 %0) {
%2 = shl nuw i32 1, %0
ret i32 %2
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
bool utf8_check_2(uint8_t *data) {
  if (((data[0] >= 0xC2) && (data[0] <= 0xDF)) &&
      ((data[1] >= 0x80) && (data[1] <= 0xBF))) {
    return (true);
  }
  return (false);
}


x86 assembly (clang, -O0):
<utf8_check_2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0xc2,(%rax)
jl     1156 <utf8_check_2+0x56>
mov    -0x10(%rbp),%rax
cmpl   $0xdf,(%rax)
jg     1156 <utf8_check_2+0x56>
mov    -0x10(%rbp),%rax
cmpl   $0x80,0x4(%rax)
jl     1156 <utf8_check_2+0x56>
mov    -0x10(%rbp),%rax
cmpl   $0xbf,0x4(%rax)
jg     1156 <utf8_check_2+0x56>
movl   $0x1,-0x4(%rbp)
jmp    115d <utf8_check_2+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_check_2>:
mov    $0xffffff3e,%eax
add    (%rdi),%eax
cmp    $0x1d,%eax
ja     111f <utf8_check_2+0x1f>
mov    0x4(%rdi),%ecx
and    $0xffffffc0,%ecx
mov    $0x1,%eax
cmp    $0x80,%ecx
je     1121 <utf8_check_2+0x21>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @utf8_check_2(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = add i32 %2, -194
%4 = icmp ult i32 %3, 30
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = load i32, i32* %6
%8 = and i32 %7, -64
%9 = icmp eq i32 %8, 128
br i1 %9, label %11, label %10
10: ; preds = %5, %1
br label %11
11: ; preds = %5, %10
%12 = phi i32 [ 0, %10 ], [ 1, %5 ]
ret i32 %12
}
int isupper(int character) { return (character >= 'A' && character <= 'Z'); }


x86 assembly (clang, -O0):
<isupper>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x41,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1120 <isupper+0x20>
cmpl   $0x5a,-0x4(%rbp)
setle  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isupper>:
add    $0xffffffbf,%edi
xor    %eax,%eax
cmp    $0x1a,%edi
setb   %al
ret

LLVM IR (-O0):
define i32 @isupper(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 65
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 90
br label %8
8: ; preds = %5, %1
%9 = phi i1 [ false, %1 ], [ %7, %5 ]
%10 = zext i1 %9 to i32
ret i32 %10
}

LLVM IR (-O2):
define i32 @isupper(i32 %0) {
%2 = add i32 %0, -65
%3 = icmp ult i32 %2, 26
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ abort();
long long div(long long);
int main(void) {
  long long d1 = -990000000;
  long long d2 = div(d1);
  if (d2 != -30212)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xffffffffc4fdcc80,-0x10(%rbp)
c4
mov    -0x10(%rbp),%rdi
call   1040 <div@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffff89fc,-0x18(%rbp)
ff
je     1159 <main+0x39>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xffffffffc4fdcc80,%rdi
call   1040 <div@plt>
cmp    $0xffffffffffff89fc,%rax
jne    1139 <main+0x19>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 -990000000, i64* %2
%4 = load i64, i64* %2
%5 = call i64 @div(i64 %4)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp ne i64 %6, -30212
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @div(i64 -990000000)
%2 = icmp eq i64 %1, -30212
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %0
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ ft_putchar_fd(char const, int);
void ft_putendl_fd(char const *str, int fd) {
  while (*str) {
    ft_putchar_fd(*str, fd);
    str++;
  }
  ft_putchar_fd('\n', fd);
}


x86 assembly (clang, -O0):
<ft_putendl_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     114e <ft_putendl_fd+0x3e>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0xc(%rbp),%esi
movsbl %al,%edi
call   1030 <ft_putchar_fd@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111f <ft_putendl_fd+0xf>
mov    -0xc(%rbp),%esi
mov    $0xa,%edi
call   1030 <ft_putchar_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putendl_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    (%rdi),%al
test   %al,%al
je     1145 <ft_putendl_fd+0x35>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
mov    %ebp,%esi
call   1030 <ft_putchar_fd@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <ft_putendl_fd+0x20>
mov    $0xa,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putchar_fd@plt>

LLVM IR (-O0):
define void @ft_putendl_fd(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %9, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = load i32, i32* %4
%13 = call i32 @ft_putchar_fd(i8 signext %11, i32 %12)
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
br label %5
16: ; preds = %5
%17 = load i32, i32* %4
%18 = call i32 @ft_putchar_fd(i8 signext 10, i32 %17)
ret void
}

LLVM IR (-O2):
define void @ft_putendl_fd(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %10, %5 ], [ %3, %2 ]
%7 = phi i8* [ %9, %5 ], [ %0, %2 ]
%8 = tail call i32 @ft_putchar_fd(i8 signext %6, i32 %1)
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %2
%13 = tail call i32 @ft_putchar_fd(i8 signext 10, i32 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
void myfree(void *p) {
  if (p)
    free(p);
}


x86 assembly (clang, -O0):
<myfree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1130 <myfree+0x20>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myfree>:
test   %rdi,%rdi
je     111a <myfree+0xa>
jmp    1030 <free@plt>
ret

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

LLVM IR (-O2):
define void @myfree(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @free(i8* %0)
br label %5
5: ; preds = %3, %1
ret void
}
void unsigned_char_shr_signed_char_unsigned_char(unsigned char *LHS,
                                                 unsigned char RHS) {
  (*LHS) >>= RHS;
}


x86 assembly (clang, -O0):
<unsigned_char_shr_signed_char_unsigned_char>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%ecx
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
sar    %cl,%edx
mov    %edx,%ecx
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<unsigned_char_shr_signed_char_unsigned_char>:
mov    %esi,%ecx
movzbl (%rdi),%eax
shr    %cl,%eax
mov    %al,(%rdi)
ret

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

LLVM IR (-O2):
define void @unsigned_char_shr_signed_char_unsigned_char(i8* nocapture %0, i8 zeroext %1) {
%3 = zext i8 %1 to i32
%4 = load i8, i8* %0
%5 = zext i8 %4 to i32
%6 = lshr i32 %5, %3
%7 = trunc i32 %6 to i8
store i8 %7, i8* %0
ret void
}
/* Type definitions */
struct timespec {
  unsigned long long tv_sec;
  unsigned long long tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
unsigned long long _get_timestamp(void) {
  struct timespec t;
  clock_gettime(CLOCK_MONOTONIC, &t);
  return t.tv_sec * 1000000000ull + t.tv_nsec;
}


x86 assembly (clang, -O0):
<_get_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x3b9aca00,-0x10(%rbp),%rax
3b
add    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_timestamp>:
sub    $0x18,%rsp
mov    0x2ecd(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x3b9aca00,0x8(%rsp),%rax
9a 3b
add    0x10(%rsp),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
define i64 @_get_timestamp() {
%1 = alloca %struct.timespec
%2 = load i32, i32* @CLOCK_MONOTONIC
%3 = call i32 @clock_gettime(i32 %2, %struct.timespec* %1)
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%5 = load i64, i64* %4
%6 = mul i64 %5, 1000000000
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%8 = load i64, i64* %7
%9 = add i64 %6, %8
ret i64 %9
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
define i64 @_get_timestamp() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = mul i64 %6, 1000000000
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = add i64 %7, %9
ret i64 %10
}
/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
char *build_process_status_path(char *buff, const char *pid) {
  strcpy(buff, "/proc/");
  strcat(buff, pid);
  strcat(buff, "/status");
  return buff;
}


x86 assembly (clang, -O0):
<build_process_status_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_process_status_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [8 x i8] c"/status\00"
define i8* @build_process_status_path(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 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32 @strcat(i8* %7, i8* %8)
%10 = load i8*, i8** %3
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %3
ret i8* %12
}

LLVM IR (-O2):
@.str = [7 x i8] c"/proc/\00"
@.str.1 = [8 x i8] c"/status\00"
define i8* @build_process_status_path(i8* returned %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strcat(i8* %0, i8* %1)
%5 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
ret i8* %0
}
/* Variables and functions */
double exp(int);
float fx(float x) { return 1.5 * exp(2 * x) - x * x - x - 0.5; }


x86 assembly (clang, -O0):
<fx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xeeb(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <exp@plt>
movss  -0x4(%rbp),%xmm1
mulss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xea8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe83(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fx>:
push   %rax
movss  %xmm0,0x4(%rsp)
movaps %xmm0,%xmm1
addss  %xmm0,%xmm1
cvttss2si %xmm1,%edi
call   1030 <exp@plt>
movss  0x4(%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulss  %xmm2,%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  0xebc(%rip),%xmm0
subsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
addsd  0xeb4(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @fx(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fmul float 2.000000e+00, %3
%5 = fptosi float %4 to i32
%6 = call double @exp(i32 %5)
%7 = load float, float* %2
%8 = load float, float* %2
%9 = fmul float %7, %8
%10 = fpext float %9 to double
%11 = fneg double %10
%12 = call double @llvm.fmuladd.f64(double 1.500000e+00, double %6, double %11)
%13 = load float, float* %2
%14 = fpext float %13 to double
%15 = fsub double %12, %14
%16 = fsub double %15, 5.000000e-01
%17 = fptrunc double %16 to float
ret float %17
}

LLVM IR (-O2):
define float @fx(float %0) {
%2 = fmul float %0, 2.000000e+00
%3 = fptosi float %2 to i32
%4 = tail call double @exp(i32 %3)
%5 = fmul float %0, %0
%6 = fpext float %5 to double
%7 = fneg double %6
%8 = tail call double @llvm.fmuladd.f64(double %4, double 1.500000e+00, double %7)
%9 = fpext float %0 to double
%10 = fsub double %8, %9
%11 = fadd double %10, -5.000000e-01
%12 = fptrunc double %11 to float
ret float %12
}
/* Variables and functions */
int /*<<< orphan*/ T2Cam_errormsg();
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void T2Cam_CloseLib() {
  T2Cam_errormsg();
  assert(0);
}


x86 assembly (clang, -O0):
<T2Cam_CloseLib>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <T2Cam_errormsg@plt>
xor    %edi,%edi
call   1040 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<T2Cam_CloseLib>:
push   %rax
xor    %eax,%eax
call   1030 <T2Cam_errormsg@plt>
xor    %edi,%edi
pop    %rax
jmp    1040 <assert@plt>

LLVM IR (-O0):
define void @T2Cam_CloseLib() {
%1 = call i32 (...) @T2Cam_errormsg()
%2 = call i32 @assert(i32 0)
ret void
}

LLVM IR (-O2):
define void @T2Cam_CloseLib() {
%1 = tail call i32 (...) @T2Cam_errormsg()
%2 = tail call i32 @assert(i32 0)
ret void
}
int toTheFourthPower(int x) { return x * (x * (x * x)); }


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

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

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

LLVM IR (-O2):
define i32 @toTheFourthPower(i32 %0) {
%2 = mul i32 %0, %0
%3 = mul i32 %2, %2
ret i32 %3
}
/* Variables and functions */
char *__strchrnul(const char *p, int ch) {
  char c;
  c = ch;
  for (;; ++p) {
    if (*p == c || *p == '\0')
      return ((char *)p);
  }
}


x86 assembly (clang, -O0):
<__strchrnul>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0xd(%rbp),%ecx
cmp    %ecx,%eax
je     1134 <__strchrnul+0x34>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113a <__strchrnul+0x3a>
mov    -0x8(%rbp),%rax
pop    %rbp
ret
jmp    113f <__strchrnul+0x3f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1111 <__strchrnul+0x11>

x86 assembly (clang, -O2):
<__strchrnul>:
mov    %rdi,%rax
movsbl %sil,%ecx
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rax),%edx
add    $0x1,%rax
test   %edx,%edx
je     1120 <__strchrnul+0x20>
cmp    %edx,%ecx
jne    1110 <__strchrnul+0x10>
ret

LLVM IR (-O0):
define i8* @__strchrnul(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 i32, i32* %4
%7 = trunc i32 %6 to i8
store i8 %7, i8* %5
br label %8
8: ; preds = %23, %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %11, %13
br i1 %14, label %20, label %15
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15, %8
%21 = load i8*, i8** %3
ret i8* %21
22: ; preds = %15
br label %23
23: ; preds = %22
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
br label %8
}

LLVM IR (-O2):
define i8* @__strchrnul(i8* %0, i32 %1) {
%3 = shl i32 %1, 24
%4 = ashr exact i32 %3, 24
br label %5
5: ; preds = %5, %2
%6 = phi i8* [ %0, %2 ], [ %12, %5 ]
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %4, %8
%10 = icmp eq i8 %7, 0
%11 = or i1 %10, %9
%12 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %11, label %13, label %5
13: ; preds = %5
ret i8* %6
}
unsigned short calc2(unsigned short x) { return (x << 1) + 3; }


x86 assembly (clang, -O0):
<calc2>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
shl    $0x1,%eax
add    $0x3,%eax
movzwl %ax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc2>:
lea    (%rdi,%rdi,1),%eax
add    $0x3,%eax
ret

LLVM IR (-O0):
define zeroext i16 @calc2(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
%5 = shl i32 %4, 1
%6 = add nsw i32 %5, 3
%7 = trunc i32 %6 to i16
ret i16 %7
}

LLVM IR (-O2):
define zeroext i16 @calc2(i16 zeroext %0) {
%2 = shl i16 %0, 1
%3 = add i16 %2, 3
ret i16 %3
}
/* Variables and functions */
int colliding_name();
int easy_square(int x) { return colliding_name() * x * x; }


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

x86 assembly (clang, -O2):
<easy_square>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <colliding_name@plt>
imul   %ebx,%ebx
imul   %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @easy_square(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @colliding_name()
%4 = load i32, i32* %2
%5 = mul nsw i32 %3, %4
%6 = load i32, i32* %2
%7 = mul nsw i32 %5, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @easy_square(i32 %0) {
%2 = tail call i32 (...) @colliding_name()
%3 = mul i32 %0, %0
%4 = mul i32 %3, %2
ret i32 %4
}
void DefaultISR(void) {
  for (;;)
    ;
}


x86 assembly (clang, -O0):
<DefaultISR>:
push   %rbp
mov    %rsp,%rbp
jmp    1109 <DefaultISR+0x9>
jmp    1109 <DefaultISR+0x9>

x86 assembly (clang, -O2):
<DefaultISR>:
jmp    1100 <DefaultISR>

LLVM IR (-O0):
define void @DefaultISR() {
br label %1
1: ; preds = %1, %0
br label %1
}

LLVM IR (-O2):
define void @DefaultISR() {
br label %1
1: ; preds = %1, %0
br label %1
}
void RTLogFlushToLogger(void) {}


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

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

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

LLVM IR (-O2):
define void @RTLogFlushToLogger() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
void sigh(int type) { exit(1); }


x86 assembly (clang, -O0):
<sigh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1,%edi
call   1030 <exit@plt>

x86 assembly (clang, -O2):
<sigh>:
push   %rax
mov    $0x1,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
define void @sigh(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
define void @sigh(i32 %0) {
%2 = tail call i32 @exit(i32 1)
unreachable
}
int tilt_stat(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @tilt_stat() {
ret i32 0
}
void fd167(int n) {
P0A:
  goto P0A;
  {
    typedef int(*b)[n];
  P01A:
    goto P01A;
    {
      typedef int(*c)[n];
    P012A:
      goto P012A;
      0;
    }
  P01B:
    goto P01B;
    {
      typedef int(*d)[n];
    P013A:
      goto P013A;
      0;
    }
  P01C:
    goto P01C;
    ;
    typedef int(*e)[n];
  P014A:
    goto P014A;
    0;
  };
P0B:
  goto P0B;
  {
    typedef int(*f)[n];
  P02A:
    goto P02A;
    {
      typedef int(*g)[n];
    p024A:
      goto p024A;
      goto a;
    P024A:
      goto P024A;
      0;
    };
  P02B:
    goto P02B;
    {
      typedef int(*h)[n];
    P025A:
      goto P025A;
      0;
    };
  P02C:
    goto P02C;
    ;
    typedef int(*i)[n];
  P026A:
    goto P026A;
    0;
  };
a:;
  typedef int(*j)[n];
P03A:
  goto P03A;
  0;
P03B:
  goto P03B;
}


x86 assembly (clang, -O0):
<fd167>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
jmp    1107 <fd167+0x7>

x86 assembly (clang, -O2):
<fd167>:
jmp    1100 <fd167>

LLVM IR (-O0):
define void @fd167(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
br label %3
3: ; preds = %3, %1
br label %3
4: ; No predecessors!
%5 = load i32, i32* %2
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %7, %4
br label %7
8: ; No predecessors!
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %11, %8
br label %11
12: ; preds = %12
br label %12
13: ; No predecessors!
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %16, %13
br label %16
17: ; preds = %17
br label %17
18: ; No predecessors!
%19 = load i32, i32* %2
%20 = zext i32 %19 to i64
br label %21
21: ; preds = %21, %18
br label %21
22: ; preds = %22
br label %22
23: ; No predecessors!
%24 = load i32, i32* %2
%25 = zext i32 %24 to i64
br label %26
26: ; preds = %26, %23
br label %26
27: ; No predecessors!
%28 = load i32, i32* %2
%29 = zext i32 %28 to i64
br label %30
30: ; preds = %30, %27
br label %30
31: ; preds = %31
br label %31
32: ; preds = %32
br label %32
33: ; No predecessors!
%34 = load i32, i32* %2
%35 = zext i32 %34 to i64
br label %36
36: ; preds = %36, %33
br label %36
37: ; preds = %37
br label %37
38: ; No predecessors!
%39 = load i32, i32* %2
%40 = zext i32 %39 to i64
br label %41
41: ; preds = %41, %38
br label %41
42: ; No predecessors!
%43 = load i32, i32* %2
%44 = zext i32 %43 to i64
br label %45
45: ; preds = %45, %42
br label %45
46: ; preds = %46
br label %46
}

LLVM IR (-O2):
define void @fd167(i32 %0) {
br label %2
2: ; preds = %2, %1
br label %2
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
int bytesPerPixel(uint8_t alg) { return (alg <= 4) ? 2 : 1; }


x86 assembly (clang, -O0):
<bytesPerPixel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x1,%eax
mov    $0x2,%ecx
cmp    $0x4,%edx
cmovle %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bytesPerPixel>:
xor    %eax,%eax
cmp    $0x5,%edi
setl   %al
add    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @bytesPerPixel(i32 %0) {
%2 = icmp slt i32 %0, 5
%3 = select i1 %2, i32 2, i32 1
ret i32 %3
}
void dump_node(struct bst_elem *node, unsigned level) {}


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

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

LLVM IR (-O0):
%struct.bst_elem = type opaque
define void @dump_node(%struct.bst_elem* %0, i32 %1) {
%3 = alloca %struct.bst_elem*
%4 = alloca i32
store %struct.bst_elem* %0, %struct.bst_elem** %3
store i32 %1, i32* %4
ret void
}

LLVM IR (-O2):
%struct.bst_elem = type opaque
define void @dump_node(%struct.bst_elem* nocapture %0, i32 %1) {
ret void
}
unsigned int read_24(unsigned char const *buffer) {
  return (buffer[0] << 16) | (buffer[1] << 8) | (buffer[2] << 0);
}


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

x86 assembly (clang, -O2):
<read_24>:
movzbl (%rdi),%eax
shl    $0x10,%eax
movzbl 0x1(%rdi),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
movzbl 0x2(%rdi),%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @read_24(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 i32
%7 = shl i32 %6, 16
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = shl i32 %11, 8
%13 = or i32 %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 i32
%18 = shl i32 %17, 0
%19 = or i32 %13, %18
ret i32 %19
}

LLVM IR (-O2):
define i32 @read_24(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = shl nuw nsw i32 %3, 16
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = shl nuw nsw i32 %7, 8
%9 = or i32 %8, %4
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = or i32 %9, %12
ret i32 %13
}
float clamp(float value, float min, float max) {
  float temp = value > min ? value : min;
  return temp < max ? temp : max;
}


x86 assembly (clang, -O0):
<clamp>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1131 <clamp+0x31>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    113b <clamp+0x3b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1167 <clamp+0x67>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1171 <clamp+0x71>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<clamp>:
maxss  %xmm1,%xmm0
minss  %xmm2,%xmm0
ret

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

LLVM IR (-O2):
define float @clamp(float %0, float %1, float %2) {
%4 = fcmp ogt float %0, %1
%5 = select i1 %4, float %0, float %1
%6 = fcmp olt float %5, %2
%7 = select i1 %6, float %5, float %2
ret float %7
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ stderr;
void __attribute__((noreturn)) wrong_fixed_argc(int argc, int arity) {
  fflush(NULL);
  fprintf(stderr, "Expected exactly %d arguments, got %d\n", arity, argc);
  exit(1);
}


x86 assembly (clang, -O0):
<wrong_fixed_argc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<wrong_fixed_argc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
call   1040 <fflush@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xeb2(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Expected exactly %d arguments, got %d\0A\00"
define void @wrong_fixed_argc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 @fflush(i32* null)
%6 = load i32, i32* @stderr
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Expected exactly %d arguments, got %d\0A\00"
define void @wrong_fixed_argc(i32 %0, i32 %1) {
%3 = tail call i32 @fflush(i32* null)
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0)
%6 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  int arr[50];
  if (arr[0] > arr[1]) {
    printf("Bigger");
  } else {
    printf("Naaah!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0xd0(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jle    1145 <main+0x35>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x41>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str.1 = [7 x i8] c"Naaah!\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
int test_imm_D5int16_mem(short *val) {
  return ((*val) & (-0xD5 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_D5int16_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, -213
%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_D5int16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, -213
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int isBE(char c) {
  if (c == '{')
    return 1;
  if (c == '}')
    return 1;
  if (c == '~')
    return 1;
  if (c == '|')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isBE>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7b,%eax
jne    1123 <isBE+0x23>
movl   $0x1,-0x4(%rbp)
jmp    1175 <isBE+0x75>
movsbl -0x5(%rbp),%eax
cmp    $0x7d,%eax
jne    113c <isBE+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1175 <isBE+0x75>
movsbl -0x5(%rbp),%eax
cmp    $0x7e,%eax
jne    1155 <isBE+0x55>
movl   $0x1,-0x4(%rbp)
jmp    1175 <isBE+0x75>
movsbl -0x5(%rbp),%eax
cmp    $0x7c,%eax
jne    116e <isBE+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1175 <isBE+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBE>:
add    $0x85,%dil
xor    %eax,%eax
cmp    $0x4,%dil
setb   %al
ret

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

LLVM IR (-O2):
define i32 @isBE(i8 signext %0) {
%2 = add i8 %0, -123
%3 = icmp ult i8 %2, 4
%4 = zext i1 %3 to i32
ret i32 %4
}
void perfctr_mips_init_tests(void) {}


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

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

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

LLVM IR (-O2):
define void @perfctr_mips_init_tests() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
char *reverseString(char *);
int main(void) {
  printf("%s : %s\n", "hello", reverseString("hello"));
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <reverseString@plt>
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s : %s\0A\00"
@.str.1 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i8* @reverseString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s : %s\0A\00"
@.str.1 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = tail call i8* @reverseString(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1)
ret i32 0
}
int number_digit(int digit_result, int current_number_digits) {
  if (digit_result == 3) {
    current_number_digits++;
  }
  return current_number_digits;
}


x86 assembly (clang, -O0):
<number_digit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x3,-0x4(%rbp)
jne    111d <number_digit+0x1d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_digit>:
xor    %eax,%eax
cmp    $0x3,%edi
sete   %al
add    %esi,%eax
ret

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

LLVM IR (-O2):
define i32 @number_digit(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 3
%4 = zext i1 %3 to i32
%5 = add nsw i32 %4, %1
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ func3();
void func1(void) {
  do {
    unsigned int i;
    for (i = 0; i < (100000); ++i)
      func3();
  } while (0);
}


x86 assembly (clang, -O0):
<func1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jae    1141 <func1+0x31>
mov    $0x0,%al
call   1030 <func3@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <func1+0xf>
jmp    1146 <func1+0x36>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func1>:
push   %rbx
mov    $0x186a0,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <func3@plt>
add    $0xffffffff,%ebx
jne    1120 <func1+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @func1() {
%1 = alloca i32
br label %2
2: ; preds = %0
store i32 0, i32* %1
br label %3
3: ; preds = %8, %2
%4 = load i32, i32* %1
%5 = icmp ult i32 %4, 100000
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = call i32 (...) @func3()
br label %8
8: ; preds = %6
%9 = load i32, i32* %1
%10 = add i32 %9, 1
store i32 %10, i32* %1
br label %3
11: ; preds = %3
br label %12
12: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @func1() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %4, %1 ]
%3 = tail call i32 (...) @func3()
%4 = add nuw nsw i32 %2, 1
%5 = icmp eq i32 %4, 100000
br i1 %5, label %6, label %1
6: ; preds = %1
ret void
}
unsigned long pci_reserve_size_mem(struct pci_bus *bus) { return 0; }


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

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

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

LLVM IR (-O2):
%struct.pci_bus = type opaque
define i64 @pci_reserve_size_mem(%struct.pci_bus* nocapture readnone %0) {
ret i64 0
}
/* Variables and functions */
float __ocml_ncdf_f32(float);
float normcdff(float x) { return __ocml_ncdf_f32(x); }


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

x86 assembly (clang, -O2):
<normcdff>:
jmp    1030 <__ocml_ncdf_f32@plt>

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

LLVM IR (-O2):
define float @normcdff(float %0) {
%2 = tail call float @__ocml_ncdf_f32(float %0)
ret float %2
}