#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*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned char);
int read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int rb(int suppress) {
  unsigned char c;
  if (1 != read(fileno(stdin), &c, 1))
    return -1;
  if (!suppress)
    fprintf(stderr, "%02x", c);
  return c;
}


x86 assembly (clang, -O0):
<rb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
call   1050 <fileno@plt>
mov    %eax,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <read@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1174 <rb+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <rb+0x6e>
cmpl   $0x0,-0x8(%rbp)
jne    1197 <rb+0x67>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1040 <fprintf@plt>
movzbl -0x9(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rb>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
call   1050 <fileno@plt>
lea    0xf(%rsp),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <read@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    118b <rb+0x5b>
test   %ebx,%ebx
je     116c <rb+0x3c>
mov    0xf(%rsp),%bl
jmp    1188 <rb+0x58>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    0xf(%rsp),%bl
movzbl %bl,%edx
lea    0xe7d(%rip),%rsi
call   1040 <fprintf@plt>
movzbl %bl,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @rb(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
%5 = load i32, i32* @stdin
%6 = call i32 @fileno(i32 %5)
%7 = call i32 @read(i32 %6, i8* %4, i32 1)
%8 = icmp ne i32 1, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %20
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = load i8, i8* %4
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
br label %17
17: ; preds = %13, %10
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
store i32 %19, i32* %2
br label %20
20: ; preds = %17, %9
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @rb(i32 %0) {
%2 = alloca i8
%3 = load i32, i32* @stdin
%4 = tail call i32 @fileno(i32 %3)
%5 = call i32 @read(i32 %4, i8* %2, i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = icmp eq i32 %0, 0
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = load i8, i8* %2
br label %15
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = load i8, i8* %2
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %13)
br label %15
15: ; preds = %9, %11
%16 = phi i8 [ %10, %9 ], [ %13, %11 ]
%17 = zext i8 %16 to i32
br label %18
18: ; preds = %1, %15
%19 = phi i32 [ %17, %15 ], [ -1, %1 ]
ret i32 %19
}