#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int get_num_bytes(int);
int /*<<< orphan*/ print_dek(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int utfconvert(int);
int main(void) {
  char inputStr[255];
  char *in = inputStr;
  uint32_t utf8_in;
  int n;
  fgets(in, 255, stdin);
  sscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) {
    while (*in++ != ' ')
      ;
    ;
    sscanf(in, "%X", &utf8_in);
    utf8_in = utfconvert(utf8_in);
    print_dek(utf8_in);
    printf(" 0x%0*X\n", (get_num_bytes(utf8_in) <= 2) ? 4 : 8, utf8_in);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1060 <fgets@plt>
mov    -0x118(%rbp),%rdi
lea    0xe58(%rip),%rsi
lea    -0x120(%rbp),%rdx
call   1070 <sscanf@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
cmp    -0x120(%rbp),%eax
jge    1274 <main+0x114>
jmp    11d5 <main+0x75>
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x118(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11fb <main+0x9b>
jmp    11d5 <main+0x75>
mov    -0x118(%rbp),%rdi
lea    0xdfa(%rip),%rsi
lea    -0x11c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x11c(%rbp),%edi
call   1080 <utfconvert@plt>
mov    %eax,-0x11c(%rbp)
mov    -0x11c(%rbp),%edi
call   1040 <print_dek@plt>
mov    -0x11c(%rbp),%edi
call   1030 <get_num_bytes@plt>
mov    %eax,%ecx
mov    $0x8,%esi
mov    $0x4,%eax
cmp    $0x2,%ecx
cmovle %eax,%esi
mov    -0x11c(%rbp),%edx
lea    0xdab(%rip),%rdi
call   1050 <printf@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11be <main+0x5e>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1060 <fgets@plt>
lea    0xe6f(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <sscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1218 <main+0xb8>
xor    %ebp,%ebp
lea    0xe55(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe4c(%rip),%r12
nopw   0x0(%rax,%rax,1)
cmpb   $0x20,(%rbx)
lea    0x1(%rbx),%rbx
jne    11c0 <main+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <sscanf@plt>
mov    0x8(%rsp),%edi
call   1080 <utfconvert@plt>
mov    %eax,0x8(%rsp)
mov    %eax,%edi
call   1040 <print_dek@plt>
mov    0x8(%rsp),%edi
call   1030 <get_num_bytes@plt>
xor    %ecx,%ecx
cmp    $0x3,%eax
setge  %cl
lea    0x4(,%rcx,4),%esi
mov    0x8(%rsp),%edx
mov    %r12,%rdi
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11c0 <main+0x60>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%X\00"
@.str.2 = [9 x i8] c" 0x%0*X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 255, i32 %9)
%11 = load i8*, i8** %3
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %6
br label %13
13: ; preds = %39, %0
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
br label %18
18: ; preds = %24, %17
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %25
24: ; preds = %18
br label %18
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = call i32 @utfconvert(i32 %28)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = call i32 @print_dek(i32 %30)
%32 = load i32, i32* %4
%33 = call i32 @get_num_bytes(i32 %32)
%34 = icmp sle i32 %33, 2
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 4, i32 8
%37 = load i32, i32* %4
%38 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %37)
br label %39
39: ; preds = %25
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %13
42: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%X\00"
@.str.2 = [9 x i8] c" 0x%0*X\0A\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %4, i32 255, i32 %7)
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0, %21
%13 = phi i32 [ %32, %21 ], [ 0, %0 ]
%14 = phi i8* [ %18, %21 ], [ %4, %0 ]
br label %16
15: ; preds = %21, %0
ret i32 0
16: ; preds = %12, %16
%17 = phi i8* [ %18, %16 ], [ %14, %12 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %17
%20 = icmp eq i8 %19, 32
br i1 %20, label %21, label %16
21: ; preds = %16
%22 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = call i32 @utfconvert(i32 %23)
store i32 %24, i32* %2
%25 = call i32 @print_dek(i32 %24)
%26 = load i32, i32* %2
%27 = call i32 @get_num_bytes(i32 %26)
%28 = icmp slt i32 %27, 3
%29 = select i1 %28, i32 4, i32 8
%30 = load i32, i32* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
%32 = add nuw nsw i32 %13, 1
%33 = load i32, i32* %3
%34 = icmp slt i32 %32, %33
br i1 %34, label %12, label %15
}