#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 getpid();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ wait(int, int *, int /*<<< orphan*/ *);
int main() {
  int pid, status;
  int fd[2];
  pipe(fd);
  pid = fork();
  if (pid == 0) {
    printf("Este es el proceso hijo con pid %d\n", getpid());
    exit(0);
  }
  printf("Este el es proceso padre con pid %d\n", getpid());
  printf("Estos son los descriptores de fichero pipe0 %d y pipe1 %d\n", fd[0],
         fd[1]);
  wait(pid, &status, NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
call   1050 <pipe@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11a3 <main+0x43>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <wait@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x4(%rsp),%rdi
call   1050 <pipe@plt>
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
test   %ebx,%ebx
je     11bf <main+0x5f>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1070 <wait@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe3a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Este es el proceso hijo con pid %d\0A\00"
@.str.1 = [37 x i8] c"Este el es proceso padre con pid %d\0A\00"
@.str.2 = [59 x i8] c"Estos son los descriptores de fichero pipe0 %d y pipe1 %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%5 = call i32 @pipe(i32* %4)
%6 = call i32 (...) @fork()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32 (...) @getpid()
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = call i32 (...) @getpid()
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %19)
%21 = load i32, i32* %1
%22 = call i32 @wait(i32 %21, i32* %2, i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Este es el proceso hijo con pid %d\0A\00"
@.str.1 = [37 x i8] c"Este el es proceso padre con pid %d\0A\00"
@.str.2 = [59 x i8] c"Estos son los descriptores de fichero pipe0 %d y pipe1 %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [2 x i32]* %2 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = call i32 (...) @fork()
%8 = icmp eq i32 %7, 0
%9 = call i32 (...) @getpid()
br i1 %8, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%15 = load i32, i32* %5
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %17)
%19 = call i32 @wait(i32 %7, i32* %1, i32* null)
ret i32 0
}