#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 getnbr(char *, int, char *);
int test_base(char *, char *);
scalar_t__ test_str(char *, char *);
int my_getnbr_base(char *str, char *base) {
  int result;
  int nbase;
  int i;
  char hsh[128] = {0};
  i = 0;
  if (!*base || !*str)
    result = 0;
  else if ((!(nbase = test_base(base, hsh))))
    result = 0;
  else if (test_str(str, hsh))
    result = 0;
  else
    result = getnbr(str, nbase, hsh);
  return (result);
}


x86 assembly (clang, -O0):
<my_getnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1187 <my_getnbr_base+0x47>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1193 <my_getnbr_base+0x53>
movl   $0x0,-0x14(%rbp)
jmp    1201 <my_getnbr_base+0xc1>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <test_base@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    11bb <my_getnbr_base+0x7b>
movl   $0x0,-0x14(%rbp)
jmp    11fc <my_getnbr_base+0xbc>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <test_str@plt>
cmp    $0x0,%rax
je     11e1 <my_getnbr_base+0xa1>
movl   $0x0,-0x14(%rbp)
jmp    11f7 <my_getnbr_base+0xb7>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0xa0(%rbp),%rdx
call   1040 <getnbr@plt>
mov    %eax,-0x14(%rbp)
jmp    11fc <my_getnbr_base+0xbc>
jmp    1201 <my_getnbr_base+0xc1>
mov    -0x14(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_getnbr_base>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %ebp,%ebp
cmpb   $0x0,(%rsi)
je     11a9 <my_getnbr_base+0x79>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11a9 <my_getnbr_base+0x79>
mov    %rsp,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1050 <test_base@plt>
test   %eax,%eax
je     11a9 <my_getnbr_base+0x79>
mov    %eax,%r14d
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <test_str@plt>
test   %rax,%rax
jne    11a9 <my_getnbr_base+0x79>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <getnbr@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_getnbr_base(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [128 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = bitcast [128 x i8]* %8 to i8*
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13, %2
store i32 0, i32* %5
br label %37
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%21 = call i32 @test_base(i8* %19, i8* %20)
store i32 %21, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18
store i32 0, i32* %5
br label %36
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%27 = call i64 @test_str(i8* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %5
br label %35
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = load i32, i32* %6
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%34 = call i32 @getnbr(i8* %31, i32 %32, i8* %33)
store i32 %34, i32* %5
br label %35
35: ; preds = %30, %29
br label %36
36: ; preds = %35, %23
br label %37
37: ; preds = %36, %17
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @my_getnbr_base(i8* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = call i32 @test_base(i8* %1, i8* %4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = call i64 @test_str(i8* %0, i8* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @getnbr(i8* %0, i32 %11, i8* %4)
br label %18
18: ; preds = %13, %10, %2, %7, %16
%19 = phi i32 [ %17, %16 ], [ 0, %7 ], [ 0, %2 ], [ 0, %10 ], [ 0, %13 ]
ret i32 %19
}