#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 EOF;
int getDigit(int);
int /*<<< orphan*/ putchar(int);
int readChar();
int main() {
  int upper = readChar();
  int lower = readChar();
  while (upper != EOF && lower != EOF) {
    int upperDigit = getDigit(upper);
    int lowerDigit = getDigit(lower);
    putchar((upperDigit << 4) | lowerDigit);
    upper = readChar();
    lower = readChar();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <readChar@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <readChar@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
mov    0x2e89(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x15(%rbp)
je     117c <main+0x4c>
mov    -0xc(%rbp),%eax
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118c <main+0x5c>
jmp    11c9 <main+0x99>
mov    -0x8(%rbp),%edi
call   1040 <getDigit@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <getDigit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
shl    $0x4,%edi
or     -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1050 <readChar@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <readChar@plt>
mov    %eax,-0xc(%rbp)
jmp    1153 <main+0x23>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <readChar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <readChar@plt>
mov    %eax,%ebp
mov    0x2e9b(%rip),%r14
nopl   (%rax)
mov    (%r14),%eax
cmp    %eax,%ebx
je     118b <main+0x5b>
cmp    %eax,%ebp
je     118b <main+0x5b>
mov    %ebx,%edi
call   1040 <getDigit@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <getDigit@plt>
shl    $0x4,%ebx
or     %eax,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <readChar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <readChar@plt>
mov    %eax,%ebp
jmp    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @readChar()
store i32 %6, i32* %2
%7 = call i32 (...) @readChar()
store i32 %7, i32* %3
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %2
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %30
18: ; preds = %16
%19 = load i32, i32* %2
%20 = call i32 @getDigit(i32 %19)
store i32 %20, i32* %4
%21 = load i32, i32* %3
%22 = call i32 @getDigit(i32 %21)
store i32 %22, i32* %5
%23 = load i32, i32* %4
%24 = shl i32 %23, 4
%25 = load i32, i32* %5
%26 = or i32 %24, %25
%27 = call i32 @putchar(i32 %26)
%28 = call i32 (...) @readChar()
store i32 %28, i32* %2
%29 = call i32 (...) @readChar()
store i32 %29, i32* %3
br label %8
30: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @readChar()
%2 = tail call i32 (...) @readChar()
%3 = load i32, i32* @EOF
%4 = icmp ne i32 %1, %3
%5 = icmp ne i32 %2, %3
%6 = select i1 %4, i1 %5, i1 false
br i1 %6, label %7, label %21
7: ; preds = %0, %7
%8 = phi i32 [ %15, %7 ], [ %1, %0 ]
%9 = phi i32 [ %16, %7 ], [ %2, %0 ]
%10 = tail call i32 @getDigit(i32 %8)
%11 = tail call i32 @getDigit(i32 %9)
%12 = shl i32 %10, 4
%13 = or i32 %12, %11
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 (...) @readChar()
%16 = tail call i32 (...) @readChar()
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %15, %17
%19 = icmp ne i32 %16, %17
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %7, label %21
21: ; preds = %7, %0
ret i32 0
}