#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 */
typedef int pid_t;

/* Variables and functions */
int make_process(int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
int main() {
  pid_t process[20] = {0};
  int number = 0;
  while (1) {
    sleep(1);
    pid_t p = make_process(process, number++);
    printf("create process %d\n", p);
    if (number == 10)
      break;
  }
  while (1) {
    int status = 0;
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
movl   $0x0,-0x64(%rbp)
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
call   1030 <make_process@plt>
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xa,-0x64(%rbp)
jne    11a5 <main+0x65>
jmp    11aa <main+0x6a>
jmp    1166 <main+0x26>
jmp    11af <main+0x6f>
movl   $0x0,-0x6c(%rbp)
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    11af <main+0x6f>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <make_process@plt>
lea    0xe90(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x8,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    $0x9,%esi
call   1030 <make_process@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    12b0 <main+0x180>

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

LLVM IR (-O2):
@.str = [19 x i8] c"create process %d\0A\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @sleep(i32 1)
%5 = call i32 @make_process(i32* %3, i32 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @sleep(i32 1)
%8 = call i32 @make_process(i32* %3, i32 1)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @sleep(i32 1)
%11 = call i32 @make_process(i32* %3, i32 2)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @sleep(i32 1)
%14 = call i32 @make_process(i32* %3, i32 3)
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @sleep(i32 1)
%17 = call i32 @make_process(i32* %3, i32 4)
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @sleep(i32 1)
%20 = call i32 @make_process(i32* %3, i32 5)
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 @sleep(i32 1)
%23 = call i32 @make_process(i32* %3, i32 6)
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 @sleep(i32 1)
%26 = call i32 @make_process(i32* %3, i32 7)
%27 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = call i32 @sleep(i32 1)
%29 = call i32 @make_process(i32* %3, i32 8)
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = call i32 @sleep(i32 1)
%32 = call i32 @make_process(i32* %3, i32 9)
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %0, %34
%35 = call i32 @sleep(i32 1)
br label %34
}