xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, size_t);
size_t strlen(unsigned char *);
void execute_shellcode(unsigned char *shellcode) {
  size_t len = strlen(shellcode);
  printf("[+] Shellcode Length:  %d\n", len);
  int (*ret)() = (int (*)())shellcode;
  ret();
}


x86 assembly (clang, -O0):
<execute_shellcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   *-0x18(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_shellcode>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0xed0(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %rbx,%rcx
pop    %rbx
jmp    *%rcx

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

LLVM IR (-O2):
@.str = [27 x i8] c"[+] Shellcode Length: %d\0A\00"
define void @execute_shellcode(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %2)
%4 = bitcast i8* %0 to i32 (...)*
%5 = tail call i32 (...) %4()
ret void
}
unsigned long long int rdtsc(void) {
  unsigned int low, high;
  unsigned long tsc;
  __asm__ __volatile__("rdtsc" : "=a"(low), "=d"(high));
  tsc = ((unsigned long long)high << 32) | low;
  return tsc;
}


x86 assembly (clang, -O0):
<rdtsc>:
push   %rbp
mov    %rsp,%rbp
rdtsc
mov    %eax,-0x4(%rbp)
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x20,%rax
mov    -0x4(%rbp),%ecx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdtsc>:
rdtsc
shl    $0x20,%rdx
mov    %eax,%eax
or     %rdx,%rax
ret

LLVM IR (-O0):
define i64 @rdtsc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = call { i32, i32 } asm sideeffect "rdtsc", "={ax},={dx},~{dirflag},~{fpsr},~{flags}"()
%5 = extractvalue { i32, i32 } %4, 0
%6 = extractvalue { i32, i32 } %4, 1
store i32 %5, i32* %1
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = shl i64 %8, 32
%10 = load i32, i32* %1
%11 = zext i32 %10 to i64
%12 = or i64 %9, %11
store i64 %12, i64* %3
%13 = load i64, i64* %3
ret i64 %13
}

