#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*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ read(int /*<<< orphan*/, char *, int);
int main() {
  char buff[5];
  int rc = 0;
  if (read(STDIN_FILENO, buff, 5) < 0)
    rc |= 1;
  if (read(STDOUT_FILENO, buff, 5) < 0)
    rc |= 2;
  if (read(STDERR_FILENO, buff, 5) < 0)
    rc |= 4;
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
lea    -0x9(%rbp),%rsi
mov    $0x5,%edx
call   1030 <read@plt>
cmp    $0x0,%rax
jge    1150 <main+0x40>
mov    -0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x9(%rbp),%rsi
mov    $0x5,%edx
call   1030 <read@plt>
cmp    $0x0,%rax
jge    117a <main+0x6a>
mov    -0x10(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    -0x9(%rbp),%rsi
mov    $0x5,%edx
call   1030 <read@plt>
cmp    $0x0,%rax
jge    11a4 <main+0x94>
mov    -0x10(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0xb(%rsp),%r14
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <read@plt>
mov    %rax,%rbx
shr    $0x3f,%rbx
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <read@plt>
lea    0x2(%rbx),%r15d
test   %rax,%rax
cmovns %ebx,%r15d
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <read@plt>
lea    0x4(%r15),%ecx
test   %rax,%rax
cmovns %r15d,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = load i32, i32* @STDIN_FILENO
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = call i64 @read(i32 %4, i8* %5, i32 5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %3
%10 = or i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* @STDOUT_FILENO
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%14 = call i64 @read(i32 %12, i8* %13, i32 5)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %3
%18 = or i32 %17, 2
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* @STDERR_FILENO
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%22 = call i64 @read(i32 %20, i8* %21, i32 5)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %3
%26 = or i32 %25, 4
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %19
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @STDIN_FILENO
%4 = call i64 @read(i32 %3, i8* %2, i32 5)
%5 = lshr i64 %4, 63
%6 = trunc i64 %5 to i32
%7 = load i32, i32* @STDOUT_FILENO
%8 = call i64 @read(i32 %7, i8* %2, i32 5)
%9 = icmp slt i64 %8, 0
%10 = or i32 %6, 2
%11 = select i1 %9, i32 %10, i32 %6
%12 = load i32, i32* @STDERR_FILENO
%13 = call i64 @read(i32 %12, i8* %2, i32 5)
%14 = icmp slt i64 %13, 0
%15 = or i32 %11, 4
%16 = select i1 %14, i32 %15, i32 %11
ret i32 %16
}