#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*/ printError(char *);
int strtol(char *, char **, int);
int checkArg(int i, int argc, char **argv, int *check, int map,
             unsigned int *constant) {
  if (i + 1 <= argc - 1) {
    if (!map) {
      ++i;
      char *end;
      int val = strtol(argv[i], &end, 10);
      if (end != NULL && !end[0] && val >= 0) {
        *constant = val;
        *check = 1;
        return 1;
      } else {
        printError("Unrecognised option(s)\n");
      }
    } else {
      printError("Conflict between -m and -x/-y/-d/-i/-s/-n\n");
    }
  }
}


x86 assembly (clang, -O0):
<checkArg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11e5 <checkArg+0xc5>
cmpl   $0x0,-0x24(%rbp)
jne    11d4 <checkArg+0xb4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x3c(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11c3 <checkArg+0xa3>
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11c3 <checkArg+0xa3>
cmpl   $0x0,-0x3c(%rbp)
jl     11c3 <checkArg+0xa3>
mov    -0x3c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e5 <checkArg+0xc5>
lea    0xe36(%rip),%rdi
call   1040 <printError@plt>
jmp    11e0 <checkArg+0xc0>
lea    0xe3d(%rip),%rdi
call   1040 <printError@plt>
jmp    11e5 <checkArg+0xc5>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkArg>:
push   %r14
push   %rbx
push   %rax
add    $0xffffffff,%esi
cmp    %edi,%esi
jle    117f <checkArg+0x5f>
test   %r8d,%r8d
je     1139 <checkArg+0x19>
lea    0xee1(%rip),%rdi
jmp    117a <checkArg+0x5a>
mov    %r9,%r14
mov    %rcx,%rbx
add    $0x1,%edi
movslq %edi,%rax
mov    (%rdx,%rax,8),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    (%rsp),%rcx
test   %rcx,%rcx
je     1173 <checkArg+0x53>
cmpb   $0x0,(%rcx)
jne    1173 <checkArg+0x53>
test   %eax,%eax
js     1173 <checkArg+0x53>
mov    %eax,(%r14)
movl   $0x1,(%rbx)
jmp    117f <checkArg+0x5f>
lea    0xe86(%rip),%rdi
call   1040 <printError@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Unrecognised option(s)\0A\00"
@.str.1 = [43 x i8] c"Conflict between -m and -x/-y/-d/-i/-s/-n\0A\00"
define i32 @checkArg(i32 %0, i32 %1, i8** %2, i32* %3, i32 %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i8** %2, i8*** %10
store i32* %3, i32** %11
store i32 %4, i32* %12
store i32* %5, i32** %13
%16 = load i32, i32* %8
%17 = add nsw i32 %16, 1
%18 = load i32, i32* %9
%19 = sub nsw i32 %18, 1
%20 = icmp sle i32 %17, %19
br i1 %20, label %21, label %53
21: ; preds = %6
%22 = load i32, i32* %12
%23 = icmp ne i32 %22, 0
br i1 %23, label %50, label %24
24: ; preds = %21
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
%27 = load i8**, i8*** %10
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strtol(i8* %31, i8** %14, i32 10)
store i32 %32, i32* %15
%33 = load i8*, i8** %14
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %47
35: ; preds = %24
%36 = load i8*, i8** %14
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = icmp ne i8 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %35
%41 = load i32, i32* %15
%42 = icmp sge i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32, i32* %15
%45 = load i32*, i32** %13
store i32 %44, i32* %45
%46 = load i32*, i32** %11
store i32 1, i32* %46
store i32 1, i32* %7
br label %53
47: ; preds = %40, %35, %24
%48 = call i32 @printError(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %47
br label %52
50: ; preds = %21
%51 = call i32 @printError(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
br label %53
53: ; preds = %43, %52, %6
%54 = load i32, i32* %7
ret i32 %54
}

LLVM IR (-O2):
@.str = [24 x i8] c"Unrecognised option(s)\0A\00"
@.str.1 = [43 x i8] c"Conflict between -m and -x/-y/-d/-i/-s/-n\0A\00"
define i32 @checkArg(i32 %0, i32 %1, i8** nocapture %2, i32* nocapture writeonly %3, i32 %4, i32* nocapture writeonly %5) {
%7 = alloca i8*
%8 = add nsw i32 %0, 1
%9 = add nsw i32 %1, -1
%10 = icmp sgt i32 %9, %0
br i1 %10, label %11, label %32
11: ; preds = %6
%12 = icmp eq i32 %4, 0
br i1 %12, label %13, label %30
13: ; preds = %11
%14 = bitcast i8** %7 to i8*
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds i8*, i8** %2, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i8** %7, i32 10)
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %27, label %21
21: ; preds = %13
%22 = load i8, i8* %19
%23 = icmp eq i8 %22, 0
%24 = icmp sgt i32 %18, -1
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 %18, i32* %5
store i32 1, i32* %3
br label %29
27: ; preds = %21, %13
%28 = tail call i32 @printError(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %26
br label %32
30: ; preds = %11
%31 = tail call i32 @printError(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %30, %6
ret i32 1
}