#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*/ printf(char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
void main() {
  char a[] = "1000000000";
  char b[] = "1000000000";
  char c[] = "ffff";
  char d[] = "0x42532075";
  printf("a=%d\n", strtol(a, NULL, 10));
  printf("b=%d\n", strtol(b, NULL, 2));
  printf("c=%d\n", strtol(c, NULL, 16));
  printf("d=%X\n", strtol(d, NULL, 16));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xb(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x16(%rbp)
mov    0xeaf(%rip),%ax
mov    %ax,-0xe(%rbp)
mov    0xea7(%rip),%al
mov    %al,-0xc(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x1b(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0x17(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x26(%rbp)
mov    0xe8e(%rip),%ax
mov    %ax,-0x1e(%rbp)
mov    0xe86(%rip),%al
mov    %al,-0x1c(%rbp)
lea    -0xb(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
lea    -0x16(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1b(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
lea    -0x26(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movabs $0x3030303030303031,%rax
30 30 30
mov    %rax,0x28(%rsp)
movl   $0x303030,0x2f(%rsp)
mov    %rax,0x18(%rsp)
movl   $0x303030,0x1f(%rsp)
movb   $0x0,0x4(%rsp)
movl   $0x66666666,(%rsp)
movabs $0x3032333532347830,%rax
33 32 30
mov    %rax,0x8(%rsp)
movl   $0x353730,0xf(%rsp)
lea    0x28(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
lea    0xe98(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <strtol@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
lea    0xe68(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
lea    0xe4f(%rip),%rdi
mov    %eax,%esi
add    $0x38,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.main.a = [11 x i8] c"1000000000\00"
@__const.main.b = [11 x i8] c"1000000000\00"
@__const.main.c = [5 x i8] c"ffff\00"
@__const.main.d = [11 x i8] c"0x42532075\00"
@.str = [6 x i8] c"a=%d\0A\00"
@.str.1 = [6 x i8] c"b=%d\0A\00"
@.str.2 = [6 x i8] c"c=%d\0A\00"
@.str.3 = [6 x i8] c"d=%X\0A\00"
define void @main() {
%1 = alloca [11 x i8]
%2 = alloca [11 x i8]
%3 = alloca [5 x i8]
%4 = alloca [11 x i8]
%5 = bitcast [11 x i8]* %1 to i8*
%6 = bitcast [11 x i8]* %2 to i8*
%7 = bitcast [5 x i8]* %3 to i8*
%8 = bitcast [11 x i8]* %4 to i8*
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%10 = call i32 @strtol(i8* %9, i32* null, i32 10)
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%13 = call i32 @strtol(i8* %12, i32* null, i32 2)
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%16 = call i32 @strtol(i8* %15, i32* null, i32 16)
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%19 = call i32 @strtol(i8* %18, i32* null, i32 16)
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %19)
ret void
}

LLVM IR (-O2):
@__const.main.b = [11 x i8] c"1000000000\00"
@__const.main.c = [5 x i8] c"ffff\00"
@__const.main.d = [11 x i8] c"0x42532075\00"
@.str = [6 x i8] c"a=%d\0A\00"
@.str.1 = [6 x i8] c"b=%d\0A\00"
@.str.2 = [6 x i8] c"c=%d\0A\00"
@.str.3 = [6 x i8] c"d=%X\0A\00"
define void @main() {
%1 = alloca [11 x i8]
%2 = alloca [11 x i8]
%3 = alloca [5 x i8]
%4 = alloca [11 x i8]
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = call i32 @strtol(i8* nocapture %5, i32* null, i32 10)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @strtol(i8* nocapture %6, i32* null, i32 2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 @strtol(i8* nocapture %7, i32* null, i32 16)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 @strtol(i8* nocapture %8, i32* null, i32 16)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %15)
ret void
}