#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 hex(char);
int power(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char **);
int strlen(char *);
int main() {
  char arr[50], N, k;
  int ij, i, a, b = 0, c;
  scanf("%s", &arr);
  k = strlen(arr);
  for (ij = 0; ij < strlen(arr) / 2; ij++) {
    N = arr[ij];
    arr[ij] = arr[strlen(arr) - 1 - ij];
    arr[strlen(arr) - 1 - ij] = N;
  }
  for (a = 0; a < k; a++) {
    b = b + hex(arr[a]) * power(16, a);
  }
  printf("%d", b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x54(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %al,-0x42(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jge    1201 <main+0xb1>
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x41(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
sub    -0x48(%rbp),%eax
cltq
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x48(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x41(%rbp),%al
mov    %al,-0x5d(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5d(%rbp),%cl
sub    $0x1,%eax
sub    -0x48(%rbp),%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1189 <main+0x39>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
movsbl -0x42(%rbp),%ecx
cmp    %ecx,%eax
jge    1259 <main+0x109>
mov    -0x54(%rbp),%eax
mov    %eax,-0x64(%rbp)
movslq -0x50(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%edi
call   1070 <hex@plt>
mov    %eax,-0x68(%rbp)
mov    -0x50(%rbp),%esi
mov    $0x10,%edi
call   1030 <power@plt>
mov    -0x68(%rbp),%ecx
mov    %eax,%edx
mov    -0x64(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1208 <main+0xb8>
mov    -0x54(%rbp),%esi
lea    0xda0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xe9d(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11d8 <main+0x88>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
mov    %rsp,%r15
movzbl (%rsp,%rbx,1),%r12d
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cltq
movzbl (%rsp,%rax,1),%eax
mov    %al,(%rsp,%rbx,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cltq
mov    %r12b,(%rsp,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1190 <main+0x40>
test   %r14b,%r14b
jle    1229 <main+0xd9>
movzbl %r14b,%eax
cmp    $0x2,%eax
mov    $0x1,%r15d
cmovge %eax,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rsp,%rbp,1),%edi
call   1070 <hex@plt>
mov    %eax,%r14d
mov    $0x10,%edi
mov    %ebp,%esi
call   1030 <power@plt>
imul   %r14d,%eax
add    %eax,%ebx
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <main+0xb0>
jmp    122b <main+0xdb>
xor    %ebx,%ebx
lea    0xdd1(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%10 = bitcast [50 x i8]* %2 to i8**
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = trunc i32 %13 to i8
store i8 %14, i8* %4
store i32 0, i32* %5
br label %15
15: ; preds = %45, %0
%16 = load i32, i32* %5
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = sdiv i32 %18, 2
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %48
21: ; preds = %15
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
store i8 %25, i8* %3
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %5
%30 = sub nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %35
store i8 %33, i8* %36
%37 = load i8, i8* %3
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %5
%42 = sub nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %43
store i8 %37, i8* %44
br label %45
45: ; preds = %21
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %15
48: ; preds = %15
store i32 0, i32* %7
br label %49
49: ; preds = %65, %48
%50 = load i32, i32* %7
%51 = load i8, i8* %4
%52 = sext i8 %51 to i32
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %68
54: ; preds = %49
%55 = load i32, i32* %8
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @hex(i8 signext %59)
%61 = load i32, i32* %7
%62 = call i32 @power(i32 16, i32 %61)
%63 = mul nsw i32 %60, %62
%64 = add nsw i32 %55, %63
store i32 %64, i32* %8
br label %65
65: ; preds = %54
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %49
68: ; preds = %49
%69 = load i32, i32* %8
%70 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = bitcast [50 x i8]* %1 to i8**
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%5 = call i32 @strlen(i8* %2)
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %15, label %8
8: ; preds = %15, %0
%9 = trunc i32 %5 to i8
%10 = icmp sgt i8 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %8
%12 = and i32 %5, 255
%13 = call i32 @llvm.smax.i32(i32 %12, i32 1)
%14 = zext i32 %13 to i64
br label %35
15: ; preds = %0, %15
%16 = phi i64 [ %30, %15 ], [ 0, %0 ]
%17 = trunc i64 %16 to i32
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = call i32 @strlen(i8* %2)
%21 = xor i32 %17, -1
%22 = add i32 %20, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
store i8 %25, i8* %18
%26 = call i32 @strlen(i8* %2)
%27 = add i32 %26, %21
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %28
store i8 %19, i8* %29
%30 = add nuw nsw i64 %16, 1
%31 = call i32 @strlen(i8* %2)
%32 = sdiv i32 %31, 2
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %30, %33
br i1 %34, label %15, label %8
35: ; preds = %11, %35
%36 = phi i64 [ 0, %11 ], [ %45, %35 ]
%37 = phi i32 [ 0, %11 ], [ %44, %35 ]
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %36
%39 = load i8, i8* %38
%40 = call i32 @hex(i8 signext %39)
%41 = trunc i64 %36 to i32
%42 = call i32 @power(i32 16, i32 %41)
%43 = mul nsw i32 %42, %40
%44 = add nsw i32 %43, %37
%45 = add nuw nsw i64 %36, 1
%46 = icmp eq i64 %45, %14
br i1 %46, label %47, label %35
47: ; preds = %35, %8
%48 = phi i32 [ 0, %8 ], [ %44, %35 ]
%49 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
ret i32 0
}