#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
void *DoSomething(void *threadid) {
  long tid;
  tid = (long)threadid;
  printf("Hello World! It's me, thread #%ld!\n", tid);
  fflush(stdout);
  int i, j, k, sum;
  for (i = 0; i < 5000; i++) {
    int a = i;
    a++;
  }
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<DoSomething>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1388,-0x1c(%rbp)
jge    1193 <DoSomething+0x63>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1169 <DoSomething+0x39>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoSomething>:
push   %rax
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %edi,%edi
pop    %rax
jmp    1040 <pthread_exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Hello World! It's me, thread #%ld!\0A\00"
@stdout = global i32 0
define i8* @DoSomething(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = ptrtoint i8* %10 to i64
store i64 %11, i64* %4
%12 = load i64, i64* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
store i32 0, i32* %5
br label %16
16: ; preds = %23, %1
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 5000
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %5
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
br label %23
23: ; preds = %19
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %16
26: ; preds = %16
%27 = call i32 @pthread_exit(i32* null)
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@.str = [36 x i8] c"Hello World! It's me, thread #%ld!\0A\00"
@stdout = global i32 0
define noalias i8* @DoSomething(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %2)
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
%6 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}