#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*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[], char *env[]) {
  int i, a = 1;
  for (i = 0; i < 10; i++) {
    switch (fork()) {
    case 0:
      a = 3;
      printf("a=%d\n", a);
      break;
    case -1:
      printf("Error al crear el proceso hijo\n");
      exit(0);
    }
    printf("a=%d\n", a);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11dd <main+0xad>
xor    %eax,%eax
call   1050 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
sub    $0xffffffff,%eax
je     11a9 <main+0x79>
jmp    117c <main+0x4c>
mov    -0x24(%rbp),%eax
test   %eax,%eax
jne    11be <main+0x8e>
jmp    118c <main+0x5c>
movl   $0x3,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <main+0x8e>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
mov    -0x20(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <main+0x28>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
mov    $0x1,%ebx
test   %eax,%eax
jne    1172 <main+0x32>
lea    0xe9f(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    11ae <main+0x6e>
lea    0xe63(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    11ea <main+0xaa>
lea    0xe27(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    1226 <main+0xe6>
lea    0xdeb(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    1262 <main+0x122>
lea    0xdaf(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd97(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    129e <main+0x15e>
lea    0xd73(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd5b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    12da <main+0x19a>
lea    0xd37(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd1f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    1316 <main+0x1d6>
lea    0xcfb(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xce3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    134e <main+0x20e>
lea    0xcc3(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcab(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     139d <main+0x25d>
test   %eax,%eax
jne    1386 <main+0x246>
lea    0xc8b(%rip),%rdi
mov    $0x3,%ebx
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc73(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
lea    0xc62(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"a=%d\0A\00"
@.str.1 = [32 x i8] c"Error al crear el proceso hijo\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 1, i32* %9
store i32 0, i32* %8
br label %10
10: ; preds = %24, %3
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = call i32 (...) @fork()
switch i32 %14, label %21 [
i32 0, label %15
i32 -1, label %18
]
15: ; preds = %13
store i32 3, i32* %9
%16 = load i32, i32* %9
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %21
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %13, %15
%22 = load i32, i32* %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %10
27: ; preds = %10
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"a=%d\0A\00"
@str = [31 x i8] c"Error al crear el proceso hijo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = tail call i32 (...) @fork()
switch i32 %4, label %10 [
i32 0, label %5
i32 -1, label %7
]
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %10
7: ; preds = %58, %52, %46, %40, %34, %28, %22, %16, %10, %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %3, %5
%11 = phi i32 [ 1, %3 ], [ 3, %5 ]
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 (...) @fork()
switch i32 %13, label %16 [
i32 0, label %14
i32 -1, label %7
]
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %16
16: ; preds = %14, %10
%17 = phi i32 [ %11, %10 ], [ 3, %14 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = tail call i32 (...) @fork()
switch i32 %19, label %22 [
i32 0, label %20
i32 -1, label %7
]
20: ; preds = %16
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %22
22: ; preds = %20, %16
%23 = phi i32 [ %17, %16 ], [ 3, %20 ]
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = tail call i32 (...) @fork()
switch i32 %25, label %28 [
i32 0, label %26
i32 -1, label %7
]
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %28
28: ; preds = %26, %22
%29 = phi i32 [ %23, %22 ], [ 3, %26 ]
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = tail call i32 (...) @fork()
switch i32 %31, label %34 [
i32 0, label %32
i32 -1, label %7
]
32: ; preds = %28
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %34
34: ; preds = %32, %28
%35 = phi i32 [ %29, %28 ], [ 3, %32 ]
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = tail call i32 (...) @fork()
switch i32 %37, label %40 [
i32 0, label %38
i32 -1, label %7
]
38: ; preds = %34
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %40
40: ; preds = %38, %34
%41 = phi i32 [ %35, %34 ], [ 3, %38 ]
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = tail call i32 (...) @fork()
switch i32 %43, label %46 [
i32 0, label %44
i32 -1, label %7
]
44: ; preds = %40
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %46
46: ; preds = %44, %40
%47 = phi i32 [ %41, %40 ], [ 3, %44 ]
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = tail call i32 (...) @fork()
switch i32 %49, label %52 [
i32 0, label %50
i32 -1, label %7
]
50: ; preds = %46
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %52
52: ; preds = %50, %46
%53 = phi i32 [ %47, %46 ], [ 3, %50 ]
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = tail call i32 (...) @fork()
switch i32 %55, label %58 [
i32 0, label %56
i32 -1, label %7
]
56: ; preds = %52
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %58
58: ; preds = %56, %52
%59 = phi i32 [ %53, %52 ], [ 3, %56 ]
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = tail call i32 (...) @fork()
switch i32 %61, label %64 [
i32 0, label %62
i32 -1, label %7
]
62: ; preds = %58
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 3)
br label %64
64: ; preds = %62, %58
%65 = phi i32 [ %59, %58 ], [ 3, %62 ]
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %65)
%67 = tail call i32 @exit(i32 0)
unreachable
}