#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*/ close(int);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int pip[2];
  char buf[1024];
  pipe(pip);
  write(pip[1], "hola mundo\n", 12);
  read(pip[0], buf, sizeof buf);
  printf("%s", buf);
  close(pip[0]);
  close(pip[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <pipe@plt>
mov    -0x8(%rbp),%edi
lea    0xe8b(%rip),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1070 <read@plt>
lea    -0x410(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
lea    0x8(%rsp),%rdi
call   1060 <pipe@plt>
mov    0xc(%rsp),%edi
lea    0xe93(%rip),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"hola mundo\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [1024 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%5 = call i32 @pipe(i32* %4)
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%7 = load i32, i32* %6
%8 = call i32 @write(i32 %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 12)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 1024)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%16 = load i32, i32* %15
%17 = call i32 @close(i32 %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 @close(i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"hola mundo\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [1024 x i8]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 12)
%10 = load i32, i32* %5
%11 = call i32 @read(i32 %10, i8* %4, i32 1024)
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%13 = load i32, i32* %5
%14 = call i32 @close(i32 %13)
%15 = load i32, i32* %7
%16 = call i32 @close(i32 %15)
ret i32 0
}