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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0x50(%rbp),%eax
cmp    $0x2d,%eax
je     11c6 <main+0x96>
movsbl -0x50(%rbp),%eax
cmp    $0x30,%eax
jne    119e <main+0x6e>
movsbl -0x4f(%rbp),%eax
cmp    $0x78,%eax
jne    119e <main+0x6e>
lea    -0x50(%rbp),%rdi
lea    0xe83(%rip),%rsi
lea    -0x54(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x54(%rbp),%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0x91>
lea    -0x50(%rbp),%rdi
lea    0xe62(%rip),%rsi
lea    -0x54(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x54(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xebb(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%al
cmp    $0x2d,%al
jne    1168 <main+0x38>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
lea    0xe8e(%rip),%r12
lea    0xe80(%rip),%r13
lea    0xe84(%rip),%rbp
lea    0xe80(%rip),%r14
jmp    11be <main+0x8e>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0x10(%rsp),%eax
cmp    $0x2d,%al
je     1157 <main+0x27>
cmp    $0x30,%al
jne    1190 <main+0x60>
cmpb   $0x78,0x11(%rsp)
jne    1190 <main+0x60>
mov    %rbx,%rdi
lea    0xe31(%rip),%rsi
mov    %r15,%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
jmp    11a5 <main+0x75>

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

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