#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ getpid();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sleep(int);
int process(int i) {
  printf("I AM PROCESS %d, id = %d\n", i, (int)getpid());
  if (i == 2) {
    return EXIT_FAILURE;
  }
  if (i == 1)
    return EXIT_SUCCESS;
  sleep(60);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1174 <process+0x44>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <process+0x75>
cmpl   $0x1,-0x8(%rbp)
jne    118f <process+0x5f>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <process+0x75>
mov    $0x3c,%edi
call   1050 <sleep@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xebf(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
cmp    $0x2,%ebx
je     1167 <process+0x37>
cmp    $0x1,%ebx
je     115e <process+0x2e>
mov    $0x3c,%edi
call   1050 <sleep@plt>
mov    0x2e73(%rip),%rax
jmp    116e <process+0x3e>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"I AM PROCESS %d, id = %d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @process(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 (...) @getpid()
%6 = trunc i64 %5 to i32
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %2
br label %20
12: ; preds = %1
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* @EXIT_SUCCESS
store i32 %16, i32* %2
br label %20
17: ; preds = %12
%18 = call i32 @sleep(i32 60)
%19 = load i32, i32* @EXIT_SUCCESS
store i32 %19, i32* %2
br label %20
20: ; preds = %17, %15, %10
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [26 x i8] c"I AM PROCESS %d, id = %d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @process(i32 %0) {
%2 = tail call i64 (...) @getpid()
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %3)
switch i32 %0, label %6 [
i32 2, label %8
i32 1, label %5
]
5: ; preds = %1
br label %8
6: ; preds = %1
%7 = tail call i32 @sleep(i32 60)
br label %8
8: ; preds = %1, %6, %5
%9 = phi i32* [ @EXIT_SUCCESS, %5 ], [ @EXIT_SUCCESS, %6 ], [ @EXIT_FAILURE, %1 ]
%10 = load i32, i32* %9
ret i32 %10
}