#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*/ getchar();
int hex2dec(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
void main(void) {
  unsigned N;
  scanf("%u", &N);
  getchar();
  char sHex[79] = {'\0'};
  for (; N != 0; --N) {
    scanf("0x%s", sHex);
    getchar();
    printf("%u\n", hex2dec(sHex));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x4f,%edx
call   1050 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
je     11c9 <main+0x79>
lea    -0x60(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x60(%rbp),%rdi
call   1030 <hex2dec@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <main+0x31>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xeb0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x4f(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
je     11cd <main+0x8d>
lea    0xe76(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe6f(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbx,%rdi
call   1030 <hex2dec@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
jne    11a0 <main+0x60>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [5 x i8] c"0x%s\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [79 x i8]
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i32 (...) @getchar()
%5 = bitcast [79 x i8]* %2 to i8*
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %1
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = getelementptr inbounds [79 x i8], [79 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (...) @getchar()
%13 = getelementptr inbounds [79 x i8], [79 x i8]* %2, i64 0, i64 0
%14 = call i32 @hex2dec(i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %9
%17 = load i32, i32* %1
%18 = add i32 %17, -1
store i32 %18, i32* %1
br label %6
19: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [5 x i8] c"0x%s\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [79 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @getchar()
%6 = getelementptr inbounds [79 x i8], [79 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = call i32 (...) @getchar()
%12 = call i32 @hex2dec(i8* %6)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = add i32 %14, -1
store i32 %15, i32* %1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %0
ret void
}