#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*/ printf(char *, int, int);
void *loop(void *in) {
  int i;
  int name;
  name = *((int *)in);
  for (i = 0; i < 100000000; i++) {
    if (i % 1000000 == 0) {
      (void)printf("Thread %d: %d\n", name, i);
    }
  }
  return ((void *)NULL);
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x5f5e100,-0xc(%rbp)
jge    1172 <loop+0x62>
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115f <loop+0x4f>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
jmp    1164 <loop+0x54>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112c <loop+0x1c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%ebx
xor    %ebp,%ebp
lea    0xee1(%rip),%r14
jmp    113b <loop+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x5f5e100,%ebp
je     1160 <loop+0x50>
mov    %ebp,%eax
imul   $0x431bde83,%rax,%rax
shr    $0x32,%rax
imul   $0xf4240,%eax,%eax
cmp    %ebp,%eax
jne    1130 <loop+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
jmp    1130 <loop+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Thread %d: %d\0A\00"
define i8* @loop(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
store i32 %7, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %20, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 100000000
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 1000000
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %8
23: ; preds = %8
ret i8* null
}

LLVM IR (-O2):
@.str = [15 x i8] c"Thread %d: %d\0A\00"
define noalias i8* @loop(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
br label %4
4: ; preds = %1, %10
%5 = phi i32 [ 0, %1 ], [ %11, %10 ]
%6 = urem i32 %5, 1000000
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5)
br label %10
10: ; preds = %4, %8
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 100000000
br i1 %12, label %13, label %4
13: ; preds = %10
ret i8* null
}