#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 /*<<< orphan*/);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int);
int main() {
  char ch1[] = "1111";
  char ch2[] = "2222";
  char ch3[] = "ABCD";
  printf("ch1 = %ld\n", strtol(ch1, NULL, 2));
  printf("ch2 = %ld\n", strtol(ch2, NULL, 10));
  printf("ch3 = %ld\n", strtol(ch3, NULL, 16));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec0(%rip),%al
mov    %al,-0x6(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xeb3(%rip),%al
mov    %al,-0xb(%rbp)
lea    -0x5(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
lea    -0xa(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
lea    -0xf(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movb   $0x0,0x14(%rsp)
movl   $0x31313131,0x10(%rsp)
31
movb   $0x0,0xc(%rsp)
movl   $0x32323232,0x8(%rsp)
32
movb   $0x0,0x4(%rsp)
movl   $0x44434241,(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <strtol@plt>
lea    0xead(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
lea    0xe99(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.ch1 = [5 x i8] c"1111\00"
@__const.main.ch2 = [5 x i8] c"2222\00"
@__const.main.ch3 = [5 x i8] c"ABCD\00"
@.str = [11 x i8] c"ch1 = %ld\0A\00"
@.str.1 = [11 x i8] c"ch2 = %ld\0A\00"
@.str.2 = [11 x i8] c"ch3 = %ld\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = bitcast [5 x i8]* %1 to i8*
%5 = bitcast [5 x i8]* %2 to i8*
%6 = bitcast [5 x i8]* %3 to i8*
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%8 = call i32 @strtol(i8* %7, i32* null, i32 2)
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = call i32 @strtol(i8* %10, i32* null, i32 10)
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%14 = call i32 @strtol(i8* %13, i32* null, i32 16)
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.ch1 = [5 x i8] c"1111\00"
@__const.main.ch2 = [5 x i8] c"2222\00"
@__const.main.ch3 = [5 x i8] c"ABCD\00"
@.str = [11 x i8] c"ch1 = %ld\0A\00"
@.str.1 = [11 x i8] c"ch2 = %ld\0A\00"
@.str.2 = [11 x i8] c"ch3 = %ld\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 @strtol(i8* nocapture %4, i32* null, i32 2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @strtol(i8* nocapture %5, i32* null, i32 10)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @strtol(i8* nocapture %6, i32* null, i32 16)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}