#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 WEXITSTATUS(int);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ wait(int *);
int main(int args, char *argc[]) {
  int status = 0;
  int resch0 = 0;
  int resch1 = 0;
  int i = 0;
  int sum1 = 2;
  int sum2 = 5;
  int childNum = 2;
  int childs[childNum];
  for (i = 0; i < childNum; i++) {
    childs[i] = fork();
  }
  if (childs[0] == 0) {
    resch0 = sum1 + sum2;
    exit(resch0);
  } else if (childs[1] == 0) {
    resch1 = sum1 * sum2;
    exit(resch1);
  } else {
    wait(&resch0);
    wait(&resch1);
    printf("Los resultados de mis hijos son: %d y %d \n", WEXITSTATUS(resch0),
           WEXITSTATUS(resch1));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x2,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11f3 <main+0xa3>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c5 <main+0x75>
mov    -0x48(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1211 <main+0xc1>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <exit@plt>
mov    -0x48(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    1231 <main+0xe1>
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1060 <wait@plt>
lea    -0x1c(%rbp),%rdi
call   1060 <wait@plt>
mov    -0x18(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
lea    0xd9e(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <main+0x11c>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%r14
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
xor    %eax,%eax
call   1070 <fork@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <fork@plt>
test   %ebx,%ebx
je     11c0 <main+0x70>
test   %eax,%eax
je     11ca <main+0x7a>
lea    0x4(%rsp),%rdi
call   1060 <wait@plt>
mov    %rsp,%rdi
call   1060 <wait@plt>
mov    0x4(%rsp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,%ebx
mov    (%rsp),%edi
call   1040 <WEXITSTATUS@plt>
lea    0xe56(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x7,%edi
call   1050 <exit@plt>
mov    $0xa,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"Los resultados de mis hijos son: %d y %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 2, i32* %10
store i32 5, i32* %11
store i32 2, i32* %12
%15 = load i32, i32* %12
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %13
%18 = alloca i32, i64 %16
store i64 %16, i64* %14
store i32 0, i32* %9
br label %19
19: ; preds = %28, %2
%20 = load i32, i32* %9
%21 = load i32, i32* %12
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = call i32 (...) @fork()
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %18, i64 %26
store i32 %24, i32* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %19
31: ; preds = %19
%32 = getelementptr inbounds i32, i32* %18, i64 0
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = add nsw i32 %36, %37
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %31
%42 = getelementptr inbounds i32, i32* %18, i64 1
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i32, i32* %10
%47 = load i32, i32* %11
%48 = mul nsw i32 %46, %47
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %41
%52 = call i32 @wait(i32* %7)
%53 = call i32 @wait(i32* %8)
%54 = load i32, i32* %7
%55 = call i32 @WEXITSTATUS(i32 %54)
%56 = load i32, i32* %8
%57 = call i32 @WEXITSTATUS(i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %55, i32 %57)
br label %59
59: ; preds = %51
br label %60
60: ; preds = %59
%61 = load i8*, i8** %13
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [43 x i8] c"Los resultados de mis hijos son: %d y %d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = tail call i8* @llvm.stacksave()
%8 = tail call i32 (...) @fork()
%9 = tail call i32 (...) @fork()
%10 = icmp eq i32 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @exit(i32 7)
unreachable
13: ; preds = %2
%14 = icmp eq i32 %9, 0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @exit(i32 10)
unreachable
17: ; preds = %13
%18 = call i32 @wait(i32* %3)
%19 = call i32 @wait(i32* %4)
%20 = load i32, i32* %3
%21 = call i32 @WEXITSTATUS(i32 %20)
%22 = load i32, i32* %4
%23 = call i32 @WEXITSTATUS(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23)
ret i32 0
}