#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*/ spool_write_script(int);
void *mythread(void *unused) {
  int i;
  for (i = 0; i < 30; i++)
    spool_write_script(i);
  return NULL;
}


x86 assembly (clang, -O0):
<mythread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1e,-0xc(%rbp)
jge    1143 <mythread+0x33>
mov    -0xc(%rbp),%edi
call   1030 <spool_write_script@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <mythread+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mythread>:
push   %rax
xor    %edi,%edi
call   1030 <spool_write_script@plt>
mov    $0x1,%edi
call   1030 <spool_write_script@plt>
mov    $0x2,%edi
call   1030 <spool_write_script@plt>
mov    $0x3,%edi
call   1030 <spool_write_script@plt>
mov    $0x4,%edi
call   1030 <spool_write_script@plt>
mov    $0x5,%edi
call   1030 <spool_write_script@plt>
mov    $0x6,%edi
call   1030 <spool_write_script@plt>
mov    $0x7,%edi
call   1030 <spool_write_script@plt>
mov    $0x8,%edi
call   1030 <spool_write_script@plt>
mov    $0x9,%edi
call   1030 <spool_write_script@plt>
mov    $0xa,%edi
call   1030 <spool_write_script@plt>
mov    $0xb,%edi
call   1030 <spool_write_script@plt>
mov    $0xc,%edi
call   1030 <spool_write_script@plt>
mov    $0xd,%edi
call   1030 <spool_write_script@plt>
mov    $0xe,%edi
call   1030 <spool_write_script@plt>
mov    $0xf,%edi
call   1030 <spool_write_script@plt>
mov    $0x10,%edi
call   1030 <spool_write_script@plt>
mov    $0x11,%edi
call   1030 <spool_write_script@plt>
mov    $0x12,%edi
call   1030 <spool_write_script@plt>
mov    $0x13,%edi
call   1030 <spool_write_script@plt>
mov    $0x14,%edi
call   1030 <spool_write_script@plt>
mov    $0x15,%edi
call   1030 <spool_write_script@plt>
mov    $0x16,%edi
call   1030 <spool_write_script@plt>
mov    $0x17,%edi
call   1030 <spool_write_script@plt>
mov    $0x18,%edi
call   1030 <spool_write_script@plt>
mov    $0x19,%edi
call   1030 <spool_write_script@plt>
mov    $0x1a,%edi
call   1030 <spool_write_script@plt>
mov    $0x1b,%edi
call   1030 <spool_write_script@plt>
mov    $0x1c,%edi
call   1030 <spool_write_script@plt>
mov    $0x1d,%edi
call   1030 <spool_write_script@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i8* @mythread(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %10, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 30
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i32 @spool_write_script(i32 %8)
br label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
br label %4
13: ; preds = %4
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @mythread(i8* nocapture readnone %0) {
%2 = tail call i32 @spool_write_script(i32 0)
%3 = tail call i32 @spool_write_script(i32 1)
%4 = tail call i32 @spool_write_script(i32 2)
%5 = tail call i32 @spool_write_script(i32 3)
%6 = tail call i32 @spool_write_script(i32 4)
%7 = tail call i32 @spool_write_script(i32 5)
%8 = tail call i32 @spool_write_script(i32 6)
%9 = tail call i32 @spool_write_script(i32 7)
%10 = tail call i32 @spool_write_script(i32 8)
%11 = tail call i32 @spool_write_script(i32 9)
%12 = tail call i32 @spool_write_script(i32 10)
%13 = tail call i32 @spool_write_script(i32 11)
%14 = tail call i32 @spool_write_script(i32 12)
%15 = tail call i32 @spool_write_script(i32 13)
%16 = tail call i32 @spool_write_script(i32 14)
%17 = tail call i32 @spool_write_script(i32 15)
%18 = tail call i32 @spool_write_script(i32 16)
%19 = tail call i32 @spool_write_script(i32 17)
%20 = tail call i32 @spool_write_script(i32 18)
%21 = tail call i32 @spool_write_script(i32 19)
%22 = tail call i32 @spool_write_script(i32 20)
%23 = tail call i32 @spool_write_script(i32 21)
%24 = tail call i32 @spool_write_script(i32 22)
%25 = tail call i32 @spool_write_script(i32 23)
%26 = tail call i32 @spool_write_script(i32 24)
%27 = tail call i32 @spool_write_script(i32 25)
%28 = tail call i32 @spool_write_script(i32 26)
%29 = tail call i32 @spool_write_script(i32 27)
%30 = tail call i32 @spool_write_script(i32 28)
%31 = tail call i32 @spool_write_script(i32 29)
ret i8* null
}