#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_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int pipe(int *);
int /*<<< orphan*/ read_msg(int *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ write_msg(int *);
int main(int argc, char *argv[]) {
  int status;
  int fd[2];
  if ((status = pipe(fd)) < 0) {
    fprintf(stderr, "Err.: %d pipe() - %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  write_msg(fd);
  read_msg(fd);
  close(fd[0]);
  close(fd[1]);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <pipe@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11e4 <main+0x74>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    %rax,%rcx
lea    0xe2f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x1c(%rbp),%rdi
call   1060 <write_msg@plt>
lea    -0x1c(%rbp),%rdi
call   1080 <read_msg@plt>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1040 <pipe@plt>
test   %eax,%eax
js     11b3 <main+0x43>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <write_msg@plt>
mov    %rbx,%rdi
call   1080 <read_msg@plt>
mov    (%rsp),%edi
call   1030 <close@plt>
mov    0x4(%rsp),%edi
call   1030 <close@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%ebx
mov    0x2e15(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1090 <strerror@plt>
lea    0xe2d(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Err.: %d pipe() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%9 = call i32 @pipe(i32* %8)
store i32 %9, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%21 = call i32 @write_msg(i32* %20)
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%23 = call i32 @read_msg(i32* %22)
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%25 = load i32, i32* %24
%26 = call i32 @close(i32 %25)
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Err.: %d pipe() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i32 @write_msg(i32* %5)
%17 = call i32 @read_msg(i32* %5)
%18 = load i32, i32* %5
%19 = call i32 @close(i32 %18)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%21 = load i32, i32* %20
%22 = call i32 @close(i32 %21)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}