#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 */
typedef int /*<<< orphan*/ intmax_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ strtoimax(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int i;
  char *ep;
  intmax_t iv;
  for (i = 1; i < argc; i++) {
    iv = strtoimax(argv[i], &ep, 0);
    printf("strtoimax(\"%s\") = %jd\n", argv[i], iv);
    if (*ep)
      printf("   ep = \"%s\"\n", 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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b2 <main+0x92>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoimax@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x24(%rbp),%edx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     119f <main+0x7f>
mov    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a4 <main+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%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
cmp    $0x2,%edi
jl     118c <main+0x6c>
mov    %rsi,%rbx
mov    %edi,%r13d
mov    $0x1,%ebp
mov    %rsp,%r14
lea    0xebb(%rip),%r15
lea    0xecb(%rip),%r12
jmp    1159 <main+0x39>
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %rbp,%r13
je     118c <main+0x6c>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <strtoimax@plt>
mov    (%rbx,%rbp,8),%rsi
mov    %r15,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rsi
cmpb   $0x0,(%rsi)
je     1150 <main+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"strtoimax(\22%s\22) = %jd\0A\00"
@.str.1 = [14 x i8] c" ep = \22%s\22\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %34, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strtoimax(i8* %18, i8** %7, i32 0)
store i32 %19, i32* %8
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* %8
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %24, i32 %25)
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %13
%31 = load i8*, i8** %7
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %13
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %9
37: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"strtoimax(\22%s\22) = %jd\0A\00"
@.str.1 = [14 x i8] c" ep = \22%s\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %23
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %20
%9 = phi i64 [ 1, %6 ], [ %21, %20 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i32 @strtoimax(i8* %11, i8** %3, i32 0)
%13 = load i8*, i8** %10
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %12)
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %8
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %20
20: ; preds = %8, %18
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %20, %2
ret i32 0
}