LLVM IR (-O2):
define i64 @rdtsc() {
%1 = tail call { i32, i32 } asm sideeffect "rdtsc", "={ax},={dx},~{dirflag},~{fpsr},~{flags}"()
%2 = extractvalue { i32, i32 } %1, 0
%3 = extractvalue { i32, i32 } %1, 1
%4 = zext i32 %3 to i64
%5 = shl nuw i64 %4, 32
%6 = zext i32 %2 to i64
%7 = or i64 %5, %6
ret i64 %7
}
/* Variables and functions */
int getchar();
int /*<<< orphan*/ printf(char *, int);
main(void) {
  int c, nc = 0;
  while ((c = getchar()) != '\n') {
    ++nc;
  }
  printf("número de caracteres %d\n", nc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     1157 <main+0x37>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <main+0x16>
mov    -0xc(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
jne    1130 <main+0x10>
lea    0xeba(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"n\C3\BAmero de caracteres %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %7, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %3
br label %4
10: ; preds = %4
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [26 x i8] c"n\C3\BAmero de caracteres %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %5, %1 ]
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, 10
%5 = add nuw nsw i32 %2, 1
br i1 %4, label %6, label %1
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 0
}
int strleng(char *string) {
  int i = 0;
  while (string[i] != '\0' && string[i] != '\n' && string[i] != '\r') {
    i++;
  }
  return i;
}


x86 assembly (clang, -O0):
<strleng>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     1158 <strleng+0x58>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     1158 <strleng+0x58>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1168 <strleng+0x68>
jmp    1176 <strleng+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <strleng+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strleng>:
xor    %eax,%eax
mov    $0x2401,%ecx
jmp    1114 <strleng+0x14>
nopl   0x0(%rax)
add    $0x1,%rax
movzbl (%rdi,%rax,1),%edx
cmp    $0xd,%rdx
ja     1110 <strleng+0x10>
bt     %rdx,%rcx
jae    1110 <strleng+0x10>
ret

LLVM IR (-O0):
define i32 @strleng(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %30, %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 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 13
br label %28
28: ; preds = %20, %12, %4
%29 = phi i1 [ false, %12 ], [ false, %4 ], [ %27, %20 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %4
33: ; preds = %28
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @strleng(i8* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i64 [ %7, %6 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %8
i8 10, label %8
i8 13, label %8
]
6: ; preds = %2
%7 = add nuw i64 %3, 1
br label %2
8: ; preds = %2, %2, %2
%9 = trunc i64 %3 to i32
ret i32 %9
}
int cpuid(void) {
  static int inited = 0;
  return 0;
}


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

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

LLVM IR (-O0):
@cpuid.inited = internal global i32 0
define i32 @cpuid() {
ret i32 0
}

LLVM IR (-O2):
define i32 @cpuid() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ acu_new_unique(int /*<<< orphan*/ *, void (*)(void *));
scalar_t__ fclose;
int /*<<< orphan*/ *fopen(char const *, char const *);
FILE *acu_fopen(const char *s, const char *m) {
  FILE *fi = fopen(s, m);
  if (fi)
    (void)acu_new_unique(fi, (void (*)(void *))fclose);
  return fi;
}


x86 assembly (clang, -O0):
<acu_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115f <acu_fopen+0x3f>
mov    -0x18(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%rsi
call   1030 <acu_new_unique@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acu_fopen>:
push   %rbx
call   1040 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1140 <acu_fopen+0x20>
mov    0x2eb3(%rip),%rax
mov    (%rax),%rsi
mov    %rbx,%rdi
call   1030 <acu_new_unique@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@fclose = global i64 0
define i32* @acu_fopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %6, i8* %7)
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = load i64, i64* @fclose
%14 = inttoptr i64 %13 to void (i8*)*
%15 = call i32 @acu_new_unique(i32* %12, void (i8*)* %14)
br label %16
16: ; preds = %11, %2
%17 = load i32*, i32** %5
ret i32* %17
}

LLVM IR (-O2):
@fclose = global i64 0
define i32* @acu_fopen(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i64, i64* @fclose
%7 = inttoptr i64 %6 to void (i8*)*
%8 = tail call i32 @acu_new_unique(i32* %3, void (i8*)* %7)
br label %9
9: ; preds = %5, %2
ret i32* %3
}
int sumFormula(int n) { return (n * (n + 1)) / 2; }


x86 assembly (clang, -O0):
<sumFormula>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumFormula>:
lea    0x1(%rdi),%ecx
imul   %edi,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
ret

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

LLVM IR (-O2):
define i32 @sumFormula(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = mul nsw i32 %2, %0
%4 = sdiv i32 %3, 2
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ display_version();
int /*<<< orphan*/ print_uptime();
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc == 1)
    print_uptime();
  if ((argc == 2) && (!strcmp(argv[1], "-V")))
    display_version();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1157 <main+0x27>
mov    $0x0,%al
call   1030 <print_uptime@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1185 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1185 <main+0x55>
mov    $0x0,%al
call   1040 <display_version@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
je     1144 <main+0x14>
cmp    $0x1,%edi
jne    115f <main+0x2f>
xor    %eax,%eax
call   1030 <print_uptime@plt>
jmp    115f <main+0x2f>
mov    0x8(%rsi),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    115f <main+0x2f>
xor    %eax,%eax
call   1040 <display_version@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-V\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @print_uptime()
br label %10
10: ; preds = %8, %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 (...) @display_version()
br label %21
21: ; preds = %19, %13, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-V\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %12 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32 (...) @print_uptime()
br label %12
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 (...) @display_version()
br label %12
12: ; preds = %3, %2, %10, %5
ret i32 0
}
int RGBA(int r, int g, int b, int a) {
  return (r << 24) | (g << 16) | (b << 8) | (a);
}


x86 assembly (clang, -O0):
<RGBA>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x18,%eax
mov    -0x8(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGBA>:
mov    %edx,%eax
shl    $0x18,%edi
shl    $0x10,%esi
or     %edi,%esi
shl    $0x8,%eax
or     %ecx,%eax
or     %esi,%eax
ret

LLVM IR (-O0):
define i32 @RGBA(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* %5
%10 = shl i32 %9, 24
%11 = load i32, i32* %6
%12 = shl i32 %11, 16
%13 = or i32 %10, %12
%14 = load i32, i32* %7
%15 = shl i32 %14, 8
%16 = or i32 %13, %15
%17 = load i32, i32* %8
%18 = or i32 %16, %17
ret i32 %18
}

LLVM IR (-O2):
define i32 @RGBA(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %0, 24
%6 = shl i32 %1, 16
%7 = or i32 %6, %5
%8 = shl i32 %2, 8
%9 = or i32 %7, %8
%10 = or i32 %9, %3
ret i32 %10
}
/* Variables and functions */
int EOF;
int getchar();
int /*<<< orphan*/ putchar(int);
main(void) {
  int c;
  c = getchar();
  while (c != EOF) {
    putchar(c);
    c = getchar();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
je     1162 <main+0x42>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
jmp    1139 <main+0x19>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb9(%rip),%rbx
cmp    (%rbx),%eax
je     1152 <main+0x32>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %10, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %7, %4 ], [ %1, %0 ]
%6 = tail call i32 @putchar(i32 %5)
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %4
10: ; preds = %4, %0
ret i32 0
}
unsigned xrop3_130_1_0(unsigned char s, unsigned char t) {
  unsigned D = 0x00ff;
  unsigned S = ((unsigned)s << 8) | s;
  unsigned T = ((unsigned)t << 8) | t;
  unsigned stk1;
  unsigned stk2;
  stk2 = T ^ S;
  stk2 = ~stk2;
  stk1 = D & stk2;
  return (stk1 & (~S)) | (D & S);
}


x86 assembly (clang, -O0):
<xrop3_130_1_0>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0xff,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x8,%eax
movzbl -0x1(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
movzbl -0x2(%rbp),%eax
shl    $0x8,%eax
movzbl -0x2(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    -0x8(%rbp),%ecx
and    -0xc(%rbp),%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrop3_130_1_0>:
mov    %edi,%eax
shl    $0x8,%eax
or     %edi,%eax
xor    %edi,%esi
not    %sil
movzbl %sil,%ecx
not    %eax
and    %ecx,%eax
or     %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @xrop3_130_1_0(i8 zeroext %0, i8 zeroext %1) {
%3 = zext i8 %0 to i32
%4 = mul nuw nsw i32 %3, 257
%5 = xor i8 %0, %1
%6 = xor i8 %5, -1
%7 = zext i8 %6 to i32
%8 = xor i32 %4, -1
%9 = and i32 %7, %8
%10 = or i32 %9, %3
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
void f1() {
  int size = 12;
  char src[12] = "helloworld";
  char dest[12];
  strncpy(dest, src, (unsigned)size);
}


x86 assembly (clang, -O0):
<f1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xc,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f1>:
sub    $0x18,%rsp
movabs $0x726f776f6c6c6568,%rax
77 6f 72
mov    %rax,(%rsp)
movl   $0x646c,0x8(%rsp)
lea    0xc(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xc,%edx
call   1030 <strncpy@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.f1.src = [12 x i8] c"helloworld\00\00"
define void @f1() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca [12 x i8]
store i32 12, i32* %1
%4 = bitcast [12 x i8]* %2 to i8*
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* %1
%8 = call i32 @strncpy(i8* %5, i8* %6, i32 %7)
ret void
}

LLVM IR (-O2):
@__const.f1.src = [12 x i8] c"helloworld\00\00"
define void @f1() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* %3, i32 12)
ret void
}
double cos(double x __attribute__((unused))) { return 0.0; }


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

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

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

LLVM IR (-O2):
define double @cos(double %0) {
ret double 0.000000e+00
}
void ft_striteri(char *s, void (*f)(unsigned int, char *)) {
  unsigned int i;
  if (!s || !f)
    return;
  i = 0;
  while (*s) {
    f(i, s);
    s++;
    i++;
  }
}


x86 assembly (clang, -O0):
<ft_striteri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1126 <ft_striteri+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    112b <ft_striteri+0x2b>
jmp    1166 <ft_striteri+0x66>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1166 <ft_striteri+0x66>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   *%rax
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <ft_striteri+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_striteri>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1135 <ft_striteri+0x35>
mov    %rsi,%r14
test   %rsi,%rsi
je     1135 <ft_striteri+0x35>
mov    %rdi,%r15
cmpb   $0x0,(%rdi)
je     1135 <ft_striteri+0x35>
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%rsi
mov    %ebx,%edi
call   *%r14
cmpb   $0x0,0x1(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1120 <ft_striteri+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @ft_striteri(i8* %0, void (i32, i8*)* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne void (i32, i8*)* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6, %9
%10 = phi i32 [ %13, %9 ], [ 0, %6 ]
%11 = phi i8* [ %12, %9 ], [ %0, %6 ]
tail call void %1(i32 %10, i8* %11)
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = add i32 %10, 1
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %6, %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ shell_bufferclear();
int /*<<< orphan*/ terminal_writestring(char *);
void shell_clear() {
  terminal_writestring("mato:myos/$ ");
  shell_bufferclear();
}


x86 assembly (clang, -O0):
<shell_clear>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1040 <terminal_writestring@plt>
mov    $0x0,%al
call   1030 <shell_bufferclear@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_clear>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <terminal_writestring@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <shell_bufferclear@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"mato:myos/$ \00"
define void @shell_clear() {
%1 = call i32 @terminal_writestring(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = call i32 (...) @shell_bufferclear()
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"mato:myos/$ \00"
define void @shell_clear() {
%1 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @shell_bufferclear()
ret void
}
int hash(char *a) {
  int hash = 0, i = 0;
  while (a[i] != '\0') {
    hash += (int)a[i] * (i + 1) * 10;
    i++;
  }
  return hash;
}


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

x86 assembly (clang, -O2):
<hash>:
mov    (%rdi),%cl
test   %cl,%cl
je     1137 <hash+0x37>
add    $0x1,%rdi
xor    %eax,%eax
mov    $0xa,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %cl,%ecx
imul   %edx,%ecx
add    %ecx,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
add    $0xa,%edx
test   %cl,%cl
jne    1120 <hash+0x20>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @hash(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = phi i8 [ %15, %4 ], [ %2, %1 ]
%7 = phi i32 [ %13, %4 ], [ 0, %1 ]
%8 = sext i8 %6 to i32
%9 = add nuw nsw i64 %5, 1
%10 = trunc i64 %9 to i32
%11 = mul i32 %10, 10
%12 = mul i32 %11, %8
%13 = add nsw i32 %12, %7
%14 = getelementptr inbounds i8, i8* %0, i64 %9
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %4, %1
%18 = phi i32 [ 0, %1 ], [ %13, %4 ]
ret i32 %18
}
int dfft_init_local_fft() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @dfft_init_local_fft() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ key_t;

/* Variables and functions */
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ ftok(char *, int /*<<< orphan*/);
int /*<<< orphan*/ shmctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int shmget(int /*<<< orphan*/, size_t, int);
int /*<<< orphan*/ unlink(char *);
int delete_shm_by_name(char *n, size_t s) {
  key_t k;
  int id;
  k = ftok(n, 0);
  id = shmget(k, s, 0644);
  if (id != -1) {
    shmctl(id, IPC_RMID, NULL);
  }
  unlink(n);
  return 0;
}


x86 assembly (clang, -O0):
<delete_shm_by_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1060 <ftok@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1a4,%edx
call   1050 <shmget@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     1191 <delete_shm_by_name+0x51>
mov    -0x18(%rbp),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <shmctl@plt>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_shm_by_name>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %esi,%esi
call   1060 <ftok@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x1a4,%edx
call   1050 <shmget@plt>
cmp    $0xffffffff,%eax
je     1177 <delete_shm_by_name+0x37>
mov    0x2e74(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1040 <shmctl@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@IPC_RMID = global i32 0
define i32 @delete_shm_by_name(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
%8 = call i32 @ftok(i8* %7, i32 0)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i64, i64* %4
%11 = call i32 @shmget(i32 %9, i64 %10, i32 420)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* %6
%16 = load i32, i32* @IPC_RMID
%17 = call i32 @shmctl(i32 %15, i32 %16, i32* null)
br label %18
18: ; preds = %14, %2
%19 = load i8*, i8** %3
%20 = call i32 @unlink(i8* %19)
ret i32 0
}

LLVM IR (-O2):
@IPC_RMID = global i32 0
define i32 @delete_shm_by_name(i8* %0, i64 %1) {
%3 = tail call i32 @ftok(i8* %0, i32 0)
%4 = tail call i32 @shmget(i32 %3, i64 %1, i32 420)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @IPC_RMID
%8 = tail call i32 @shmctl(i32 %4, i32 %7, i32* null)
br label %9
9: ; preds = %6, %2
%10 = tail call i32 @unlink(i8* %0)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ waitTask();
void task2() {
  while (1) {
    printf("I am task2 \n");
    int i;
    for (i = 0; i < 25000; i++) {
    }
    waitTask();
  }
}


x86 assembly (clang, -O0):
<task2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x61a8,-0x4(%rbp)
jge    115b <task2+0x3b>
jmp    114d <task2+0x2d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113b <task2+0x1b>
mov    $0x0,%al
call   1030 <waitTask@plt>
jmp    1128 <task2+0x8>

x86 assembly (clang, -O2):
<task2>:
push   %rbx
lea    0xed8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <waitTask@plt>
jmp    1130 <task2+0x10>

LLVM IR (-O0):
@.str = [13 x i8] c"I am task2 \0A\00"
define void @task2() {
%1 = alloca i32
br label %2
2: ; preds = %0, %11
%3 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %4
4: ; preds = %8, %2
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 25000
br i1 %6, label %7, label %11
7: ; preds = %4
br label %8
8: ; preds = %7
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
store i32 %10, i32* %1
br label %4
11: ; preds = %4
%12 = call i32 (...) @waitTask()
br label %2
}

LLVM IR (-O2):
@str = [12 x i8] c"I am task2 \00"
define void @task2() {
br label %1
1: ; preds = %0, %1
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @waitTask()
br label %1
}
/* Type definitions */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int apc_all(void *cls, const struct sockaddr *addr, socklen_t addrlen) {
  (void)cls;
  (void)addr;
  (void)addrlen;
  return 1;
}


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

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

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
define i32 @apc_all(i8* %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.sockaddr*
%6 = alloca i32
store i8* %0, i8** %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load %struct.sockaddr*, %struct.sockaddr** %5
%9 = load i32, i32* %6
ret i32 1
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
define i32 @apc_all(i8* nocapture readnone %0, %struct.sockaddr* nocapture readnone %1, i32 %2) {
ret i32 1
}
/* Variables and functions */
size_t nlpo2(size_t x) {
  if (x == 1)
    goto out;
  x--;
  for (size_t i = 1; i < sizeof(size_t) * 8; i *= 2) {
    x |= (x >> i);
  }
  x++;
out:
  return x;
}


x86 assembly (clang, -O0):
<nlpo2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x1,-0x8(%rbp)
jne    1118 <nlpo2+0x18>
jmp    1167 <nlpo2+0x67>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
movq   $0x1,-0x10(%rbp)
cmpq   $0x40,-0x10(%rbp)
jae    115b <nlpo2+0x5b>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    %cl,%rax
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <nlpo2+0x2c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nlpo2>:
mov    $0x1,%eax
cmp    $0x1,%rdi
je     114e <nlpo2+0x4e>
add    $0xffffffffffffffff,%rdi
mov    %rdi,%rax
shr    %rax
or     %rdi,%rax
mov    %rax,%rcx
shr    $0x2,%rcx
or     %rax,%rcx
mov    %rcx,%rax
shr    $0x4,%rax
or     %rcx,%rax
mov    %rax,%rcx
shr    $0x8,%rcx
or     %rax,%rcx
mov    %rcx,%rdx
shr    $0x10,%rdx
or     %rcx,%rdx
mov    %rdx,%rax
shr    $0x20,%rax
or     %rdx,%rax
add    $0x1,%rax
ret

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

LLVM IR (-O2):
define i64 @nlpo2(i64 %0) {
%2 = icmp eq i64 %0, 1
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = add i64 %0, -1
%5 = lshr i64 %4, 1
%6 = or i64 %5, %4
%7 = lshr i64 %6, 2
%8 = or i64 %7, %6
%9 = lshr i64 %8, 4
%10 = or i64 %9, %8
%11 = lshr i64 %10, 8
%12 = or i64 %11, %10
%13 = lshr i64 %12, 16
%14 = or i64 %13, %12
%15 = lshr i64 %14, 32
%16 = or i64 %15, %14
%17 = add i64 %16, 1
br label %18
18: ; preds = %1, %3
%19 = phi i64 [ 1, %1 ], [ %17, %3 ]
ret i64 %19
}
/* Variables and functions */
double fmod(scalar_t__, double);
scalar_t__ pow(double, double);
double radians(double);
double sun_geometric_mean_longitude(double tm) {
  double rc =
      fmod(pow(0.0003032 * tm, 2.0) + 36000.76983 * tm + 280.46646, 360.0);
  return radians(rc);
}


x86 assembly (clang, -O0):
<sun_geometric_mean_longitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
call   1050 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xea7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe8f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
movsd  0xe76(%rip),%xmm0
call   1030 <fmod@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <radians@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun_geometric_mean_longitude>:
push   %rax
movapd %xmm0,%xmm1
movsd  %xmm0,(%rsp)
movsd  0xebe(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xeba(%rip),%xmm1
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
mulsd  0xea8(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  0xea4(%rip),%xmm1
cvttsd2si %xmm1,%rdi
movsd  0xe9f(%rip),%xmm0
call   1030 <fmod@plt>
pop    %rax
jmp    1040 <radians@plt>

LLVM IR (-O0):
define double @sun_geometric_mean_longitude(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fmul double 3.032000e-04, %4
%6 = call i64 @pow(double %5, double 2.000000e+00)
%7 = sitofp i64 %6 to double
%8 = load double, double* %2
%9 = call double @llvm.fmuladd.f64(double 0x40E19418A272862F, double %8, double %7)
%10 = fadd double %9, 0x407187769EC2CE46
%11 = fptosi double %10 to i64
%12 = call double @fmod(i64 %11, double 3.600000e+02)
store double %12, double* %3
%13 = load double, double* %3
%14 = call double @radians(double %13)
ret double %14
}

LLVM IR (-O2):
define double @sun_geometric_mean_longitude(double %0) {
%2 = fmul double %0, 3.032000e-04
%3 = tail call i64 @pow(double %2, double 2.000000e+00)
%4 = sitofp i64 %3 to double
%5 = tail call double @llvm.fmuladd.f64(double %0, double 0x40E19418A272862F, double %4)
%6 = fadd double %5, 0x407187769EC2CE46
%7 = fptosi double %6 to i64
%8 = tail call double @fmod(i64 %7, double 3.600000e+02)
%9 = tail call double @radians(double %8)
ret double %9
}
unsigned int read_be32(unsigned int val) {
  unsigned char *v = (unsigned char *)&val;
  return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3];
}


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

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

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

LLVM IR (-O2):
define i32 @read_be32(i32 %0) {
%2 = tail call i32 @llvm.bswap.i32(i32 %0)
ret i32 %2
}
long int FATORACAO(long int n) {
  long int numero = n;
  long int divisor = 1;
  long int resto;
  long int i = 2;
  while (numero != 1) {
    resto = numero % i;
    if (resto == 0) {
      divisor = i;
      numero /= i;
    } else
      i++;
  }
  return divisor;
}


x86 assembly (clang, -O0):
<FATORACAO>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x2,-0x28(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     1173 <FATORACAO+0x73>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x28(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1162 <FATORACAO+0x62>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    116e <FATORACAO+0x6e>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1120 <FATORACAO+0x20>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FATORACAO>:
mov    $0x1,%ecx
cmp    $0x1,%rdi
jne    110f <FATORACAO+0xf>
mov    %rcx,%rax
ret
mov    $0x2,%esi
jmp    1141 <FATORACAO+0x41>
cs nopw 0x0(%rax,%rax,1)
mov    %rdi,%rax
cqto
idiv   %rsi
test   %rdx,%rdx
cmove  %rsi,%rcx
cmove  %rax,%rdi
lea    0x1(%rsi),%rax
cmovne %rax,%rsi
cmp    $0x1,%rdi
je     110b <FATORACAO+0xb>
mov    %rdi,%rax
or     %rsi,%rax
shr    $0x20,%rax
jne    1120 <FATORACAO+0x20>
mov    %edi,%eax
xor    %edx,%edx
div    %esi
jmp    1128 <FATORACAO+0x28>

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

LLVM IR (-O2):
define i64 @FATORACAO(i64 %0) {
%2 = icmp eq i64 %0, 1
br i1 %2, label %15, label %3
3: ; preds = %1, %3
%4 = phi i64 [ %13, %3 ], [ 2, %1 ]
%5 = phi i64 [ %12, %3 ], [ %0, %1 ]
%6 = phi i64 [ %11, %3 ], [ 1, %1 ]
%7 = srem i64 %5, %4
%8 = sdiv i64 %5, %4
%9 = icmp eq i64 %7, 0
%10 = add nsw i64 %4, 1
%11 = select i1 %9, i64 %4, i64 %6
%12 = select i1 %9, i64 %8, i64 %5
%13 = select i1 %9, i64 %4, i64 %10
%14 = icmp eq i64 %12, 1
br i1 %14, label %15, label %3
15: ; preds = %3, %1
%16 = phi i64 [ 1, %1 ], [ %11, %3 ]
ret i64 %16
}
unsigned short int cast_long_ushort(long int x) {
  return (unsigned short int)x;
}


x86 assembly (clang, -O0):
<cast_long_ushort>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzwl %ax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cast_long_ushort>:
mov    %rdi,%rax
ret

LLVM IR (-O0):
define zeroext i16 @cast_long_ushort(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = trunc i64 %3 to i16
ret i16 %4
}

LLVM IR (-O2):
define zeroext i16 @cast_long_ushort(i64 %0) {
%2 = trunc i64 %0 to i16
ret i16 %2
}
void kvmppc_uvmem_slot_free(struct kvm *kvm,
                            const struct kvm_memory_slot *slot) {}


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

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

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

LLVM IR (-O2):
%struct.kvm = type opaque
%struct.kvm_memory_slot = type opaque
define void @kvmppc_uvmem_slot_free(%struct.kvm* nocapture %0, %struct.kvm_memory_slot* nocapture %1) {
ret void
}
/* Variables and functions */
double sqrt(double);
double sq(double x) { return (sqrt(x)); }


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

x86 assembly (clang, -O2):
<sq>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     111f <sq+0xf>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

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

LLVM IR (-O2):
define double @sq(double %0) {
%2 = tail call double @sqrt(double %0)
ret double %2
}
/* Variables and functions */
int linked_mem_pool_destroy(void *);
int virtual_machine_resource_pool_linked_uninit(void *pool_ptr) {
  return linked_mem_pool_destroy(pool_ptr);
}


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

x86 assembly (clang, -O2):
<virtual_machine_resource_pool_linked_uninit>:
jmp    1030 <linked_mem_pool_destroy@plt>

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

LLVM IR (-O2):
define i32 @virtual_machine_resource_pool_linked_uninit(i8* %0) {
%2 = tail call i32 @linked_mem_pool_destroy(i8* %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ SerialWriteString(char *);
void iRobot_SetClock(unsigned short day, unsigned short hour,
                     unsigned short minute) {
  char data[] = {168, day, hour, minute};
  SerialWriteString(data);
}


x86 assembly (clang, -O0):
<iRobot_SetClock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %di,%dx
mov    %dx,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
movb   $0xa8,-0xa(%rbp)
mov    -0x2(%rbp),%ax
mov    %al,-0x9(%rbp)
mov    -0x4(%rbp),%ax
mov    %al,-0x8(%rbp)
mov    -0x6(%rbp),%ax
mov    %al,-0x7(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <SerialWriteString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iRobot_SetClock>:
push   %rax
movb   $0xa8,0x4(%rsp)
mov    %dil,0x5(%rsp)
mov    %sil,0x6(%rsp)
mov    %dl,0x7(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <SerialWriteString@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @iRobot_SetClock(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca [4 x i8]
store i16 %0, i16* %4
store i16 %1, i16* %5
store i16 %2, i16* %6
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 -88, i8* %8
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i16, i16* %4
%11 = trunc i16 %10 to i8
store i8 %11, i8* %9
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = load i16, i16* %5
%14 = trunc i16 %13 to i8
store i8 %14, i8* %12
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = load i16, i16* %6
%17 = trunc i16 %16 to i8
store i8 %17, i8* %15
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%19 = call i32 @SerialWriteString(i8* %18)
ret void
}

LLVM IR (-O2):
define void @iRobot_SetClock(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8 -88, i8* %5
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%7 = trunc i16 %0 to i8
store i8 %7, i8* %6
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%9 = trunc i16 %1 to i8
store i8 %9, i8* %8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%11 = trunc i16 %2 to i8
store i8 %11, i8* %10
%12 = call i32 @SerialWriteString(i8* %5)
ret void
}