#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*/ isdigit(char);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int enter_base(char *base_str, int *base) {
  int i;
  scanf("%s", base_str);
  for (i = 0; i < strlen(base_str); i++) {
    if (!isdigit(base_str[i])) {
      return 0;
    }
  }
  *(base) = atoi(base_str);
  if (*(base) == 0 || *(base) >= 37) {
    return 0;
  }
  return *(base);
}


x86 assembly (clang, -O0):
<enter_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11bc <enter_base+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a9 <enter_base+0x69>
movl   $0x0,-0x4(%rbp)
jmp    11fc <enter_base+0xbc>
jmp    11ae <enter_base+0x6e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <enter_base+0x27>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11e7 <enter_base+0xa7>
mov    -0x18(%rbp),%rax
cmpl   $0x25,(%rax)
jl     11f3 <enter_base+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    11fc <enter_base+0xbc>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enter_base>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeab(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1191 <enter_base+0x51>
xor    %r15d,%r15d
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl (%r12,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11ac <enter_base+0x6c>
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1170 <enter_base+0x30>
mov    %r12,%rdi
call   1060 <atoi@plt>
xor    %r15d,%r15d
cmp    $0x25,%eax
cmovl  %eax,%r15d
mov    %eax,(%r14)
test   %eax,%eax
cmove  %eax,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @enter_base(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 0, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @isdigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %14
store i32 0, i32* %3
br label %42
23: ; preds = %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
%28 = load i8*, i8** %4
%29 = call i32 @atoi(i8* %28)
%30 = load i32*, i32** %5
store i32 %29, i32* %30
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %27
%35 = load i32*, i32** %5
%36 = load i32, i32* %35
%37 = icmp sge i32 %36, 37
br i1 %37, label %38, label %39
38: ; preds = %34, %27
store i32 0, i32* %3
br label %42
39: ; preds = %34
%40 = load i32*, i32** %5
%41 = load i32, i32* %40
store i32 %41, i32* %3
br label %42
42: ; preds = %39, %38, %22
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @enter_base(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %10, label %17
6: ; preds = %10
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = icmp slt i64 %16, %8
br i1 %9, label %10, label %17
10: ; preds = %2, %6
%11 = phi i64 [ %16, %6 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @isdigit(i8 signext %13)
%15 = icmp eq i32 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %23, label %6
17: ; preds = %6, %2
%18 = tail call i32 @atoi(i8* %0)
store i32 %18, i32* %1
%19 = icmp eq i32 %18, 0
%20 = icmp sgt i32 %18, 36
%21 = or i1 %19, %20
%22 = select i1 %21, i32 0, i32 %18
br label %23
23: ; preds = %10, %17
%24 = phi i32 [ %22, %17 ], [ 0, %10 ]
ret i32 %24
}