#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*/ fprintf(int /*<<< orphan*/, char *, int, int);
int getpid();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main() {
  int i;
  for (i = 0; i < 10; i++) {
    fprintf(stdout, "PID=%d; iteration=%d\n", getpid(), i + 1);
    sleep(5);
  }
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1192 <main+0x62>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
lea    0xe8b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2ea5(%rip),%r14
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xeb4(%rip),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x1,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x2,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x3,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x4,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x5,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x6,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x7,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x8,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x9,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0xa,%ecx
call   1040 <fprintf@plt>
mov    $0x5,%edi
call   1050 <sleep@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [22 x i8] c"PID=%d; iteration=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* @stdout
%8 = call i32 (...) @getpid()
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10)
%12 = call i32 @sleep(i32 5)
br label %13
13: ; preds = %6
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %3
16: ; preds = %3
ret i32 1
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"PID=%d; iteration=%d\0A\00"
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %2, i32 1)
%4 = tail call i32 @sleep(i32 5)
%5 = load i32, i32* @stdout
%6 = tail call i32 (...) @getpid()
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %6, i32 2)
%8 = tail call i32 @sleep(i32 5)
%9 = load i32, i32* @stdout
%10 = tail call i32 (...) @getpid()
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i32 3)
%12 = tail call i32 @sleep(i32 5)
%13 = load i32, i32* @stdout
%14 = tail call i32 (...) @getpid()
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %14, i32 4)
%16 = tail call i32 @sleep(i32 5)
%17 = load i32, i32* @stdout
%18 = tail call i32 (...) @getpid()
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %18, i32 5)
%20 = tail call i32 @sleep(i32 5)
%21 = load i32, i32* @stdout
%22 = tail call i32 (...) @getpid()
%23 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %22, i32 6)
%24 = tail call i32 @sleep(i32 5)
%25 = load i32, i32* @stdout
%26 = tail call i32 (...) @getpid()
%27 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %26, i32 7)
%28 = tail call i32 @sleep(i32 5)
%29 = load i32, i32* @stdout
%30 = tail call i32 (...) @getpid()
%31 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %30, i32 8)
%32 = tail call i32 @sleep(i32 5)
%33 = load i32, i32* @stdout
%34 = tail call i32 (...) @getpid()
%35 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %34, i32 9)
%36 = tail call i32 @sleep(i32 5)
%37 = load i32, i32* @stdout
%38 = tail call i32 (...) @getpid()
%39 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %38, i32 10)
%40 = tail call i32 @sleep(i32 5)
ret i32 1
}