#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gridgen_printhelpalg();
int /*<<< orphan*/ gridgen_printhelpprm();
int /*<<< orphan*/ gridgen_printversion();
int /*<<< orphan*/ gridgen_setverbose(int);
int /*<<< orphan*/ quit(char *);
char tolower(char);
int /*<<< orphan*/ usage();
void parse_commandline(int argc, char *argv[], char **prmfname) {
  int i;
  for (i = 1; i < argc; ++i) {
    if (argv[i][0] != '-')
      *prmfname = argv[i];
    else
      switch (argv[i][1]) {
      case 'a':
        gridgen_printhelpalg();
        exit(0);
        break;
      case 'h':
        gridgen_printhelpprm();
        exit(0);
        break;
      case 'p':
        i++;
        if (i >= argc)
          quit("no file name found after (obsolete) -p\n");
        if (argv[i][0] == '-')
          quit("do not begin parameter file name with '-'\n");
        *prmfname = argv[i];
        break;
      case 'v':
        gridgen_setverbose(1);
        break;
      case 'V':
        gridgen_setverbose((argv[i][2] == 0) ? 2 : 3);
        break;
      default:
        usage();
        break;
      }
  }
  if (argc == 2 && tolower(argv[1][1]) == 'v') {
    gridgen_printversion();
    exit(0);
  }
  if (*prmfname == NULL)
    usage();
}


