#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*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char *msg = "How are you?";
  char inbuff[16];
  int p[2];
  int ret;
  pipe(p);
  ret = fork();
  if (ret > 0) {
    write(p[1], msg, 16);
  } else {
    sleep(1);
    read(p[0], inbuff, 16);
    printf("%s\n", inbuff);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <pipe@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    11bd <main+0x4d>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
jmp    11e8 <main+0x78>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x28(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1060 <read@plt>
lea    -0x20(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x8(%rsp),%rdi
call   1050 <pipe@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jle    11a6 <main+0x36>
mov    0xc(%rsp),%edi
lea    0xe6b(%rip),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
lea    0xe40(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"How are you?\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [16 x i8]
%4 = alloca [2 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%7 = call i32 @pipe(i32* %6)
%8 = call i32 (...) @fork()
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%13 = load i32, i32* %12
%14 = load i8*, i8** %2
%15 = call i32 @write(i32 %13, i8* %14, i32 16)
br label %24
16: ; preds = %0
%17 = call i32 @sleep(i32 1)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 16)
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %16, %11
%25 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"How are you?\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [2 x i32]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%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 sgt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 16)
br label %18
13: ; preds = %0
%14 = call i32 @sleep(i32 1)
%15 = load i32, i32* %5
%16 = call i32 @read(i32 %15, i8* %3, i32 16)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %13, %9
%19 = call i32 @exit(i32 0)
unreachable
}