#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 */
#define EOF 128
int getchar();
int /*<<< orphan*/ putchar(int);
int scanf(char *, char *, char *);
int sscanf(char *, char *, int *);
int main(int argc, char **argv) {
  while (1) {
    int c;
    switch (c = getchar()) {
    case EOF:
      return 0;
    case '_': {
      char hex[3];
      int i;
      i = scanf("%1[0-9A-Fa-f]%1[0-9A-Fa-f]", &hex[0], &hex[1]);
      if (i != 2) {
        return 1;
      }
      i = sscanf(hex, "%2x", &c);
      if (i == EOF || i == 0) {
        return 2;
      }
    }
    default:
      putchar(c);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
sub    $0x5f,%eax
je     1192 <main+0x52>
jmp    1173 <main+0x33>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
jne    1202 <main+0xc2>
jmp    1186 <main+0x46>
movl   $0x0,-0x4(%rbp)
jmp    120f <main+0xcf>
lea    -0x17(%rbp),%rsi
lea    -0x17(%rbp),%rdx
add    $0x1,%rdx
lea    0xe5b(%rip),%rdi
call   1060 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
je     11c3 <main+0x83>
movl   $0x1,-0x4(%rbp)
jmp    120f <main+0xcf>
lea    -0x17(%rbp),%rdi
lea    0xe4d(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x80,-0x1c(%rbp)
je     11f1 <main+0xb1>
cmpl   $0x0,-0x1c(%rbp)
jne    11fd <main+0xbd>
movl   $0x2,-0x4(%rbp)
jmp    120f <main+0xcf>
jmp    1202 <main+0xc2>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1156 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x6(%rsp),%r14
lea    0xea9(%rip),%r15
lea    0x5(%rsp),%rbx
lea    0xeb8(%rip),%r12
mov    %rsp,%r13
xor    %ebp,%ebp
jmp    117e <main+0x3e>
nopw   0x0(%rax,%rax,1)
cmp    $0x80,%eax
je     11c6 <main+0x86>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,(%rsp)
cmp    $0x5f,%eax
jne    1170 <main+0x30>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11ba <main+0x7a>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <sscanf@plt>
test   $0xffffff7f,%eax
je     11c1 <main+0x81>
mov    (%rsp),%eax
jmp    1177 <main+0x37>
mov    $0x1,%ebp
jmp    11c6 <main+0x86>
mov    $0x2,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%1[0-9A-Fa-f]%1[0-9A-Fa-f]\00"
@.str.1 = [4 x i8] c"%2x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [3 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %2, %32
%10 = call i32 (...) @getchar()
store i32 %10, i32* %6
switch i32 %10, label %29 [
i32 128, label %11
i32 95, label %12
]
11: ; preds = %9
store i32 0, i32* %3
br label %33
12: ; preds = %9
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
%15 = call i32 @scanf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 1, i32* %3
br label %33
19: ; preds = %12
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 128
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24, %19
store i32 2, i32* %3
br label %33
28: ; preds = %24
br label %29
29: ; preds = %9, %28
%30 = load i32, i32* %6
%31 = call i32 @putchar(i32 %30)
br label %32
32: ; preds = %29
br label %9
33: ; preds = %27, %18, %11
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [27 x i8] c"%1[0-9A-Fa-f]%1[0-9A-Fa-f]\00"
@.str.1 = [4 x i8] c"%2x\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
br label %8
8: ; preds = %20, %2
%9 = call i32 (...) @getchar()
store i32 %9, i32* %3
switch i32 %9, label %20 [
i32 128, label %23
i32 95, label %10
]
10: ; preds = %8
%11 = call i32 @scanf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%12 = icmp eq i32 %11, 2
br i1 %12, label %14, label %13
13: ; preds = %10
br label %23
14: ; preds = %10
%15 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = and i32 %15, -129
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = load i32, i32* %3
br label %20
20: ; preds = %18, %8
%21 = phi i32 [ %9, %8 ], [ %19, %18 ]
%22 = call i32 @putchar(i32 %21)
br label %8
23: ; preds = %14, %8, %13
%24 = phi i32 [ 1, %13 ], [ 0, %8 ], [ 2, %14 ]
ret i32 %24
}