#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*/ feof(int /*<<< orphan*/);
int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int utf8parse(unsigned char);
int main() {
  char hexc[] = {'0', '1', '2', '3', '4', '5', '6', '7',
                 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  unsigned char buf[256] = {
      0,
  };
  int i, j, len, ret, last;
  while (!feof(stdin)) {
    len = fread(buf, 1, 255, stdin);
    last = 0;
    for (i = 0; i < len; i++) {
      ret = utf8parse(buf[i]);
      if (ret >= 0) {
        printf("0x%04x = ", ret);
        for (j = last; j <= i; j++)
          printf("%c", buf[j]);
        printf(" = ");
        for (j = last; j <= i; j++)
          printf("%c%c ", hexc[buf[j] >> 4], hexc[buf[j] & 0xf]);
        printf("\n");
        last = i + 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ae <main+0x5e>
jmp    133e <main+0x1ee>
lea    -0x120(%rbp),%rdi
mov    0x2e2c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0xff,%edx
call   1040 <fread@plt>
mov    %eax,-0x12c(%rbp)
movl   $0x0,-0x134(%rbp)
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
cmp    -0x12c(%rbp),%eax
jge    1339 <main+0x1e9>
movslq -0x124(%rbp),%rax
movzbl -0x120(%rbp,%rax,1),%edi
ff
call   1030 <utf8parse@plt>
mov    %eax,-0x130(%rbp)
cmpl   $0x0,-0x130(%rbp)
jl     1320 <main+0x1d0>
mov    -0x130(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x134(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jg     1283 <main+0x133>
movslq -0x128(%rbp),%rax
movzbl -0x120(%rbp,%rax,1),%esi
ff
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1240 <main+0xf0>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x134(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jg     1303 <main+0x1b3>
movslq -0x128(%rbp),%rax
movzbl -0x120(%rbp,%rax,1),%eax
ff
sar    $0x4,%eax
cltq
movsbl -0x20(%rbp,%rax,1),%esi
movslq -0x128(%rbp),%rax
movzbl -0x120(%rbp,%rax,1),%eax
ff
and    $0xf,%eax
cltq
movsbl -0x20(%rbp,%rax,1),%edx
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    129d <main+0x14d>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1325 <main+0x1d5>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11e7 <main+0x97>
jmp    118b <main+0x3b>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    0x2e12(%rip),%rbx
mov    (%rbx),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     11f5 <main+0xa5>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe14(%rip),%rbp
lea    0xe17(%rip),%r14
jmp    1222 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2dd1(%rip),%rbx
mov    (%rbx),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    11e1 <main+0x91>
mov    (%rbx),%ecx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0xff,%edx
call   1050 <fread@plt>
test   %eax,%eax
jle    1210 <main+0xc0>
mov    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %ebx,%ebx
mov    $0x1,%r15d
xor    %r12d,%r12d
jmp    125f <main+0x10f>
add    $0x1,%rbx
add    $0x1,%r15d
cmp    0x8(%rsp),%rbx
je     1210 <main+0xc0>
movzbl 0x10(%rsp,%rbx,1),%edi
call   1030 <utf8parse@plt>
test   %eax,%eax
js     1250 <main+0x100>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %r12d,%r13
cmp    %r13,%rbx
mov    %rbx,(%rsp)
jge    12a0 <main+0x150>
lea    0xd8a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%r13
jmp    132a <main+0x1da>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rbx
lea    (%rsp,%r13,1),%r12
add    $0x10,%r12
mov    %r15d,%r14d
sub    %r13d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r12,%rbp,1),%edi
call   1040 <putchar@plt>
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    12c0 <main+0x170>
lea    0xd3c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r13,(%rsp)
lea    0xd14(%rip),%rbp
mov    %rbx,%r13
jl     132a <main+0x1da>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r12,%rbx,1),%eax
mov    %rax,%rcx
shr    $0x4,%rcx
movsbl (%rcx,%rbp,1),%esi
and    $0xf,%eax
movsbl (%rax,%rbp,1),%edx
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r14d
jne    1300 <main+0x1b0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rsp),%rbx
add    $0x1,%rbx
mov    %ebx,%r12d
mov    %r13,%r14
lea    0xcc7(%rip),%rbp
jmp    1254 <main+0x104>

LLVM IR (-O0):
@__const.main.hexc = [16 x i8] c"0123456789abcdef"
@stdin = global i32 0
@.str = [10 x i8] c"0x%04x = \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c" = \00"
@.str.3 = [6 x i8] c"%c%c \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [16 x i8]* %2 to i8*
%10 = bitcast [256 x i8]* %3 to i8*
br label %11
11: ; preds = %90, %0
%12 = load i32, i32* @stdin
%13 = call i32 @feof(i32 %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %91
16: ; preds = %11
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32 @fread(i8* %17, i32 1, i32 255, i32 %18)
store i32 %19, i32* %6
store i32 0, i32* %8
store i32 0, i32* %4
br label %20
20: ; preds = %87, %16
%21 = load i32, i32* %4
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %90
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @utf8parse(i8 zeroext %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %86
32: ; preds = %24
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %8
store i32 %35, i32* %5
br label %36
36: ; preds = %47, %32
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %40
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %36
50: ; preds = %36
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32, i32* %8
store i32 %52, i32* %5
br label %53
53: ; preds = %79, %50
%54 = load i32, i32* %5
%55 = load i32, i32* %4
%56 = icmp sle i32 %54, %55
br i1 %56, label %57, label %82
57: ; preds = %53
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = ashr i32 %62, 4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = and i32 %72, 15
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %67, i32 %77)
br label %79
79: ; preds = %57
%80 = load i32, i32* %5
%81 = add nsw i32 %80, 1
store i32 %81, i32* %5
br label %53
82: ; preds = %53
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%84 = load i32, i32* %4
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %86
86: ; preds = %82, %24
br label %87
87: ; preds = %86
%88 = load i32, i32* %4
%89 = add nsw i32 %88, 1
store i32 %89, i32* %4
br label %20
90: ; preds = %20
br label %11
91: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.hexc = [16 x i8] c"0123456789abcdef"
@stdin = global i32 0
@.str = [10 x i8] c"0x%04x = \00"
@.str.2 = [4 x i8] c" = \00"
@.str.3 = [6 x i8] c"%c%c \00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @feof(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %71
6: ; preds = %66, %10
%7 = load i32, i32* @stdin
%8 = call i32 @feof(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %71
10: ; preds = %0, %6
%11 = load i32, i32* @stdin
%12 = call i32 @fread(i8* %2, i32 1, i32 255, i32 %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %10
%15 = zext i32 %12 to i64
br label %16
16: ; preds = %14, %66
%17 = phi i64 [ 0, %14 ], [ %67, %66 ]
%18 = phi i32 [ 1, %14 ], [ %69, %66 ]
%19 = phi i32 [ 0, %14 ], [ %68, %66 ]
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %17
%21 = load i8, i8* %20
%22 = call i32 @utf8parse(i8 zeroext %21)
%23 = icmp sgt i32 %22, -1
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = add nuw nsw i64 %17, 1
br label %66
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22)
%28 = sext i32 %19 to i64
%29 = icmp slt i64 %17, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %62
32: ; preds = %26, %32
%33 = phi i64 [ %38, %32 ], [ %28, %26 ]
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = call i32 @putchar(i32 %36)
%38 = add nsw i64 %33, 1
%39 = trunc i64 %38 to i32
%40 = icmp eq i32 %18, %39
br i1 %40, label %41, label %32
41: ; preds = %32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br i1 %29, label %62, label %43
43: ; preds = %41, %43
%44 = phi i64 [ %59, %43 ], [ %28, %41 ]
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = lshr i32 %47, 4
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.main.hexc, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = and i32 %47, 15
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.main.hexc, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %52, i32 %57)
%59 = add nsw i64 %44, 1
%60 = trunc i64 %59 to i32
%61 = icmp eq i32 %18, %60
br i1 %61, label %62, label %43
62: ; preds = %43, %30, %41
%63 = call i32 @putchar(i32 10)
%64 = add nuw nsw i64 %17, 1
%65 = trunc i64 %64 to i32
br label %66
66: ; preds = %24, %62
%67 = phi i64 [ %25, %24 ], [ %64, %62 ]
%68 = phi i32 [ %19, %24 ], [ %65, %62 ]
%69 = add nuw i32 %18, 1
%70 = icmp eq i64 %67, %15
br i1 %70, label %6, label %16
71: ; preds = %6, %0
ret i32 0
}