#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 /*<<< orphan*/ test_int_to_str(int, int);
int /*<<< orphan*/ test_str_to_int(char *, int);
int main(void) {
  test_str_to_int("1024", 10);
  test_str_to_int("-1024", 10);
  test_str_to_int("FF", 16);
  test_str_to_int("-ff", 16);
  test_str_to_int("0", 2);
  test_str_to_int("123a", 10);
  test_str_to_int("1012", 2);
  test_int_to_str(1024, 10);
  test_int_to_str(-1024, 10);
  test_int_to_str(5, 2);
  test_int_to_str(-5, 2);
  test_int_to_str(48879, 16);
  test_int_to_str(-48879, 16);
  test_int_to_str(1023, 2);
  test_int_to_str(1024, 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecb(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xeb9(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xeae(%rip),%rdi
mov    $0x10,%esi
call   1030 <test_str_to_int@plt>
lea    0xea0(%rip),%rdi
mov    $0x10,%esi
call   1030 <test_str_to_int@plt>
lea    0xe93(%rip),%rdi
mov    $0x2,%esi
call   1030 <test_str_to_int@plt>
lea    0xe84(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xe78(%rip),%rdi
mov    $0x2,%esi
call   1030 <test_str_to_int@plt>
mov    $0x400,%edi
mov    $0xa,%esi
call   1040 <test_int_to_str@plt>
mov    $0xfffffc00,%edi
mov    $0xa,%esi
call   1040 <test_int_to_str@plt>
mov    $0x5,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0xfffffffb,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0xbeef,%edi
mov    $0x10,%esi
call   1040 <test_int_to_str@plt>
mov    $0xffff4111,%edi
mov    $0x10,%esi
call   1040 <test_int_to_str@plt>
mov    $0x3ff,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0x400,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed9(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xec7(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xebc(%rip),%rdi
mov    $0x10,%esi
call   1030 <test_str_to_int@plt>
lea    0xeae(%rip),%rdi
mov    $0x10,%esi
call   1030 <test_str_to_int@plt>
lea    0xea1(%rip),%rdi
mov    $0x2,%esi
call   1030 <test_str_to_int@plt>
lea    0xe92(%rip),%rdi
mov    $0xa,%esi
call   1030 <test_str_to_int@plt>
lea    0xe86(%rip),%rdi
mov    $0x2,%esi
call   1030 <test_str_to_int@plt>
mov    $0x400,%edi
mov    $0xa,%esi
call   1040 <test_int_to_str@plt>
mov    $0xfffffc00,%edi
mov    $0xa,%esi
call   1040 <test_int_to_str@plt>
mov    $0x5,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0xfffffffb,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0xbeef,%edi
mov    $0x10,%esi
call   1040 <test_int_to_str@plt>
mov    $0xffff4111,%edi
mov    $0x10,%esi
call   1040 <test_int_to_str@plt>
mov    $0x3ff,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
mov    $0x400,%edi
mov    $0x2,%esi
call   1040 <test_int_to_str@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1024\00"
@.str.1 = [6 x i8] c"-1024\00"
@.str.2 = [3 x i8] c"FF\00"
@.str.3 = [4 x i8] c"-ff\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [5 x i8] c"123a\00"
@.str.6 = [5 x i8] c"1012\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 10)
%3 = call i32 @test_str_to_int(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 10)
%4 = call i32 @test_str_to_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 16)
%5 = call i32 @test_str_to_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 16)
%6 = call i32 @test_str_to_int(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 2)
%7 = call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 10)
%8 = call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 2)
%9 = call i32 @test_int_to_str(i32 1024, i32 10)
%10 = call i32 @test_int_to_str(i32 -1024, i32 10)
%11 = call i32 @test_int_to_str(i32 5, i32 2)
%12 = call i32 @test_int_to_str(i32 -5, i32 2)
%13 = call i32 @test_int_to_str(i32 48879, i32 16)
%14 = call i32 @test_int_to_str(i32 -48879, i32 16)
%15 = call i32 @test_int_to_str(i32 1023, i32 2)
%16 = call i32 @test_int_to_str(i32 1024, i32 2)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"1024\00"
@.str.1 = [6 x i8] c"-1024\00"
@.str.2 = [3 x i8] c"FF\00"
@.str.3 = [4 x i8] c"-ff\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [5 x i8] c"123a\00"
@.str.6 = [5 x i8] c"1012\00"
define i32 @main() {
%1 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 10)
%2 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 10)
%3 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 16)
%4 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 16)
%5 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 2)
%6 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 10)
%7 = tail call i32 @test_str_to_int(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 2)
%8 = tail call i32 @test_int_to_str(i32 1024, i32 10)
%9 = tail call i32 @test_int_to_str(i32 -1024, i32 10)
%10 = tail call i32 @test_int_to_str(i32 5, i32 2)
%11 = tail call i32 @test_int_to_str(i32 -5, i32 2)
%12 = tail call i32 @test_int_to_str(i32 48879, i32 16)
%13 = tail call i32 @test_int_to_str(i32 -48879, i32 16)
%14 = tail call i32 @test_int_to_str(i32 1023, i32 2)
%15 = tail call i32 @test_int_to_str(i32 1024, i32 2)
ret i32 0
}