#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 a_to_i(char *, int);
int /*<<< orphan*/ check_int(int, int);
void test_a_to_i() {
  int result, expected_result;
  result = a_to_i("7", 2);
  expected_result = 7;
  check_int(result, expected_result);
  result = a_to_i("4211", 5);
  expected_result = 4211;
  check_int(result, expected_result);
  result = a_to_i(" -2 ", 5);
  expected_result = -2;
  check_int(result, expected_result);
}


x86 assembly (clang, -O0):
<test_a_to_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x2,%esi
call   1040 <a_to_i@plt>
mov    %eax,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <check_int@plt>
lea    0xead(%rip),%rdi
mov    $0x5,%esi
call   1040 <a_to_i@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1073,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <check_int@plt>
lea    0xe8c(%rip),%rdi
mov    $0x5,%esi
call   1040 <a_to_i@plt>
mov    %eax,-0x4(%rbp)
movl   $0xfffffffe,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <check_int@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_a_to_i>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x2,%esi
call   1040 <a_to_i@plt>
mov    %eax,%edi
mov    $0x7,%esi
call   1030 <check_int@plt>
lea    0xebd(%rip),%rdi
mov    $0x5,%esi
call   1040 <a_to_i@plt>
mov    %eax,%edi
mov    $0x1073,%esi
call   1030 <check_int@plt>
lea    0xea5(%rip),%rdi
mov    $0x5,%esi
call   1040 <a_to_i@plt>
mov    %eax,%edi
mov    $0xfffffffe,%esi
pop    %rax
jmp    1030 <check_int@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"7\00"
@.str.1 = [5 x i8] c"4211\00"
@.str.2 = [5 x i8] c" -2 \00"
define void @test_a_to_i() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @a_to_i(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
store i32 %3, i32* %1
store i32 7, i32* %2
%4 = load i32, i32* %1
%5 = load i32, i32* %2
%6 = call i32 @check_int(i32 %4, i32 %5)
%7 = call i32 @a_to_i(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5)
store i32 %7, i32* %1
store i32 4211, i32* %2
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 @check_int(i32 %8, i32 %9)
%11 = call i32 @a_to_i(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5)
store i32 %11, i32* %1
store i32 -2, i32* %2
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @check_int(i32 %12, i32 %13)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"7\00"
@.str.1 = [5 x i8] c"4211\00"
@.str.2 = [5 x i8] c" -2 \00"
define void @test_a_to_i() {
%1 = tail call i32 @a_to_i(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = tail call i32 @check_int(i32 %1, i32 7)
%3 = tail call i32 @a_to_i(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5)
%4 = tail call i32 @check_int(i32 %3, i32 4211)
%5 = tail call i32 @a_to_i(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5)
%6 = tail call i32 @check_int(i32 %5, i32 -2)
ret void
}