#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
int pl_Nn_Int(void *variable, int argc, char *argv[], int i, int k) {
  char c = '\0';
  if (i >= argc) {
    fprintf(stderr, "The command line is missing a non-negative ");
    fprintf(stderr, "integer at its end.\n\n");
    return (0);
  } else if ((sscanf(&argv[i][k], "%d%c", (int *)variable, &c) != 1) ||
             (c != '\0') || (*((int *)variable) < 0)) {
    fprintf(stderr, "\"%s\" (from item %d on the command line) ", &argv[i][k],
            i);
    fprintf(stderr, "is not a non-negative integer.\n\n");
    return (0);
  } else
    return (i + 1);
}


x86 assembly (clang, -O0):
<pl_Nn_Int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movb   $0x0,-0x29(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1184 <pl_Nn_Int+0x64>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1227 <pl_Nn_Int+0x107>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
lea    0xea0(%rip),%rsi
lea    -0x29(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ce <pl_Nn_Int+0xae>
movsbl -0x29(%rbp),%eax
cmp    $0x0,%eax
jne    11ce <pl_Nn_Int+0xae>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    121e <pl_Nn_Int+0xfe>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x28(%rbp),%rax
add    %rax,%rdx
mov    -0x24(%rbp),%ecx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1227 <pl_Nn_Int+0x107>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pl_Nn_Int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xf(%rsp)
cmp    %esi,%ecx
jge    1178 <pl_Nn_Int+0x58>
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rdi,%r15
movslq %ecx,%r12
movslq %r8d,%rbp
mov    (%rdx,%r12,8),%rdi
add    %rbp,%rdi
lea    0xef1(%rip),%rsi
lea    0xf(%rsp),%rcx
mov    %r15,%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    119d <pl_Nn_Int+0x7d>
cmpb   $0x0,0xf(%rsp)
jne    119d <pl_Nn_Int+0x7d>
cmpl   $0x0,(%r15)
js     119d <pl_Nn_Int+0x7d>
add    $0x1,%ebx
mov    %ebx,%r14d
jmp    11d2 <pl_Nn_Int+0xb2>
mov    0x2e61(%rip),%rbx
mov    (%rbx),%edi
lea    0xe78(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe91(%rip),%rsi
jmp    11cb <pl_Nn_Int+0xab>
mov    0x2e3c(%rip),%r15
mov    (%r15),%edi
add    (%r14,%r12,8),%rbp
lea    0xe95(%rip),%rsi
xor    %r14d,%r14d
mov    %rbp,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xea5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"The command line is missing a non-negative \00"
@.str.1 = [22 x i8] c"integer at its end.\0A\0A\00"
@.str.2 = [5 x i8] c"%d%c\00"
@.str.3 = [41 x i8] c"\22%s\22 (from item %d on the command line) \00"
@.str.4 = [33 x i8] c"is not a non-negative integer.\0A\0A\00"
define i32 @pl_Nn_Int(i8* %0, i32 %1, i8** %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8 0, i8* %12
%13 = load i32, i32* %10
%14 = load i32, i32* %8
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %5
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %60
21: ; preds = %5
%22 = load i8**, i8*** %9
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8*, i8** %7
%31 = bitcast i8* %30 to i32*
%32 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %31, i8* %12)
%33 = icmp ne i32 %32, 1
br i1 %33, label %43, label %34
34: ; preds = %21
%35 = load i8, i8* %12
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %34
%39 = load i8*, i8** %7
%40 = bitcast i8* %39 to i32*
%41 = load i32, i32* %40
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %57
43: ; preds = %38, %34, %21
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %9
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i32, i32* %10
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %52, i32 %53)
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %60
57: ; preds = %38
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %60
60: ; preds = %57, %43, %16
%61 = load i32, i32* %6
ret i32 %61
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"The command line is missing a non-negative \00"
@.str.1 = [22 x i8] c"integer at its end.\0A\0A\00"
@.str.2 = [5 x i8] c"%d%c\00"
@.str.3 = [41 x i8] c"\22%s\22 (from item %d on the command line) \00"
@.str.4 = [33 x i8] c"is not a non-negative integer.\0A\0A\00"
define i32 @pl_Nn_Int(i8* %0, i32 %1, i8** nocapture %2, i32 %3, i32 %4) {
%6 = alloca i8
store i8 0, i8* %6
%7 = icmp slt i32 %3, %1
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %37
13: ; preds = %5
%14 = sext i32 %3 to i64
%15 = getelementptr inbounds i8*, i8** %2, i64 %14
%16 = load i8*, i8** %15
%17 = sext i32 %4 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = bitcast i8* %0 to i32*
%20 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %19, i8* %6)
%21 = icmp ne i32 %20, 1
%22 = load i8, i8* %6
%23 = icmp ne i8 %22, 0
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %28, label %25
25: ; preds = %13
%26 = load i32, i32* %19
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25, %13
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %15
%31 = getelementptr inbounds i8, i8* %30, i64 %17
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %31, i32 %3)
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %37
35: ; preds = %25
%36 = add nsw i32 %3, 1
br label %37
37: ; preds = %35, %28, %8
%38 = phi i32 [ 0, %8 ], [ 0, %28 ], [ %36, %35 ]
ret i32 %38
}