#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int aton(int);
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int getByte(FILE *in) {
  int ch1, ch2;
  if (feof(in)) {
    printf("eof");
    return -1;
  }
  ch1 = fgetc(in);
  if (feof(in)) {
    printf("eof");
    return -1;
  }
  ch2 = fgetc(in);
  return 16 * aton(ch1) + aton(ch2);
}


x86 assembly (clang, -O0):
<getByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1177 <getByte+0x37>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <getByte+0x9a>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11ae <getByte+0x6e>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <getByte+0x9a>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <aton@plt>
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <aton@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getByte>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <feof@plt>
test   %rax,%rax
jne    1167 <getByte+0x27>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
je     117f <getByte+0x3f>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <aton@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
mov    %ebx,%edi
call   1030 <aton@plt>
add    %ebp,%eax
jmp    1178 <getByte+0x38>

LLVM IR (-O0):
@.str = [4 x i8] c"eof\00"
define i32 @getByte(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i64 @feof(i32* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %28
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = call i32 @fgetc(i32* %12)
store i32 %13, i32* %4
%14 = load i32*, i32** %3
%15 = call i64 @feof(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %28
19: ; preds = %11
%20 = load i32*, i32** %3
%21 = call i32 @fgetc(i32* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %4
%23 = call i32 @aton(i32 %22)
%24 = mul nsw i32 16, %23
%25 = load i32, i32* %5
%26 = call i32 @aton(i32 %25)
%27 = add nsw i32 %24, %26
store i32 %27, i32* %2
br label %28
28: ; preds = %19, %17, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [4 x i8] c"eof\00"
define i32 @getByte(i32* nocapture %0) {
%2 = tail call i64 @feof(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %18
6: ; preds = %1
%7 = tail call i32 @fgetc(i32* %0)
%8 = tail call i64 @feof(i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %18
12: ; preds = %6
%13 = tail call i32 @fgetc(i32* %0)
%14 = tail call i32 @aton(i32 %7)
%15 = shl nsw i32 %14, 4
%16 = tail call i32 @aton(i32 %13)
%17 = add nsw i32 %15, %16
br label %18
18: ; preds = %12, %10, %4
%19 = phi i32 [ -1, %4 ], [ -1, %10 ], [ %17, %12 ]
ret i32 %19
}