#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 my_strlen(char *);
int whereIsIt(char, char *);
int my_getnbr_base(char *str, char *base) {
  int number;
  int object;
  int i;
  number = 0;
  object = 1;
  if (str[0] == '-')
    return (-my_getnbr_base(&str[1], base));
  for (i = my_strlen(str) - 1; i >= 0; i--) {
    number = number + whereIsIt(str[i], base) * object;
    object *= my_strlen(base);
  }
  return (number);
}


x86 assembly (clang, -O0):
<my_getnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    117d <my_getnbr_base+0x4d>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <my_getnbr_base@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11e5 <my_getnbr_base+0xb5>
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11df <my_getnbr_base+0xaf>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <whereIsIt@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   -0x20(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <my_strlen@plt>
imul   -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    118c <my_getnbr_base+0x5c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_getnbr_base>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
cmpb   $0x2d,(%rdi)
jne    115a <my_getnbr_base+0x2a>
add    $0x1,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <my_getnbr_base@plt>
mov    %eax,%r12d
neg    %r12d
jmp    11b0 <my_getnbr_base+0x80>
mov    %r14,%rdi
call   1030 <my_strlen@plt>
test   %eax,%eax
jle    11ad <my_getnbr_base+0x7d>
mov    %eax,%ebx
add    $0x1,%rbx
xor    %r12d,%r12d
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x2(%rbx),%eax
movsbl (%r14,%rax,1),%edi
mov    %r15,%rsi
call   1050 <whereIsIt@plt>
imul   %ebp,%eax
add    %eax,%r12d
mov    %r15,%rdi
call   1030 <my_strlen@plt>
imul   %eax,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1180 <my_getnbr_base+0x50>
jmp    11b0 <my_getnbr_base+0x80>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_getnbr_base(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i32 1, i32* %7
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %5
%18 = call i32 @my_getnbr_base(i8* %16, i8* %17)
%19 = sub nsw i32 0, %18
store i32 %19, i32* %3
br label %48
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = call i32 @my_strlen(i8* %21)
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %8
br label %24
24: ; preds = %43, %20
%25 = load i32, i32* %8
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %46
27: ; preds = %24
%28 = load i32, i32* %6
%29 = load i8*, i8** %4
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %5
%35 = call i32 @whereIsIt(i8 signext %33, i8* %34)
%36 = load i32, i32* %7
%37 = mul nsw i32 %35, %36
%38 = add nsw i32 %28, %37
store i32 %38, i32* %6
%39 = load i8*, i8** %5
%40 = call i32 @my_strlen(i8* %39)
%41 = load i32, i32* %7
%42 = mul nsw i32 %41, %40
store i32 %42, i32* %7
br label %43
43: ; preds = %27
%44 = load i32, i32* %8
%45 = add nsw i32 %44, -1
store i32 %45, i32* %8
br label %24
46: ; preds = %24
%47 = load i32, i32* %6
store i32 %47, i32* %3
br label %48
48: ; preds = %46, %14
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @my_getnbr_base(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
br i1 %4, label %7, label %11
5: ; preds = %16, %11, %7
%6 = phi i32 [ %10, %7 ], [ 0, %11 ], [ %26, %16 ]
ret i32 %6
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = tail call i32 @my_getnbr_base(i8* %8, i8* %1)
%10 = sub nsw i32 0, %9
br label %5
11: ; preds = %2
%12 = tail call i32 @my_strlen(i8* %0)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %11
%15 = zext i32 %12 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ %15, %14 ], [ %20, %16 ]
%18 = phi i32 [ 1, %14 ], [ %28, %16 ]
%19 = phi i32 [ 0, %14 ], [ %26, %16 ]
%20 = add nsw i64 %17, -1
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = tail call i32 @whereIsIt(i8 signext %23, i8* %1)
%25 = mul nsw i32 %24, %18
%26 = add nsw i32 %25, %19
%27 = tail call i32 @my_strlen(i8* %1)
%28 = mul nsw i32 %27, %18
%29 = icmp ugt i64 %17, 1
br i1 %29, label %16, label %5
}