#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int fds[2];
  char buf[128];
  int n;
  pipe(fds);
  write(fds[1], "hello", 5);
  n = read(fds[0], buf, sizeof(buf));
  printf("%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <pipe@plt>
mov    -0x8(%rbp),%edi
lea    0xe9b(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1060 <read@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [128 x i8]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = getelementptr inbounds [128 x i8], [128 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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%10 = load i32, i32* %5
%11 = call i32 @read(i32 %10, i8* %4, i32 128)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}