#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ delay();
int gettid();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ pthread_exit();
void output() {
  int j;
  for (j = 0; j < 50; j++) {
    delay();
  }
  printf("[%d] THREAD EXIT\n", gettid());
  pthread_exit();
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x32,-0x4(%rbp)
jge    116e <output+0x2e>
mov    $0x0,%al
call   1050 <delay@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <output+0xf>
mov    $0x0,%al
call   1030 <gettid@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <pthread_exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %rax
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1030 <gettid@plt>
lea    0xd53(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <pthread_exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"[%d] THREAD EXIT\0A\00"
define void @output() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %7, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 50
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = call i32 (...) @delay()
br label %7
7: ; preds = %5
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
br label %2
10: ; preds = %2
%11 = call i32 (...) @gettid()
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @pthread_exit()
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"[%d] THREAD EXIT\0A\00"
define void @output() {
%1 = tail call i32 (...) @delay()
%2 = tail call i32 (...) @delay()
%3 = tail call i32 (...) @delay()
%4 = tail call i32 (...) @delay()
%5 = tail call i32 (...) @delay()
%6 = tail call i32 (...) @delay()
%7 = tail call i32 (...) @delay()
%8 = tail call i32 (...) @delay()
%9 = tail call i32 (...) @delay()
%10 = tail call i32 (...) @delay()
%11 = tail call i32 (...) @delay()
%12 = tail call i32 (...) @delay()
%13 = tail call i32 (...) @delay()
%14 = tail call i32 (...) @delay()
%15 = tail call i32 (...) @delay()
%16 = tail call i32 (...) @delay()
%17 = tail call i32 (...) @delay()
%18 = tail call i32 (...) @delay()
%19 = tail call i32 (...) @delay()
%20 = tail call i32 (...) @delay()
%21 = tail call i32 (...) @delay()
%22 = tail call i32 (...) @delay()
%23 = tail call i32 (...) @delay()
%24 = tail call i32 (...) @delay()
%25 = tail call i32 (...) @delay()
%26 = tail call i32 (...) @delay()
%27 = tail call i32 (...) @delay()
%28 = tail call i32 (...) @delay()
%29 = tail call i32 (...) @delay()
%30 = tail call i32 (...) @delay()
%31 = tail call i32 (...) @delay()
%32 = tail call i32 (...) @delay()
%33 = tail call i32 (...) @delay()
%34 = tail call i32 (...) @delay()
%35 = tail call i32 (...) @delay()
%36 = tail call i32 (...) @delay()
%37 = tail call i32 (...) @delay()
%38 = tail call i32 (...) @delay()
%39 = tail call i32 (...) @delay()
%40 = tail call i32 (...) @delay()
%41 = tail call i32 (...) @delay()
%42 = tail call i32 (...) @delay()
%43 = tail call i32 (...) @delay()
%44 = tail call i32 (...) @delay()
%45 = tail call i32 (...) @delay()
%46 = tail call i32 (...) @delay()
%47 = tail call i32 (...) @delay()
%48 = tail call i32 (...) @delay()
%49 = tail call i32 (...) @delay()
%50 = tail call i32 (...) @delay()
%51 = tail call i32 (...) @gettid()
%52 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = tail call i32 (...) @pthread_exit()
ret void
}