#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 getValue(char const);
scalar_t__ strlen(char const *);
int minBase(const char *input) {
  int length = (int)strlen(input);
  int base = -1;
  for (int i = 0; i < length; i++) {
    int value = getValue(input[i]);
    if (value > base) {
      base = value;
    }
  }
  if (base < 2) {
    return 2;
  }
  return base + 1;
}


x86 assembly (clang, -O0):
<minBase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118b <minBase+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <getValue@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1178 <minBase+0x58>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    117d <minBase+0x5d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1146 <minBase+0x26>
cmpl   $0x2,-0x18(%rbp)
jge    11a1 <minBase+0x81>
movl   $0x2,-0x4(%rbp)
jmp    11aa <minBase+0x8a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minBase>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    115d <minBase+0x3d>
mov    %eax,%r15d
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1040 <getValue@plt>
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <minBase+0x20>
cmp    $0x1,%ebp
jg     1164 <minBase+0x44>
mov    $0x2,%ebp
jmp    1167 <minBase+0x47>
add    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @minBase(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %4
store i32 -1, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %28, %1
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @getValue(i8 signext %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = load i32, i32* %5
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = load i32, i32* %7
store i32 %26, i32* %5
br label %27
27: ; preds = %25, %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %11
31: ; preds = %11
%32 = load i32, i32* %5
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 2, i32* %2
br label %38
35: ; preds = %31
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %38
38: ; preds = %35, %34
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
define i32 @minBase(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = and i64 %2, 4294967295
br label %13
7: ; preds = %13
%8 = icmp slt i32 %20, 2
%9 = add nsw i32 %20, 1
br i1 %8, label %10, label %11
10: ; preds = %1, %7
br label %11
11: ; preds = %7, %10
%12 = phi i32 [ 2, %10 ], [ %9, %7 ]
ret i32 %12
13: ; preds = %5, %13
%14 = phi i64 [ 0, %5 ], [ %21, %13 ]
%15 = phi i32 [ -1, %5 ], [ %20, %13 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %14
%17 = load i8, i8* %16
%18 = tail call i32 @getValue(i8 signext %17)
%19 = icmp sgt i32 %18, %15
%20 = select i1 %19, i32 %18, i32 %15
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %6
br i1 %22, label %7, label %13
}