x86 assembly (clang, -O0):
<parse_commandline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12dd <parse_commandline+0x15d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11d6 <parse_commandline+0x56>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    12ca <parse_commandline+0x14a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffaa,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x20,%eax
ja     12be <parse_commandline+0x13e>
mov    -0x28(%rbp),%rax
lea    0xdfd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <gridgen_printhelpalg@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1040 <gridgen_printhelpprm@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1249 <parse_commandline+0xc9>
lea    0xe40(%rip),%rdi
call   1030 <quit@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    126d <parse_commandline+0xed>
lea    0xe44(%rip),%rdi
call   1030 <quit@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    12c5 <parse_commandline+0x145>
mov    $0x1,%edi
call   1050 <gridgen_setverbose@plt>
jmp    12c5 <parse_commandline+0x145>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x2(%rax),%ecx
mov    $0x3,%edi
mov    $0x2,%eax
cmp    $0x0,%ecx
cmove  %eax,%edi
call   1050 <gridgen_setverbose@plt>
jmp    12c5 <parse_commandline+0x145>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    12ca <parse_commandline+0x14a>
jmp    12cf <parse_commandline+0x14f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <parse_commandline+0x1a>
cmpl   $0x2,-0x4(%rbp)
jne    1312 <parse_commandline+0x192>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%edi
call   1070 <tolower@plt>
movsbl %al,%eax
cmp    $0x76,%eax
jne    1312 <parse_commandline+0x192>
mov    $0x0,%al
call   1060 <gridgen_printversion@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1327 <parse_commandline+0x1a7>
mov    $0x0,%al
call   1090 <usage@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_commandline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
cmp    $0x2,%edi
jl     1254 <parse_commandline+0xd4>
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%ebx
lea    0xe58(%rip),%r15
jmp    11be <parse_commandline+0x3e>
nopw   0x0(%rax,%rax,1)
mov    %rax,(%r14)
add    $0x1,%ebx
cmp    %ebp,%ebx
jge    123e <parse_commandline+0xbe>
movslq %ebx,%rax
mov    0x0(%r13,%rax,8),%rax
cmpb   $0x2d,(%rax)
jne    11b0 <parse_commandline+0x30>
movsbl 0x1(%rax),%ecx
add    $0xffffffaa,%ecx
cmp    $0x20,%ecx
ja     11f3 <parse_commandline+0x73>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
cmpb   $0x1,0x2(%rax)
mov    $0x3,%edi
sbb    $0x0,%edi
call   1050 <gridgen_setverbose@plt>
jmp    11b3 <parse_commandline+0x33>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    11b3 <parse_commandline+0x33>
add    $0x1,%ebx
cmp    %ebp,%ebx
jl     120f <parse_commandline+0x8f>
lea    0xe7a(%rip),%rdi
call   1030 <quit@plt>
movslq %ebx,%r12
mov    0x0(%r13,%r12,8),%rax
cmpb   $0x2d,(%rax)
jne    11b0 <parse_commandline+0x30>
lea    0xe89(%rip),%rdi
call   1030 <quit@plt>
mov    0x0(%r13,%r12,8),%rax
jmp    11b0 <parse_commandline+0x30>
mov    $0x1,%edi
call   1050 <gridgen_setverbose@plt>
jmp    11b3 <parse_commandline+0x33>
cmp    $0x2,%ebp
jne    1254 <parse_commandline+0xd4>
mov    0x8(%r13),%rax
movsbl 0x1(%rax),%edi
call   1070 <tolower@plt>
cmp    $0x76,%al
je     129a <parse_commandline+0x11a>
cmpq   $0x0,(%r14)
je     1269 <parse_commandline+0xe9>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <usage@plt>
xor    %eax,%eax
call   1080 <gridgen_printhelpalg@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
call   1040 <gridgen_printhelpprm@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
call   1060 <gridgen_printversion@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"no file name found after (obsolete) -p\0A\00"
@.str.1 = [43 x i8] c"do not begin parameter file name with '-'\0A\00"
define void @parse_commandline(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 1, i32* %7
br label %8
8: ; preds = %90, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %93
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 45
br i1 %21, label %22, label %29
22: ; preds = %12
%23 = load i8**, i8*** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %6
store i8* %27, i8** %28
br label %89
29: ; preds = %12
%30 = load i8**, i8*** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
switch i32 %37, label %86 [
i32 97, label %38
i32 104, label %41
i32 112, label %44
i32 118, label %71
i32 86, label %73
]
38: ; preds = %29
%39 = call i32 (...) @gridgen_printhelpalg()
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %29
%42 = call i32 (...) @gridgen_printhelpprm()
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %29
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = load i32, i32* %4
%49 = icmp sge i32 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @quit(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %52
52: ; preds = %50, %44
%53 = load i8**, i8*** %5
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 45
br i1 %61, label %62, label %64
62: ; preds = %52
%63 = call i32 @quit(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %64
64: ; preds = %62, %52
%65 = load i8**, i8*** %5
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %6
store i8* %69, i8** %70
br label %88
71: ; preds = %29
%72 = call i32 @gridgen_setverbose(i32 1)
br label %88
73: ; preds = %29
%74 = load i8**, i8*** %5
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = getelementptr inbounds i8, i8* %78, i64 2
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 0
%83 = zext i1 %82 to i64
%84 = select i1 %82, i32 2, i32 3
%85 = call i32 @gridgen_setverbose(i32 %84)
br label %88
86: ; preds = %29
%87 = call i32 (...) @usage()
br label %88
88: ; preds = %86, %73, %71, %64
br label %89
89: ; preds = %88, %22
br label %90
90: ; preds = %89
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %8
93: ; preds = %8
%94 = load i32, i32* %4
%95 = icmp eq i32 %94, 2
br i1 %95, label %96, label %108
96: ; preds = %93
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 1
%99 = load i8*, i8** %98
%100 = getelementptr inbounds i8, i8* %99, i64 1
%101 = load i8, i8* %100
%102 = call signext i8 @tolower(i8 signext %101)
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 118
br i1 %104, label %105, label %108
105: ; preds = %96
%106 = call i32 (...) @gridgen_printversion()
%107 = call i32 @exit(i32 0)
unreachable
108: ; preds = %96, %93
%109 = load i8**, i8*** %6
%110 = load i8*, i8** %109
%111 = icmp eq i8* %110, null
br i1 %111, label %112, label %114
112: ; preds = %108
%113 = call i32 (...) @usage()
br label %114
114: ; preds = %112, %108
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"no file name found after (obsolete) -p\0A\00"
@.str.1 = [43 x i8] c"do not begin parameter file name with '-'\0A\00"
define void @parse_commandline(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %65
5: ; preds = %3, %49
%6 = phi i32 [ %51, %49 ], [ 1, %3 ]
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 45
br i1 %11, label %13, label %12
12: ; preds = %5
store i8* %9, i8** %2
br label %49
13: ; preds = %5
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %47 [
i32 97, label %17
i32 104, label %20
i32 112, label %23
i32 118, label %39
i32 86, label %41
]
17: ; preds = %13
%18 = tail call i32 (...) @gridgen_printhelpalg()
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %13
%21 = tail call i32 (...) @gridgen_printhelpprm()
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %13
%24 = add nsw i32 %6, 1
%25 = icmp slt i32 %24, %0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 @quit(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = sext i32 %24 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 45
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = tail call i32 @quit(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%36 = load i8*, i8** %30
br label %37
37: ; preds = %34, %28
%38 = phi i8* [ %36, %34 ], [ %31, %28 ]
store i8* %38, i8** %2
br label %49
39: ; preds = %13
%40 = tail call i32 @gridgen_setverbose(i32 1)
br label %49
41: ; preds = %13
%42 = getelementptr inbounds i8, i8* %9, i64 2
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 0
%45 = select i1 %44, i32 2, i32 3
%46 = tail call i32 @gridgen_setverbose(i32 %45)
br label %49
47: ; preds = %13
%48 = tail call i32 (...) @usage()
br label %49
49: ; preds = %12, %47, %41, %39, %37
%50 = phi i32 [ %6, %12 ], [ %6, %47 ], [ %6, %41 ], [ %6, %39 ], [ %24, %37 ]
%51 = add nsw i32 %50, 1
%52 = icmp slt i32 %51, %0
br i1 %52, label %5, label %53
53: ; preds = %49
%54 = icmp eq i32 %0, 2
br i1 %54, label %55, label %65
55: ; preds = %53
%56 = getelementptr inbounds i8*, i8** %1, i64 1
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = load i8, i8* %58
%60 = tail call signext i8 @tolower(i8 signext %59)
%61 = icmp eq i8 %60, 118
br i1 %61, label %62, label %65
62: ; preds = %55
%63 = tail call i32 (...) @gridgen_printversion()
%64 = tail call i32 @exit(i32 0)
unreachable
65: ; preds = %3, %55, %53
%66 = load i8*, i8** %2
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = tail call i32 (...) @usage()
br label %70
70: ; preds = %68, %65
ret void
}