#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 errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ write(int, char *, int);
char passThrough(int from, int to) {
  char buffer[256];
  int n = read(from, buffer, 256);
  if (n < 0) {
    fprintf(stderr, "err: %s (%i)\n", strerror(errno), errno);
    exit(1);
  } else if (n == 0)
    return 1;
  write(to, buffer, n);
  return 0;
}


x86 assembly (clang, -O0):
<passThrough>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1040 <read@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jge    11cd <passThrough+0x7d>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x118(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x118(%rbp),%edi
mov    %rax,%rdx
mov    0x2e23(%rip),%rax
mov    (%rax),%ecx
lea    0xe42(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x0,-0x114(%rbp)
jne    11e3 <passThrough+0x93>
movb   $0x1,-0x1(%rbp)
jmp    1201 <passThrough+0xb1>
jmp    11e8 <passThrough+0x98>
mov    -0xc(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x114(%rbp),%edx
call   1030 <write@plt>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passThrough>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ebx
mov    %rsp,%rsi
mov    $0x100,%edx
call   1040 <read@plt>
test   %eax,%eax
js     118c <passThrough+0x3c>
je     117f <passThrough+0x2f>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
jmp    1181 <passThrough+0x31>
mov    $0x1,%al
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e4d(%rip),%rax
mov    (%rax),%ebx
mov    0x2e3c(%rip),%r14
mov    (%r14),%edi
call   1070 <strerror@plt>
mov    (%r14),%ecx
lea    0xe52(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"err: %s (%i)\0A\00"
@errno = global i32 0
define signext i8 @passThrough(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @read(i32 %0, i8* %4, i32 256)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = load i32, i32* @errno
%12 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp eq i32 %5, 0
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = call i32 @write(i32 %1, i8* %4, i32 %5)
br label %18
18: ; preds = %14, %16
%19 = phi i8 [ 0, %16 ], [ 1, %14 ]
ret i8 %19
}