#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);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, unsigned int *);
scalar_t__ strcmp(char *, char const *);
int strlen(char *);
void parseuns(int argc, char *argv[], const char *name, unsigned *p,
              unsigned hasdef, unsigned defval) {
  int i, res;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
      printf("--%s <unsigned int>", name);
      if (hasdef)
        printf(" (DEFAULT:%u)", defval);
      printf("\n");
      return;
    }
  }
  for (i = 1; i < argc; i++) {
    if (strlen(argv[i]) < 3)
      continue;
    if (argv[i][0] != '-' || argv[i][1] != '-' ||
        strcmp(argv[i] + 2, name) != 0)
      continue;
    if (i == argc - 1) {
      printf("option %s value missing\n", name);
      exit(1);
    }
    res = sscanf(argv[i + 1], "%u", p);
    if (res != 1) {
      printf("option %s failed to parse value\n", name);
      exit(1);
    }
    break;
  }
  if (i == argc) {
    if (hasdef) {
      *p = defval;
    } else {
      printf("option %s is required\n", name);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<parseuns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1219 <parseuns+0xc9>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c6 <parseuns+0x76>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1206 <parseuns+0xb6>
mov    -0x18(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     11f3 <parseuns+0xa3>
mov    -0x28(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1373 <parseuns+0x223>
jmp    120b <parseuns+0xbb>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1176 <parseuns+0x26>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    132e <parseuns+0x1de>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    124b <parseuns+0xfb>
jmp    1320 <parseuns+0x1d0>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    129f <parseuns+0x14f>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    129f <parseuns+0x14f>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12a4 <parseuns+0x154>
jmp    1320 <parseuns+0x1d0>
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12d1 <parseuns+0x181>
mov    -0x18(%rbp),%rsi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd58(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x30(%rbp)
je     131b <parseuns+0x1cb>
mov    -0x18(%rbp),%rsi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    132e <parseuns+0x1de>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1220 <parseuns+0xd0>
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1373 <parseuns+0x223>
cmpl   $0x0,-0x24(%rbp)
je     1352 <parseuns+0x202>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    136e <parseuns+0x21e>
mov    -0x18(%rbp),%rsi
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1373 <parseuns+0x223>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseuns>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8d,%ebx
mov    %rcx,0x20(%rsp)
mov    %rdx,%r14
mov    $0x1,%r12d
cmp    $0x2,%edi
jl     128b <parseuns+0x12b>
mov    %rsi,%rbp
mov    %ebx,0x14(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %edi,0xc(%rsp)
mov    %edi,%r13d
mov    $0x1,%ebx
lea    0xe51(%rip),%r15
lea    0xe51(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp,%rbx,8),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12ab <parseuns+0x14b>
mov    0x0(%rbp,%rbx,8),%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12ab <parseuns+0x14b>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <parseuns+0x60>
mov    0xc(%rsp),%edi
cmp    $0x2,%edi
mov    0x18(%rsp),%r14
mov    0x10(%rsp),%r15d
mov    0x14(%rsp),%ebx
jl     128b <parseuns+0x12b>
mov    $0x1,%r12d
jmp    122e <parseuns+0xce>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12
add    $0xffffffffffffffff,%r13
cmp    $0x1,%r13
je     1290 <parseuns+0x130>
mov    0x0(%rbp,%r12,8),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     1220 <parseuns+0xc0>
mov    0x0(%rbp,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
jne    1220 <parseuns+0xc0>
cmpb   $0x2d,0x1(%rdi)
jne    1220 <parseuns+0xc0>
add    $0x2,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1220 <parseuns+0xc0>
cmp    $0x2,%r13d
je     130a <parseuns+0x1aa>
mov    0x8(%rbp,%r12,8),%rdi
lea    0xdd1(%rip),%rsi
mov    0x20(%rsp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1313 <parseuns+0x1b3>
mov    0xc(%rsp),%edi
cmp    %edi,%r12d
jne    129c <parseuns+0x13c>
test   %ebx,%ebx
je     12ef <parseuns+0x18f>
mov    0x20(%rsp),%rax
mov    %r15d,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd58(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x14(%rsp)
je     12d7 <parseuns+0x177>
lea    0xd52(%rip),%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
lea    0xd73(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd1b(%rip),%rdi
jmp    12f6 <parseuns+0x196>
lea    0xd2e(%rip),%rdi
jmp    12f6 <parseuns+0x196>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [20 x i8] c"--%s <unsigned int>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%u)\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [3 x i8] c"%u\00"
@.str.7 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.8 = [23 x i8] c"option %s is required\0A\00"
define void @parseuns(i32 %0, i8** %1, i8* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 1, i32* %13
br label %15
15: ; preds = %46, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = load i8**, i8*** %8
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %19
%28 = load i8**, i8*** %8
%29 = load i32, i32* %13
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %27, %19
%36 = load i8*, i8** %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %11
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %137
45: ; preds = %27
br label %46
46: ; preds = %45
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %13
br label %15
49: ; preds = %15
store i32 1, i32* %13
br label %50
50: ; preds = %119, %49
%51 = load i32, i32* %13
%52 = load i32, i32* %7
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %122
54: ; preds = %50
%55 = load i8**, i8*** %8
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = icmp slt i32 %60, 3
br i1 %61, label %62, label %63
62: ; preds = %54
br label %119
63: ; preds = %54
%64 = load i8**, i8*** %8
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %71, 45
br i1 %72, label %93, label %73
73: ; preds = %63
%74 = load i8**, i8*** %8
%75 = load i32, i32* %13
%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 1
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 45
br i1 %82, label %93, label %83
83: ; preds = %73
%84 = load i8**, i8*** %8
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = getelementptr inbounds i8, i8* %88, i64 2
%90 = load i8*, i8** %9
%91 = call i64 @strcmp(i8* %89, i8* %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %83, %73, %63
br label %119
94: ; preds = %83
%95 = load i32, i32* %13
%96 = load i32, i32* %7
%97 = sub nsw i32 %96, 1
%98 = icmp eq i32 %95, %97
br i1 %98, label %99, label %103
99: ; preds = %94
%100 = load i8*, i8** %9
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %94
%104 = load i8**, i8*** %8
%105 = load i32, i32* %13
%106 = add nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8*, i8** %104, i64 %107
%109 = load i8*, i8** %108
%110 = load i32*, i32** %10
%111 = call i32 @sscanf(i8* %109, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %110)
store i32 %111, i32* %14
%112 = load i32, i32* %14
%113 = icmp ne i32 %112, 1
br i1 %113, label %114, label %118
114: ; preds = %103
%115 = load i8*, i8** %9
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %115)
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %103
br label %122
119: ; preds = %93, %62
%120 = load i32, i32* %13
%121 = add nsw i32 %120, 1
store i32 %121, i32* %13
br label %50
122: ; preds = %118, %50
%123 = load i32, i32* %13
%124 = load i32, i32* %7
%125 = icmp eq i32 %123, %124
br i1 %125, label %126, label %137
126: ; preds = %122
%127 = load i32, i32* %11
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = load i32, i32* %12
%131 = load i32*, i32** %10
store i32 %130, i32* %131
br label %136
132: ; preds = %126
%133 = load i8*, i8** %9
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %133)
%135 = call i32 @exit(i32 1)
unreachable
136: ; preds = %129
br label %137
137: ; preds = %43, %136, %122
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [20 x i8] c"--%s <unsigned int>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%u)\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [3 x i8] c"%u\00"
@.str.7 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.8 = [23 x i8] c"option %s is required\0A\00"
define void @parseuns(i32 %0, i8** nocapture %1, i8* %2, i32* %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %71
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %15
10: ; preds = %21
%11 = icmp eq i64 %25, %9
br i1 %11, label %12, label %15
12: ; preds = %10
br i1 %7, label %13, label %71
13: ; preds = %12
%14 = zext i32 %0 to i64
br label %33
15: ; preds = %8, %10
%16 = phi i64 [ 1, %8 ], [ %25, %10 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %15
%22 = load i8*, i8** %17
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %16, 1
br i1 %24, label %26, label %10
26: ; preds = %21, %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%28 = icmp eq i32 %4, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %31
31: ; preds = %29, %26
%32 = tail call i32 @putchar(i32 10)
br label %80
33: ; preds = %13, %68
%34 = phi i64 [ 1, %13 ], [ %69, %68 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = tail call i32 @strlen(i8* %36)
%38 = icmp slt i32 %37, 3
br i1 %38, label %68, label %39
39: ; preds = %33
%40 = load i8*, i8** %35
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 45
br i1 %42, label %43, label %68
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %40, i64 1
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 45
br i1 %46, label %47, label %68
47: ; preds = %43
%48 = getelementptr inbounds i8, i8* %40, i64 2
%49 = tail call i64 @strcmp(i8* %48, i8* %2)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %68
51: ; preds = %47
%52 = trunc i64 %34 to i32
%53 = add nsw i32 %0, -1
%54 = icmp eq i32 %53, %52
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %51
%59 = add nuw i64 %34, 1
%60 = and i64 %59, 4294967295
%61 = getelementptr inbounds i8*, i8** %1, i64 %60
%62 = load i8*, i8** %61
%63 = tail call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%64 = icmp eq i32 %63, 1
br i1 %64, label %71, label %65
65: ; preds = %58
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%67 = tail call i32 @exit(i32 1)
unreachable
68: ; preds = %39, %43, %47, %33
%69 = add nuw nsw i64 %34, 1
%70 = icmp eq i64 %69, %14
br i1 %70, label %74, label %33
71: ; preds = %6, %12, %58
%72 = phi i32 [ %52, %58 ], [ 1, %12 ], [ 1, %6 ]
%73 = icmp eq i32 %72, %0
br i1 %73, label %74, label %80
74: ; preds = %68, %71
%75 = icmp eq i32 %4, 0
br i1 %75, label %77, label %76
76: ; preds = %74
store i32 %5, i32* %3
br label %80
77: ; preds = %74
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%79 = tail call i32 @exit(i32 1)
unreachable
80: ; preds = %71, %76, %31
ret void
}