#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int main() {
  int n;
  char a[10000];
  while (scanf("%s", a) == 1) {
    n = atoi(a);
    if (n < 0)
      break;
    if (a[1] == 'x') {
      sscanf(a, "%X", &n);
      printf("%d\n", n);
    } else
      printf("0x%X\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2720,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2720(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11db <main+0x9b>
lea    -0x2720(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    118c <main+0x4c>
jmp    11db <main+0x9b>
movsbl -0x271f(%rbp),%eax
cmp    $0x78,%eax
jne    11c7 <main+0x87>
lea    -0x2720(%rbp),%rdi
lea    0xe59(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
jmp    11d6 <main+0x96>
mov    -0x8(%rbp),%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2728,%rsp
lea    0xea8(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11d8 <main+0x98>
lea    0x10(%rsp),%rbx
lea    0xe90(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe87(%rip),%r12
lea    0xe7a(%rip),%r13
lea    0xe7d(%rip),%rbp
jmp    11aa <main+0x6a>
nop
mov    %rbp,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11d8 <main+0x98>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     11d8 <main+0x98>
cmpb   $0x78,0x11(%rsp)
jne    1190 <main+0x50>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
jmp    1195 <main+0x55>
xor    %eax,%eax
add    $0x2728,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%X\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"0x%X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10000 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %27, %0
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%10 = call i32 @atoi(i8* %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
br label %28
14: ; preds = %8
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 120
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %27
24: ; preds = %14
%25 = load i32, i32* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %19
br label %4
28: ; preds = %13, %4
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%X\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"0x%X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10000 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %24
7: ; preds = %0
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 1
br label %9
9: ; preds = %7, %21
%10 = call i32 @atoi(i8* %4)
store i32 %10, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = load i8, i8* %8
%14 = icmp eq i8 %13, 120
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %21
21: ; preds = %19, %15
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%23 = icmp eq i32 %22, 1
br i1 %23, label %9, label %24
24: ; preds = %21, %9, %0
ret i32 0
}