#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 fork();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int i;
  int pid;
  i = 100;
  pid = fork();
  if (pid == 0) {
    for (i = 0; (i <= 100); i++) {
      printf("HIJO: El valor de i es %d\n", i);
    }
  } else {
    for (i = 0; (i <= 100); i++) {
      printf("PADRE: El valor de i es %d\n", i);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
mov    $0x0,%al
call   1040 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117d <main+0x5d>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     1178 <main+0x58>
mov    -0x8(%rbp),%esi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <main+0x31>
jmp    11b0 <main+0x90>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     11ab <main+0x8b>
mov    -0x8(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x64>
jmp    11b0 <main+0x90>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <fork@plt>
test   %eax,%eax
je     1154 <main+0x34>
lea    0xee3(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <main+0x20>
jmp    1172 <main+0x52>
xor    %ebx,%ebx
lea    0xea3(%rip),%r14
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"HIJO: El valor de i es %d\0A\00"
@.str.1 = [28 x i8] c"PADRE: El valor de i es %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %2
%4 = call i32 (...) @fork()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %0
store i32 0, i32* %2
br label %8
8: ; preds = %14, %7
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 100
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %8
17: ; preds = %8
br label %29
18: ; preds = %0
store i32 0, i32* %2
br label %19
19: ; preds = %25, %18
%20 = load i32, i32* %2
%21 = icmp sle i32 %20, 100
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %19
28: ; preds = %19
br label %29
29: ; preds = %28, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"HIJO: El valor de i es %d\0A\00"
@.str.1 = [28 x i8] c"PADRE: El valor de i es %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0, %3
%4 = phi i32 [ %6, %3 ], [ 0, %0 ]
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 101
br i1 %7, label %13, label %3
8: ; preds = %0, %8
%9 = phi i32 [ %11, %8 ], [ 0, %0 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, 101
br i1 %12, label %13, label %8
13: ; preds = %8, %3
ret i32 0
}