#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 convertCharToNumber(char);
int getStringLength(char *);
int convertCharNumberToInt(char *number) {
  int i;
  int place = 1;
  int sum = 0;
  for (i = getStringLength(number) - 1; number[i]; i--) {
    int temp = convertCharToNumber(number[i]);
    sum = sum + (temp * place);
    place = place * 10;
  }
  return sum;
}


x86 assembly (clang, -O0):
<convertCharNumberToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getStringLength@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1193 <convertCharNumberToInt+0x73>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <convertCharToNumber@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <convertCharNumberToInt+0x29>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertCharNumberToInt>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <getStringLength@plt>
movslq %eax,%rcx
mov    -0x1(%rbx,%rcx,1),%al
test   %al,%al
je     1171 <convertCharNumberToInt+0x51>
add    $0xffffffffffffffff,%rcx
add    %rcx,%rbx
add    $0xffffffffffffffff,%rbx
mov    $0x1,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <convertCharToNumber@plt>
imul   %ebp,%eax
add    %eax,%r14d
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
movzbl (%rbx),%eax
add    $0xffffffffffffffff,%rbx
test   %al,%al
jne    1150 <convertCharNumberToInt+0x30>
jmp    1174 <convertCharNumberToInt+0x54>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @convertCharNumberToInt(i8* %0) {
%2 = tail call i32 @getStringLength(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %1, %8
%9 = phi i64 [ %17, %8 ], [ %4, %1 ]
%10 = phi i8 [ %19, %8 ], [ %6, %1 ]
%11 = phi i32 [ %15, %8 ], [ 0, %1 ]
%12 = phi i32 [ %16, %8 ], [ 1, %1 ]
%13 = tail call i32 @convertCharToNumber(i8 signext %10)
%14 = mul nsw i32 %13, %12
%15 = add nsw i32 %14, %11
%16 = mul nsw i32 %12, 10
%17 = add i64 %9, -1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %8, %1
%22 = phi i32 [ 0, %1 ], [ %15, %8 ]
ret i32 %22
}