#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*/ fflush(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(unsigned int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(void) {
  unsigned int c;
  char linebuf[256];
  char *linebufptr;
  linebuf[0] = '\0';
  while (1) {
    linebufptr = fgets(linebuf, 256, stdin);
    if (linebufptr == NULL)
      break;
    c = (unsigned char)strtol(linebuf, NULL, 16);
    putchar(c);
    fflush(stdout);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x110(%rbp)
lea    -0x110(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    118d <main+0x4d>
jmp    11c3 <main+0x83>
lea    -0x110(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
movb   $0x0,(%rsp)
mov    0x2e91(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11b4 <main+0x74>
mov    %rsp,%rbx
mov    0x2e62(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
movzbl %al,%edi
call   1030 <putchar@plt>
mov    (%r15),%edi
call   1060 <fflush@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8 0, i8* %5
br label %6
6: ; preds = %0, %13
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i8* @fgets(i8* %7, i32 256, i32 %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %6
br label %22
13: ; preds = %6
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = call i64 @strtol(i8* %14, i32* null, i32 16)
%16 = trunc i64 %15 to i8
%17 = zext i8 %16 to i32
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i32 @putchar(i32 %18)
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
br label %6
22: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%3 = load i32, i32* @stdin
%4 = call i8* @fgets(i8* %2, i32 256, i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %0, %6
%7 = call i64 @strtol(i8* nocapture %2, i32* null, i32 16)
%8 = trunc i64 %7 to i32
%9 = and i32 %8, 255
%10 = call i32 @putchar(i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
%13 = load i32, i32* @stdin
%14 = call i8* @fgets(i8* %2, i32 256, i32 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %6
16: ; preds = %6, %0
ret i32 0
}