xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ bar(int, int, int);
void foo(int i, int j, int k) { bar(i, j, k); }


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

x86 assembly (clang, -O2):
<foo>:
jmp    1030 <bar@plt>

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

LLVM IR (-O2):
define void @foo(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @bar(i32 %0, i32 %1, i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void usage(char *name) {
  fprintf(stderr, "Usage: %s -l <device> [-s <speed>]\n", name);
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    %rdi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: %s -l <device> [-s <speed>]\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: %s -l <device> [-s <speed>]\0A\00"
define void @usage(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
long time(int /*<<< orphan*/);
long sapi_get_time_sec() { return time(0); }


x86 assembly (clang, -O0):
<sapi_get_time_sec>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1030 <time@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sapi_get_time_sec>:
xor    %edi,%edi
jmp    1030 <time@plt>

LLVM IR (-O0):
define i64 @sapi_get_time_sec() {
%1 = call i64 @time(i32 0)
ret i64 %1
}

LLVM IR (-O2):
define i64 @sapi_get_time_sec() {
%1 = tail call i64 @time(i32 0)
ret i64 %1
}
/* Variables and functions */
scalar_t__ toupper(char);
char *pstrtoupper(char *dst) {
  char *p;
  for (p = dst; *p; ++p) {
    *p = (char)toupper(*p);
  }
  return dst;
}


x86 assembly (clang, -O0):
<pstrtoupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1156 <pstrtoupper+0x46>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <pstrtoupper+0x14>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pstrtoupper>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1146 <pstrtoupper+0x36>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <pstrtoupper+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @pstrtoupper(i8* returned %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %10, %4 ], [ %2, %1 ]
%6 = phi i8* [ %9, %4 ], [ %0, %1 ]
%7 = tail call i64 @toupper(i8 signext %5)
%8 = trunc i64 %7 to i8
store i8 %8, i8* %6
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %4, %1
ret i8* %0
}
/* Variables and functions */
int f326(int *);
int f327(int *p) { return f326(p); }


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

x86 assembly (clang, -O2):
<f327>:
jmp    1030 <f326@plt>

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

LLVM IR (-O2):
define i32 @f327(i32* %0) {
%2 = tail call i32 @f326(i32* %0)
ret i32 %2
}
int get_index(int *nvox, int i, int j, int k) {
  return (k + nvox[2] * (j + nvox[1] * i));
}


x86 assembly (clang, -O0):
<get_index>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%ecx
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rsi
mov    0x4(%rsi),%esi
imul   -0xc(%rbp),%esi
add    %esi,%edx
imul   %edx,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_index>:
imul   0x4(%rdi),%esi
lea    (%rsi,%rdx,1),%eax
imul   0x8(%rdi),%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @get_index(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 2
%12 = load i32, i32* %11
%13 = load i32, i32* %7
%14 = load i32*, i32** %5
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = load i32, i32* %6
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 %13, %18
%20 = mul nsw i32 %12, %19
%21 = add nsw i32 %9, %20
ret i32 %21
}

LLVM IR (-O2):
define i32 @get_index(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds i32, i32* %0, i64 2
%6 = load i32, i32* %5
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = mul nsw i32 %8, %1
%10 = add nsw i32 %9, %2
%11 = mul nsw i32 %10, %6
%12 = add nsw i32 %11, %3
ret i32 %12
}
int replace_grant_supported(void) { return 1; }


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

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

LLVM IR (-O0):
define i32 @replace_grant_supported() {
ret i32 1
}

LLVM IR (-O2):
define i32 @replace_grant_supported() {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ log_f(char *);
unsigned mouseb_none_button_get(unsigned mouse, unsigned button) {
  log_f("mouseb:none: mouseb_none_button_get()\n");
  return 0;
}


x86 assembly (clang, -O0):
<mouseb_none_button_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xedb(%rip),%rdi
call   1030 <log_f@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [39 x i8] c"mouseb:none: mouseb_none_button_get()\0A\00"
define i32 @mouseb_none_button_get(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 @log_f(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"mouseb:none: mouseb_none_button_get()\0A\00"
define i32 @mouseb_none_button_get(i32 %0, i32 %1) {
%3 = tail call i32 @log_f(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
void strength_test8(int *data) {
  int i = 0;
  do {
    int j = i + 1;
    data[data[2]] = j;
    i = j + 1;
  } while (i * 21 < data[3]);
}


x86 assembly (clang, -O0):
<strength_test8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq 0x8(%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
imul   $0x15,-0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    0xc(%rcx),%eax
jl     110f <strength_test8+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<strength_test8>:
mov    $0x1,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movslq 0x8(%rdi),%rdx
mov    %eax,(%rdi,%rdx,4)
add    $0x2,%eax
add    $0x2a,%ecx
cmp    0xc(%rdi),%ecx
jl     1110 <strength_test8+0x10>
ret

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

LLVM IR (-O2):
define void @strength_test8(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 2
%3 = getelementptr inbounds i32, i32* %0, i64 3
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ 0, %1 ], [ %10, %4 ]
%6 = or i32 %5, 1
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 %6, i32* %9
%10 = add nuw nsw i32 %5, 2
%11 = mul nsw i32 %10, 21
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %4, label %14
14: ; preds = %4
ret void
}
void DMA2_Stream4_IRQHandler() {}


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

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

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

LLVM IR (-O2):
define void @DMA2_Stream4_IRQHandler() {
ret void
}
int count_strings(char **strings) {
  int count;
  for (count = 0; strings[count]; count++)
    ;
  return count;
}


x86 assembly (clang, -O0):
<count_strings>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1135 <count_strings+0x35>
jmp    1127 <count_strings+0x27>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <count_strings+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @count_strings(i8** nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8*, i8** %0, i64 %3
%5 = load i8*, i8** %4
%6 = icmp eq i8* %5, null
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = trunc i64 %3 to i32
ret i32 %9
}
void rop3_172_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  unsigned char stk3;
  stk3 = *D ^ S;
  stk2 = T & stk3;
  stk1 = S ^ stk2;
  *D = (stk1 & (~S)) | (*D & S);
}


x86 assembly (clang, -O0):
<rop3_172_1_0>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
movzbl -0x9(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0xd(%rbp)
movzbl -0xa(%rbp),%eax
movzbl -0xd(%rbp),%ecx
and    %ecx,%eax
mov    %al,-0xc(%rbp)
movzbl -0x9(%rbp),%eax
movzbl -0xc(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
movzbl -0x9(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl (%rcx),%ecx
movzbl -0x9(%rbp),%edx
and    %edx,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rop3_172_1_0>:
or     %edx,%esi
and    %sil,(%rdi)
ret

LLVM IR (-O0):
define void @rop3_172_1_0(i8* %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = load i8, i8* %5
%14 = zext i8 %13 to i32
%15 = xor i32 %12, %14
%16 = trunc i32 %15 to i8
store i8 %16, i8* %9
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = load i8, i8* %9
%20 = zext i8 %19 to i32
%21 = and i32 %18, %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %8
%23 = load i8, i8* %5
%24 = zext i8 %23 to i32
%25 = load i8, i8* %8
%26 = zext i8 %25 to i32
%27 = xor i32 %24, %26
%28 = trunc i32 %27 to i8
store i8 %28, i8* %7
%29 = load i8, i8* %7
%30 = zext i8 %29 to i32
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = xor i32 %32, -1
%34 = and i32 %30, %33
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = load i8, i8* %5
%39 = zext i8 %38 to i32
%40 = and i32 %37, %39
%41 = or i32 %34, %40
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %4
store i8 %42, i8* %43
ret void
}

LLVM IR (-O2):
define void @rop3_172_1_0(i8* nocapture %0, i8 zeroext %1, i8 zeroext %2) {
%4 = load i8, i8* %0
%5 = or i8 %2, %1
%6 = and i8 %5, %4
store i8 %6, i8* %0
ret void
}
int isHex(char ch) {
  return ((ch >= '0' && ch <= '9') || ((ch & 0xdf) >= 'A' && (ch & 0xdf) <= 'F')
              ? 1
              : 0);
}


x86 assembly (clang, -O0):
<isHex>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1129 <isHex+0x29>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x39,%ecx
mov    %al,-0x2(%rbp)
jle    1159 <isHex+0x59>
movsbl -0x1(%rbp),%ecx
and    $0xdf,%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x3(%rbp)
jl     1153 <isHex+0x53>
movsbl -0x1(%rbp),%eax
and    $0xdf,%eax
cmp    $0x46,%eax
setle  %al
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @isHex(i8 signext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
%4 = and i8 %0, -33
%5 = add i8 %4, -65
%6 = icmp ult i8 %5, 6
%7 = or i1 %3, %6
%8 = zext i1 %7 to i32
ret i32 %8
}
void indirect_check_item(struct item_head *ih, char *item) {}


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

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

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

LLVM IR (-O2):
%struct.item_head = type opaque
define void @indirect_check_item(%struct.item_head* nocapture %0, i8* nocapture %1) {
ret void
}
/* Variables and functions */
double *malloc(int);
int main() {
  volatile double *arr = malloc(10 * sizeof(double));
  arr[5] = 1.6;
  arr[4] = 1.45;
  return arr[5] + arr[4];
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x50,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x50,%edi
call   1030 <malloc@plt>
movabs $0x3ff999999999999a,%rcx
99 f9 3f
mov    %rcx,0x28(%rax)
movabs $0x3ff7333333333333,%rcx
33 f7 3f
mov    %rcx,0x20(%rax)
movsd  0x28(%rax),%xmm0
addsd  0x20(%rax),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
store i32 0, i32* %1
%3 = call double* @malloc(i32 80)
store double* %3, double** %2
%4 = load double*, double** %2
%5 = getelementptr inbounds double, double* %4, i64 5
store volatile double 1.600000e+00, double* %5
%6 = load double*, double** %2
%7 = getelementptr inbounds double, double* %6, i64 4
store volatile double 1.450000e+00, double* %7
%8 = load double*, double** %2
%9 = getelementptr inbounds double, double* %8, i64 5
%10 = load volatile double, double* %9
%11 = load double*, double** %2
%12 = getelementptr inbounds double, double* %11, i64 4
%13 = load volatile double, double* %12
%14 = fadd double %10, %13
%15 = fptosi double %14 to i32
ret i32 %15
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call double* @malloc(i32 80)
%2 = getelementptr inbounds double, double* %1, i64 5
store volatile double 1.600000e+00, double* %2
%3 = getelementptr inbounds double, double* %1, i64 4
store volatile double 1.450000e+00, double* %3
%4 = load volatile double, double* %2
%5 = load volatile double, double* %3
%6 = fadd double %4, %5
%7 = fptosi double %6 to i32
ret i32 %7
}
/* Variables and functions */
scalar_t__ __random();
int rand(void) { return (int)__random(); }


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

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

LLVM IR (-O0):
define i32 @rand() {
%1 = call i64 (...) @__random()
%2 = trunc i64 %1 to i32
ret i32 %2
}

LLVM IR (-O2):
define i32 @rand() {
%1 = tail call i64 (...) @__random()
%2 = trunc i64 %1 to i32
ret i32 %2
}
/* Type definitions */
struct forth_instance {
  int dummy;
};

/* Variables and functions */
int st_pop(struct forth_instance *);
int /*<<< orphan*/ usleep(int);
void microsleep(struct forth_instance *fi) {
  int tp;
  tp = st_pop(fi);
  if (tp >= 999999)
    for (; tp >= 999999; tp -= 999999)
      usleep(999999);
  usleep(tp);
}


x86 assembly (clang, -O0):
<microsleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <st_pop@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xf423f,-0xc(%rbp)
jl     1176 <microsleep+0x56>
jmp    114a <microsleep+0x2a>
cmpl   $0xf423f,-0xc(%rbp)
jl     1171 <microsleep+0x51>
mov    $0xf423f,%edi
call   1040 <usleep@plt>
mov    -0xc(%rbp),%eax
sub    $0xf423f,%eax
mov    %eax,-0xc(%rbp)
jmp    114a <microsleep+0x2a>
jmp    1176 <microsleep+0x56>
mov    -0xc(%rbp),%edi
call   1040 <usleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<microsleep>:
push   %rbx
call   1030 <st_pop@plt>
mov    %eax,%ebx
cmp    $0xf423f,%eax
jl     1150 <microsleep+0x30>
nop
mov    $0xf423f,%edi
call   1040 <usleep@plt>
lea    -0xf423f(%rbx),%edi
cmp    $0x1e847d,%ebx
mov    %edi,%ebx
ja     1130 <microsleep+0x10>
pop    %rbx
jmp    1040 <usleep@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1040 <usleep@plt>

LLVM IR (-O0):
%struct.forth_instance = type { i32 }
define void @microsleep(%struct.forth_instance* %0) {
%2 = alloca %struct.forth_instance*
%3 = alloca i32
store %struct.forth_instance* %0, %struct.forth_instance** %2
%4 = load %struct.forth_instance*, %struct.forth_instance** %2
%5 = call i32 @st_pop(%struct.forth_instance* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 999999
br i1 %7, label %8, label %18
8: ; preds = %1
br label %9
9: ; preds = %14, %8
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 999999
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = call i32 @usleep(i32 999999)
br label %14
14: ; preds = %12
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 999999
store i32 %16, i32* %3
br label %9
17: ; preds = %9
br label %18
18: ; preds = %17, %1
%19 = load i32, i32* %3
%20 = call i32 @usleep(i32 %19)
ret void
}

LLVM IR (-O2):
%struct.forth_instance = type { i32 }
define void @microsleep(%struct.forth_instance* %0) {
%2 = tail call i32 @st_pop(%struct.forth_instance* %0)
%3 = icmp sgt i32 %2, 999998
br i1 %3, label %4, label %9
4: ; preds = %1, %4
%5 = phi i32 [ %7, %4 ], [ %2, %1 ]
%6 = tail call i32 @usleep(i32 999999)
%7 = add nsw i32 %5, -999999
%8 = icmp ugt i32 %5, 1999997
br i1 %8, label %4, label %9
9: ; preds = %4, %1
%10 = phi i32 [ %2, %1 ], [ %7, %4 ]
%11 = tail call i32 @usleep(i32 %10)
ret void
}
/* Variables and functions */
int _popcnt32(unsigned int);
int test_popcnt32(unsigned int __X) { return _popcnt32(__X); }


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

x86 assembly (clang, -O2):
<test_popcnt32>:
jmp    1030 <_popcnt32@plt>

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

LLVM IR (-O2):
define i32 @test_popcnt32(i32 %0) {
%2 = tail call i32 @_popcnt32(i32 %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
void x_closesocket(int fd) { close(fd); }


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

x86 assembly (clang, -O2):
<x_closesocket>:
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define void @x_closesocket(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *,
                           char *);
int /*<<< orphan*/ stderr;
void usage() {
  (void)fprintf(
      stderr, "usage: mount %s %s\n       mount %s\n       mount %s\n",
      "[-dfruvw] [-o options] [-t ufs | external_type]", "special node",
      "[-adfruvw] [-t ufs | external_type]", "[-dfruvw] special | node");
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
lea    0xef9(%rip),%rdx
lea    0xf22(%rip),%rcx
lea    0xf28(%rip),%r8
lea    0xf45(%rip),%r9
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
lea    0xefc(%rip),%rdx
lea    0xf25(%rip),%rcx
lea    0xf2b(%rip),%r8
lea    0xf48(%rip),%r9
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"usage: mount %s %s\0A mount %s\0A mount %s\0A\00"
@.str.1 = [48 x i8] c"[-dfruvw] [-o options] [-t ufs | external_type]\00"
@.str.2 = [13 x i8] c"special node\00"
@.str.3 = [36 x i8] c"[-adfruvw] [-t ufs | external_type]\00"
@.str.4 = [25 x i8] c"[-dfruvw] special | node\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"usage: mount %s %s\0A mount %s\0A mount %s\0A\00"
@.str.1 = [48 x i8] c"[-dfruvw] [-o options] [-t ufs | external_type]\00"
@.str.2 = [13 x i8] c"special node\00"
@.str.3 = [36 x i8] c"[-adfruvw] [-t ufs | external_type]\00"
@.str.4 = [25 x i8] c"[-dfruvw] special | node\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%3 = tail call i32 @exit(i32 1)
unreachable
}
/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int /*<<< orphan*/ polyglot_array_typeid(int /*<<< orphan*/,
                                         int /*<<< orphan*/);
void *polyglot_from_typed(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ polyglot_i16_typeid();
__attribute__((always_)) void *polyglot_from_i16_array(int16_t *arr,
                                                       uint64_t len) {
  return polyglot_from_typed(arr,
                             polyglot_array_typeid(polyglot_i16_typeid(), len));
}


x86 assembly (clang, -O0):
<polyglot_from_i16_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <polyglot_i16_typeid@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1050 <polyglot_array_typeid@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <polyglot_from_typed@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<polyglot_from_i16_array>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <polyglot_i16_typeid@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1050 <polyglot_array_typeid@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <polyglot_from_typed@plt>

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

LLVM IR (-O2):
define i8* @polyglot_from_i16_array(i32* %0, i32 %1) {
%3 = tail call i32 (...) @polyglot_i16_typeid()
%4 = tail call i32 @polyglot_array_typeid(i32 %3, i32 %1)
%5 = tail call i8* @polyglot_from_typed(i32* %0, i32 %4)
ret i8* %5
}
/* Variables and functions */
int rand();
int builtin_var_random_integer() { return rand(); }


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

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

LLVM IR (-O0):
define i32 @builtin_var_random_integer() {
%1 = call i32 (...) @rand()
ret i32 %1
}

LLVM IR (-O2):
define i32 @builtin_var_random_integer() {
%1 = tail call i32 (...) @rand()
ret i32 %1
}
/* Variables and functions */
int /*<<< orphan*/ USBDEVFS_RESET;
int doioctl(int /*<<< orphan*/, int *, char *);
int /*<<< orphan*/ printf(char *);
int reset(void) {
  int i = 0;
  printf("resetting...\n");
  return doioctl(USBDEVFS_RESET, &i, "reset");
}


x86 assembly (clang, -O0):
<reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
lea    0xebf(%rip),%rdx
call   1040 <doioctl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rdx
lea    0x4(%rsp),%rsi
call   1040 <doioctl@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"resetting...\0A\00"
@USBDEVFS_RESET = global i32 0
@.str.1 = [6 x i8] c"reset\00"
define i32 @reset() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @USBDEVFS_RESET
%4 = call i32 @doioctl(i32 %3, i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 %4
}

LLVM IR (-O2):
@USBDEVFS_RESET = global i32 0
@.str.1 = [6 x i8] c"reset\00"
@str = [13 x i8] c"resetting...\00"
define i32 @reset() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @USBDEVFS_RESET
%5 = call i32 @doioctl(i32 %4, i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 %5
}
int read(void) { return 42; }


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

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

LLVM IR (-O0):
define i32 @read() {
ret i32 42
}

LLVM IR (-O2):
define i32 @read() {
ret i32 42
}
int is_val_ok(const int val, const int lo_val, const int hi_val) {
  return (val >= lo_val && val <= hi_val) ? 1 : 0;
}


x86 assembly (clang, -O0):
<is_val_ok>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0xd(%rbp)
jl     112a <is_val_ok+0x2a>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_val_ok>:
cmp    %esi,%edi
setge  %al
cmp    %edx,%edi
setle  %cl
and    %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @is_val_ok(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = icmp sge i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* %4
%12 = load i32, i32* %6
%13 = icmp sle i32 %11, %12
br label %14
14: ; preds = %10, %3
%15 = phi i1 [ false, %3 ], [ %13, %10 ]
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 1, i32 0
ret i32 %17
}

LLVM IR (-O2):
define i32 @is_val_ok(i32 %0, i32 %1, i32 %2) {
%4 = icmp sge i32 %0, %1
%5 = icmp sle i32 %0, %2
%6 = and i1 %4, %5
%7 = zext i1 %6 to i32
ret i32 %7
}
/* Variables and functions */
scalar_t__ tolower(int);
int char_ci_lt(int c1, int c2) { return tolower(c1) < tolower(c2); }


x86 assembly (clang, -O0):
<char_ci_lt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <tolower@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_ci_lt>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <tolower@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1030 <tolower@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setl   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @char_ci_lt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i64 @tolower(i32 %5)
%7 = load i32, i32* %4
%8 = call i64 @tolower(i32 %7)
%9 = icmp slt i64 %6, %8
%10 = zext i1 %9 to i32
ret i32 %10
}

LLVM IR (-O2):
define i32 @char_ci_lt(i32 %0, i32 %1) {
%3 = tail call i64 @tolower(i32 %0)
%4 = tail call i64 @tolower(i32 %1)
%5 = icmp slt i64 %3, %4
%6 = zext i1 %5 to i32
ret i32 %6
}
unsigned int getle32(const unsigned char *p) {
  return (p[0] << 0) | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}


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

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

LLVM IR (-O0):
define i32 @getle32(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, 0
%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, 16
%19 = or i32 %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 i32
%24 = shl i32 %23, 24
%25 = or i32 %19, %24
ret i32 %25
}

LLVM IR (-O2):
define i32 @getle32(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = shl nuw nsw i32 %6, 8
%8 = or i32 %7, %3
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = shl nuw nsw i32 %11, 16
%13 = or i32 %8, %12
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl nuw i32 %16, 24
%18 = or i32 %13, %17
ret i32 %18
}
float ReverseFloat(const float inFloat) {
  float retVal;
  char *floatToConvert = (char *)&inFloat;
  char *returnFloat = (char *)&retVal;
  returnFloat[0] = floatToConvert[3];
  returnFloat[1] = floatToConvert[2];
  returnFloat[2] = floatToConvert[1];
  returnFloat[3] = floatToConvert[0];
  return retVal;
}


x86 assembly (clang, -O0):
<ReverseFloat>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
movss  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReverseFloat>:
movd   %xmm0,%eax
bswap  %eax
movd   %eax,%xmm0
ret

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

LLVM IR (-O2):
define float @ReverseFloat(float %0) {
%2 = bitcast float %0 to i32
%3 = tail call i32 @llvm.bswap.i32(i32 %2)
%4 = bitcast i32 %3 to float
ret float %4
}
/* Variables and functions */
float sqrtf(float);
float vec3_length(float *a) {
  return sqrtf(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
}


x86 assembly (clang, -O0):
<vec3_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3_length>:
movss  (%rdi),%xmm1
movss  0x4(%rdi),%xmm0
mulss  %xmm0,%xmm0
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0x8(%rdi),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     113f <vec3_length+0x2f>
sqrtss %xmm0,%xmm0
ret
jmp    1030 <sqrtf@plt>

LLVM IR (-O0):
define float @vec3_length(float* %0) {
%2 = alloca float*
store float* %0, float** %2
%3 = load float*, float** %2
%4 = getelementptr inbounds float, float* %3, i64 0
%5 = load float, float* %4
%6 = load float*, float** %2
%7 = getelementptr inbounds float, float* %6, i64 0
%8 = load float, float* %7
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 1
%11 = load float, float* %10
%12 = load float*, float** %2
%13 = getelementptr inbounds float, float* %12, i64 1
%14 = load float, float* %13
%15 = fmul float %11, %14
%16 = call float @llvm.fmuladd.f32(float %5, float %8, float %15)
%17 = load float*, float** %2
%18 = getelementptr inbounds float, float* %17, i64 2
%19 = load float, float* %18
%20 = load float*, float** %2
%21 = getelementptr inbounds float, float* %20, i64 2
%22 = load float, float* %21
%23 = call float @llvm.fmuladd.f32(float %19, float %22, float %16)
%24 = call float @sqrtf(float %23)
ret float %24
}

LLVM IR (-O2):
define float @vec3_length(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = fmul float %4, %4
%6 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %5)
%7 = getelementptr inbounds float, float* %0, i64 2
%8 = load float, float* %7
%9 = tail call float @llvm.fmuladd.f32(float %8, float %8, float %6)
%10 = tail call float @sqrtf(float %9)
ret float %10
}
/* Variables and functions */
int close(int);
int close_connection(int connection) { return close(connection); }


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

x86 assembly (clang, -O2):
<close_connection>:
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define i32 @close_connection(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret i32 %2
}
int islessequal(float f1, float f2) {
  int r = (f1 <= f2);
  return !r ? -1 : 1;
}


x86 assembly (clang, -O0):
<islessequal>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setne  %dl
xor    $0xff,%dl
mov    $0x1,%eax
mov    $0xffffffff,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<islessequal>:
xor    %eax,%eax
ucomiss %xmm0,%xmm1
setae  %al
add    %eax,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @islessequal(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %3
%7 = load float, float* %4
%8 = fcmp ole float %6, %7
%9 = zext i1 %8 to i32
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 -1, i32 1
ret i32 %14
}

LLVM IR (-O2):
define i32 @islessequal(float %0, float %1) {
%3 = fcmp ugt float %0, %1
%4 = select i1 %3, i32 -1, i32 1
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
extern long long shmem_longlong_swap(long long *target, long long value,
                                     int pe) {
  printf("\nOpenSHMEM Analyzer\n");
}


x86 assembly (clang, -O0):
<shmem_longlong_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shmem_longlong_swap>:
lea    0xee9(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"\0AOpenSHMEM Analyzer\0A\00"
define i64 @shmem_longlong_swap(i64* %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i32
store i64* %0, i64** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = load i64, i64* %4
ret i64 %9
}

LLVM IR (-O2):
@str = [20 x i8] c"\0AOpenSHMEM Analyzer\00"
define i64 @shmem_longlong_swap(i64* nocapture readnone %0, i64 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i64 undef
}
/* Variables and functions */
int /*<<< orphan*/ SETVAL;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int semctl(int, int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int sem_set(int id, int value) {
  if (semctl(id, 0, SETVAL, (int)value) == -1) {
    fprintf(stderr,
            "Error: semaphore (Anforderungen) konnte nicht gesetzt werden\n");
    exit(-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<sem_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
call   1040 <semctl@plt>
cmp    $0xffffffff,%eax
jne    117c <sem_set+0x4c>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sem_set>:
push   %rax
mov    %esi,%ecx
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <semctl@plt>
cmp    $0xffffffff,%eax
je     114c <sem_set+0x1c>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SETVAL = global i32 0
@stderr = global i32 0
@.str = [62 x i8] c"Error: semaphore (Anforderungen) konnte nicht gesetzt werden\0A\00"
define i32 @sem_set(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* @SETVAL
%7 = load i32, i32* %4
%8 = call i32 @semctl(i32 %5, i32 0, i32 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
ret i32 0
}

LLVM IR (-O2):
@SETVAL = global i32 0
@stderr = global i32 0
@.str = [62 x i8] c"Error: semaphore (Anforderungen) konnte nicht gesetzt werden\0A\00"
define i32 @sem_set(i32 %0, i32 %1) {
%3 = load i32, i32* @SETVAL
%4 = tail call i32 @semctl(i32 %0, i32 0, i32 %3, i32 %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
ret i32 0
}
/* Variables and functions */
unsigned int get_uart_base_addr(unsigned int);
unsigned int read_uart(unsigned int reg_offs, unsigned int uartid) {
  volatile unsigned int *reg_ptr =
      (unsigned int *)(get_uart_base_addr(uartid) | reg_offs);
  return *reg_ptr;
}


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

x86 assembly (clang, -O2):
<read_uart>:
push   %rbx
mov    %edi,%ebx
mov    %esi,%edi
call   1030 <get_uart_base_addr@plt>
or     %ebx,%eax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_uart(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @get_uart_base_addr(i32 %6)
%8 = load i32, i32* %3
%9 = or i32 %7, %8
%10 = zext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %5
%12 = load i32*, i32** %5
%13 = load volatile i32, i32* %12
ret i32 %13
}

LLVM IR (-O2):
define i32 @read_uart(i32 %0, i32 %1) {
%3 = tail call i32 @get_uart_base_addr(i32 %1)
%4 = or i32 %3, %0
%5 = zext i32 %4 to i64
%6 = inttoptr i64 %5 to i32*
%7 = load volatile i32, i32* %6
ret i32 %7
}
int _isatty() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @_isatty() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ write_port(int, int);
void keyboard_init(void) { write_port(0x21, 0xFD); }


x86 assembly (clang, -O0):
<keyboard_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x21,%edi
mov    $0xfd,%esi
call   1030 <write_port@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyboard_init>:
mov    $0x21,%edi
mov    $0xfd,%esi
jmp    1030 <write_port@plt>

LLVM IR (-O0):
define void @keyboard_init() {
%1 = call i32 @write_port(i32 33, i32 253)
ret void
}

LLVM IR (-O2):
define void @keyboard_init() {
%1 = tail call i32 @write_port(i32 33, i32 253)
ret void
}