#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 resolve(char leftc, char currentc, char rightc) {
  char left[2];
  char current[2];
  char right[2];
  int index;
  left[0] = leftc;
  current[0] = currentc;
  right[0] = rightc;
  left[1] = current[1] = right[1] = '\0';
  index = 4 * atoi(left) + 2 * atoi(current) + atoi(right);
  return index;
}


x86 assembly (clang, -O0):
<resolve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %dil,%dl
mov    %dl,-0x1(%rbp)
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    -0x1(%rbp),%al
mov    %al,-0x5(%rbp)
mov    -0x2(%rbp),%al
mov    %al,-0x7(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x9(%rbp)
movb   $0x0,-0x8(%rbp)
movb   $0x0,-0x6(%rbp)
movb   $0x0,-0x4(%rbp)
lea    -0x5(%rbp),%rdi
call   1030 <atoi@plt>
shl    $0x2,%eax
mov    %eax,-0x18(%rbp)
lea    -0x7(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
lea    -0x9(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resolve>:
push   %rbx
sub    $0x10,%rsp
mov    %dil,0xe(%rsp)
mov    %sil,0xc(%rsp)
mov    %dl,0xa(%rsp)
movb   $0x0,0xb(%rsp)
movb   $0x0,0xd(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xe(%rsp),%rdi
call   1030 <atoi@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
lea    0xc(%rsp),%rdi
call   1030 <atoi@plt>
lea    (%rbx,%rax,2),%ebx
lea    0xa(%rsp),%rdi
call   1030 <atoi@plt>
add    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @resolve(i8 signext %0, i8 signext %1, i8 signext %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca [2 x i8]
%8 = alloca [2 x i8]
%9 = alloca [2 x i8]
%10 = alloca i32
store i8 %0, i8* %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%11 = load i8, i8* %4
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i8, i8* %5
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 %13, i8* %14
%15 = load i8, i8* %6
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
store i8 %15, i8* %16
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 1
store i8 0, i8* %17
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 1
store i8 0, i8* %18
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
store i8 0, i8* %19
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
%22 = mul nsw i32 4, %21
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
%25 = mul nsw i32 2, %24
%26 = add nsw i32 %22, %25
%27 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%28 = call i32 @atoi(i8* %27)
%29 = add nsw i32 %26, %28
store i32 %29, i32* %10
%30 = load i32, i32* %10
ret i32 %30
}

LLVM IR (-O2):
define i32 @resolve(i8 signext %0, i8 signext %1, i8 signext %2) {
%4 = alloca [2 x i8]
%5 = alloca [2 x i8]
%6 = alloca [2 x i8]
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
store i8 0, i8* %10
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 0, i8* %11
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %7)
%14 = shl nsw i32 %13, 2
%15 = call i32 @atoi(i8* %8)
%16 = shl nsw i32 %15, 1
%17 = add nsw i32 %16, %14
%18 = call i32 @atoi(i8* %9)
%19 = add nsw i32 %17, %18
ret i32 %19
}