#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 /*<<< orphan*/ bigFor();
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main(int argc, char const *argv[]) {
  pid_t p;
  p = fork();
  if (p == -1) {
    perror("Couldn't create a fork");
    exit(-1);
  }
  if (p == 0) {
    bigFor();
    printf("Soy el hijo\n");
  } else {
    sleep(10);
    bigFor();
    printf("Soy el padre\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11a0 <main+0x40>
lea    0xe6f(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11c2 <main+0x62>
mov    $0x0,%al
call   1040 <bigFor@plt>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <main+0x7f>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    $0x0,%al
call   1040 <bigFor@plt>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1184 <main+0x24>
cmp    $0xffffffff,%eax
je     119e <main+0x3e>
mov    $0xa,%edi
call   1070 <sleep@plt>
lea    0xe95(%rip),%rbx
jmp    118b <main+0x2b>
lea    0xe99(%rip),%rbx
xor    %eax,%eax
call   1040 <bigFor@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe5b(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Couldn't create a fork\00"
@.str.1 = [13 x i8] c"Soy el hijo\0A\00"
@.str.2 = [14 x i8] c"Soy el padre\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @fork()
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 (...) @bigFor()
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %23
19: ; preds = %13
%20 = call i32 @sleep(i32 10)
%21 = call i32 (...) @bigFor()
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %19, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Couldn't create a fork\00"
@str = [13 x i8] c"Soy el padre\00"
@str.3 = [12 x i8] c"Soy el hijo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @fork()
switch i32 %3, label %7 [
i32 -1, label %4
i32 0, label %9
]
4: ; preds = %2
%5 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = tail call i32 @sleep(i32 10)
br label %9
9: ; preds = %2, %7
%10 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0), %2 ]
%11 = tail call i32 (...) @bigFor()
%12 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}