#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 */
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
long strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  int i;
  char *ep;
  long base;
  long lval;
  if (argc < 2) {
    printf("Usage: %s base 'string' [base 'string']...\n", argv[0]);
    return 0;
  }
  for (i = 1; i < argc; i++) {
    base = strtol(argv[i], &ep, 10);
    if (*ep != '\0') {
      printf("base error in '%s' near '%s'\n", argv[i], ep);
      return 0;
    } else if (base > 36 || base < 0) {
      printf("Invalid base: %ld\n", base);
      return 0;
    }
    if (++i >= argc) {
      printf("missing conversion string! arg # %d\n", i);
      return 0;
    }
    errno = 0;
    lval = strtol(argv[i], &ep, (int)base);
    if (errno != 0) {
      perror(argv[i]);
    } else {
      printf("%s(%ld) => %ld(10); ep = '%s'\n", argv[i], base, lval, ep);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d8 <main+0x1a8>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d1 <main+0x1a1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11dc <main+0xac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d8 <main+0x1a8>
cmpq   $0x24,-0x28(%rbp)
jg     11f2 <main+0xc2>
cmpq   $0x0,-0x28(%rbp)
jge    1210 <main+0xe0>
mov    -0x28(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d8 <main+0x1a8>
jmp    1215 <main+0xe5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jl     1244 <main+0x114>
mov    -0x14(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d8 <main+0x1a8>
mov    0x2d95(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
lea    -0x20(%rbp),%rsi
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d68(%rip),%rax
cmpq   $0x0,(%rax)
je     1298 <main+0x168>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <perror@plt>
jmp    12be <main+0x18e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c3 <main+0x193>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jge    1152 <main+0x22>
mov    (%r14),%rsi
lea    0xeb3(%rip),%rdi
jmp    1212 <main+0xe2>
mov    %edi,%ebp
mov    $0x2,%ebx
mov    %rsp,%r15
mov    0x2e7d(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x8(%r14,%rbx,8),%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    (%rsp),%rdx
cmpb   $0x0,(%rdx)
jne    11f3 <main+0xc3>
mov    %rax,%r13
cmp    $0x25,%rax
jae    1208 <main+0xd8>
cmp    %rbp,%rbx
jae    122a <main+0xfa>
movq   $0x0,(%r12)
mov    (%r14,%rbx,8),%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <strtol@plt>
cmpq   $0x0,(%r12)
mov    (%r14,%rbx,8),%rsi
jne    11e9 <main+0xb9>
mov    (%rsp),%r8
lea    0xeb8(%rip),%rdi
mov    %r13,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x2(%rbx),%rax
add    $0x1,%rbx
cmp    %rbp,%rbx
mov    %rax,%rbx
jb     1170 <main+0x40>
jmp    1219 <main+0xe9>
mov    %rsi,%rdi
call   1050 <perror@plt>
jmp    11d7 <main+0xa7>
mov    -0x8(%r14,%rbx,8),%rsi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1219 <main+0xe9>
lea    0xe3b(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe2c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1219 <main+0xe9>

LLVM IR (-O0):
@.str = [44 x i8] c"Usage: %s base 'string' [base 'string']...\0A\00"
@.str.1 = [30 x i8] c"base error in '%s' near '%s'\0A\00"
@.str.2 = [19 x i8] c"Invalid base: %ld\0A\00"
@.str.3 = [37 x i8] c"missing conversion string! arg # %d\0A\00"
@errno = global i64 0
@.str.4 = [31 x i8] c"%s(%ld) => %ld(10); ep = '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %3
br label %92
17: ; preds = %2
store i32 1, i32* %6
br label %18
18: ; preds = %88, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %91
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strtol(i8* %27, i8** %7, i32 10)
store i64 %28, i64* %8
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %22
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = load i8*, i8** %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %39)
store i32 0, i32* %3
br label %92
41: ; preds = %22
%42 = load i64, i64* %8
%43 = icmp sgt i64 %42, 36
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i64, i64* %8
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44, %41
%48 = load i64, i64* %8
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %48)
store i32 0, i32* %3
br label %92
50: ; preds = %44
br label %51
51: ; preds = %50
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
%54 = load i32, i32* %4
%55 = icmp sge i32 %53, %54
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = load i32, i32* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %57)
store i32 0, i32* %3
br label %92
59: ; preds = %51
store i64 0, i64* @errno
%60 = load i8**, i8*** %5
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = load i64, i64* %8
%66 = trunc i64 %65 to i32
%67 = call i64 @strtol(i8* %64, i8** %7, i32 %66)
store i64 %67, i64* %9
%68 = load i64, i64* @errno
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %77
70: ; preds = %59
%71 = load i8**, i8*** %5
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @perror(i8* %75)
br label %87
77: ; preds = %59
%78 = load i8**, i8*** %5
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = load i64, i64* %8
%84 = load i64, i64* %9
%85 = load i8*, i8** %7
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %82, i64 %83, i64 %84, i8* %85)
br label %87
87: ; preds = %77, %70
br label %88
88: ; preds = %87
%89 = load i32, i32* %6
%90 = add nsw i32 %89, 1
store i32 %90, i32* %6
br label %18
91: ; preds = %18
store i32 0, i32* %3
br label %92
92: ; preds = %91, %56, %47, %33, %12
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str = [44 x i8] c"Usage: %s base 'string' [base 'string']...\0A\00"
@.str.1 = [30 x i8] c"base error in '%s' near '%s'\0A\00"
@.str.2 = [19 x i8] c"Invalid base: %ld\0A\00"
@.str.3 = [37 x i8] c"missing conversion string! arg # %d\0A\00"
@errno = global i64 0
@.str.4 = [31 x i8] c"%s(%ld) => %ld(10); ep = '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %50
11: ; preds = %6, %47
%12 = phi i64 [ 1, %6 ], [ %48, %47 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call i64 @strtol(i8* %14, i8** %3, i32 10)
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %11
%20 = and i64 %12, 4294967295
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %16)
br label %50
24: ; preds = %11
%25 = icmp ugt i64 %15, 36
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %15)
br label %50
28: ; preds = %24
%29 = add nuw nsw i64 %12, 1
%30 = icmp ult i64 %29, %7
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = trunc i64 %29 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %50
34: ; preds = %28
store i64 0, i64* @errno
%35 = getelementptr inbounds i8*, i8** %1, i64 %29
%36 = load i8*, i8** %35
%37 = trunc i64 %15 to i32
%38 = call i64 @strtol(i8* %36, i8** %3, i32 %37)
%39 = load i64, i64* @errno
%40 = icmp eq i64 %39, 0
%41 = load i8*, i8** %35
br i1 %40, label %44, label %42
42: ; preds = %34
%43 = tail call i32 @perror(i8* %41)
br label %47
44: ; preds = %34
%45 = load i8*, i8** %3
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %41, i64 %15, i64 %38, i8* %45)
br label %47
47: ; preds = %42, %44
%48 = add nuw nsw i64 %12, 2
%49 = icmp ult i64 %48, %7
br i1 %49, label %11, label %50
50: ; preds = %47, %31, %26, %19, %8
ret i32 0
}