#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 */
char *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char const *, char *, char *);
scalar_t__ strcmp(char *, char const *);
int strlen(char const *);
void parsestr(int argc, char *argv[], const char *name, char **p,
              unsigned hasdef, const char *defval) {
  int i, res, slen;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
      printf("--%s <str>", name);
      if (hasdef)
        printf(" (DEFAULT:%s)", 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);
    }
    slen = strlen(argv[i + 1]);
    if (slen > 5000) {
      printf("option %s value too long\n", name);
      exit(1);
    }
    *p = calloc(slen + 1, sizeof(char));
    if (*p == NULL) {
      printf("option %s memory error\n", name);
      exit(1);
    }
    res = sscanf(argv[i + 1], "%s", *p);
    if (res != 1) {
      printf("option %s failed to parse value\n", name);
      exit(1);
    }
    break;
  }
  if (i == argc) {
    if (hasdef) {
      slen = strlen(defval);
      if (slen > 5000) {
        printf("option %s value too long\n", name);
        exit(1);
      }
      *p = calloc(slen + 1, sizeof(char));
      if (*p == NULL) {
        printf("option %s memory error\n", name);
        exit(1);
      }
      res = sscanf(defval, "%s", *p);
      if (res != 1) {
        printf("option %s failed to parse value\n", name);
        exit(1);
      }
    } else {
      printf("option %s is required\n", name);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<parsestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122a <parsestr+0xca>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe5b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11d6 <parsestr+0x76>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe40(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1217 <parsestr+0xb7>
mov    -0x18(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1204 <parsestr+0xa4>
mov    -0x30(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14bd <parsestr+0x35d>
jmp    121c <parsestr+0xbc>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1186 <parsestr+0x26>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13c8 <parsestr+0x268>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    125c <parsestr+0xfc>
jmp    13ba <parsestr+0x25a>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12b0 <parsestr+0x150>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    12b0 <parsestr+0x150>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12b5 <parsestr+0x155>
jmp    13ba <parsestr+0x25a>
mov    -0x34(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12e2 <parsestr+0x182>
mov    -0x18(%rbp),%rsi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1388,-0x3c(%rbp)
jle    1324 <parsestr+0x1c4>
mov    -0x18(%rbp),%rsi
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1368 <parsestr+0x208>
mov    -0x18(%rbp),%rsi
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xce7(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     13b5 <parsestr+0x255>
mov    -0x18(%rbp),%rsi
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    13c8 <parsestr+0x268>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1231 <parsestr+0xd1>
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    14bd <parsestr+0x35d>
cmpl   $0x0,-0x24(%rbp)
je     149c <parsestr+0x33c>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1388,-0x3c(%rbp)
jle    1413 <parsestr+0x2b3>
mov    -0x18(%rbp),%rsi
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1457 <parsestr+0x2f7>
mov    -0x18(%rbp),%rsi
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xc05(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     1497 <parsestr+0x337>
mov    -0x18(%rbp),%rsi
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    14b8 <parsestr+0x358>
mov    -0x18(%rbp),%rsi
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    14bd <parsestr+0x35d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsestr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8d,0xc(%rsp)
mov    %rcx,%r15
mov    %rdx,%r14
mov    $0x1,%r12d
cmp    $0x2,%edi
jl     12cd <parsestr+0x15d>
mov    %rsi,%rbp
mov    %r15,0x20(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %edi,0x8(%rsp)
mov    %edi,%r13d
mov    $0x1,%ebx
lea    0xe40(%rip),%r14
lea    0xe40(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%rbx,8),%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     132d <parsestr+0x1bd>
mov    0x0(%rbp,%rbx,8),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     132d <parsestr+0x1bd>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11d0 <parsestr+0x60>
mov    0x8(%rsp),%edi
cmp    $0x2,%edi
mov    0x18(%rsp),%r14
mov    0x10(%rsp),%rbx
mov    0x20(%rsp),%r15
jl     12cd <parsestr+0x15d>
mov    $0x1,%r12d
jmp    1242 <parsestr+0xd2>
nopl   0x0(%rax)
add    $0x1,%r12
add    $0xffffffffffffffff,%r13
cmp    $0x1,%r13
je     12d2 <parsestr+0x162>
mov    0x0(%rbp,%r12,8),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     1230 <parsestr+0xc0>
mov    0x0(%rbp,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
jne    1230 <parsestr+0xc0>
cmpb   $0x2d,0x1(%rdi)
jne    1230 <parsestr+0xc0>
add    $0x2,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1230 <parsestr+0xc0>
cmp    $0x2,%r13d
je     13a8 <parsestr+0x238>
mov    0x8(%rbp,%r12,8),%rdi
call   1040 <strlen@plt>
cmp    $0x1389,%eax
jge    1372 <parsestr+0x202>
add    $0x1,%eax
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     137b <parsestr+0x20b>
mov    0x8(%rbp,%r12,8),%rdi
lea    0xdb6(%rip),%rsi
mov    %rax,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1384 <parsestr+0x214>
mov    0x8(%rsp),%edi
cmp    %edi,%r12d
jne    131e <parsestr+0x1ae>
cmpl   $0x0,0xc(%rsp)
je     138d <parsestr+0x21d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1389,%eax
jge    1372 <parsestr+0x202>
add    $0x1,%eax
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     137b <parsestr+0x20b>
lea    0xd60(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1384 <parsestr+0x214>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd6(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
je     135a <parsestr+0x1ea>
lea    0xcc7(%rip),%rdi
mov    0x10(%rsp),%rsi
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    0xcc3(%rip),%rdi
jmp    1394 <parsestr+0x224>
lea    0xcd4(%rip),%rdi
jmp    1394 <parsestr+0x224>
lea    0xce6(%rip),%rdi
jmp    1394 <parsestr+0x224>
lea    0xcfe(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xc74(%rip),%rdi
jmp    1394 <parsestr+0x224>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [11 x i8] c"--%s <str>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%s)\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [26 x i8] c"option %s value too long\0A\00"
@.str.7 = [24 x i8] c"option %s memory error\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.10 = [23 x i8] c"option %s is required\0A\00"
define void @parsestr(i32 %0, i8** %1, i8* %2, i8** %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i8* %2, i8** %9
store i8** %3, i8*** %10
store i32 %4, i32* %11
store i8* %5, i8** %12
store i32 1, i32* %13
br label %16
16: ; preds = %47, %6
%17 = load i32, i32* %13
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %50
20: ; preds = %16
%21 = load i8**, i8*** %8
%22 = load i32, i32* %13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %20
%29 = load i8**, i8*** %8
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %28, %20
%37 = load i8*, i8** %9
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i8*, i8** %12
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %36
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %195
46: ; preds = %28
br label %47
47: ; preds = %46
%48 = load i32, i32* %13
%49 = add nsw i32 %48, 1
store i32 %49, i32* %13
br label %16
50: ; preds = %16
store i32 1, i32* %13
br label %51
51: ; preds = %147, %50
%52 = load i32, i32* %13
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %150
55: ; preds = %51
%56 = load i8**, i8*** %8
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @strlen(i8* %60)
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %64
63: ; preds = %55
br label %147
64: ; preds = %55
%65 = load i8**, i8*** %8
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = getelementptr inbounds i8, i8* %69, i64 0
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 45
br i1 %73, label %94, label %74
74: ; preds = %64
%75 = load i8**, i8*** %8
%76 = load i32, i32* %13
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 45
br i1 %83, label %94, label %84
84: ; preds = %74
%85 = load i8**, i8*** %8
%86 = load i32, i32* %13
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
%89 = load i8*, i8** %88
%90 = getelementptr inbounds i8, i8* %89, i64 2
%91 = load i8*, i8** %9
%92 = call i64 @strcmp(i8* %90, i8* %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %84, %74, %64
br label %147
95: ; preds = %84
%96 = load i32, i32* %13
%97 = load i32, i32* %7
%98 = sub nsw i32 %97, 1
%99 = icmp eq i32 %96, %98
br i1 %99, label %100, label %104
100: ; preds = %95
%101 = load i8*, i8** %9
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %101)
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %95
%105 = load i8**, i8*** %8
%106 = load i32, i32* %13
%107 = add nsw i32 %106, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8*, i8** %105, i64 %108
%110 = load i8*, i8** %109
%111 = call i32 @strlen(i8* %110)
store i32 %111, i32* %15
%112 = load i32, i32* %15
%113 = icmp sgt i32 %112, 5000
br i1 %113, label %114, label %118
114: ; preds = %104
%115 = load i8*, i8** %9
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %115)
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %104
%119 = load i32, i32* %15
%120 = add nsw i32 %119, 1
%121 = call i8* @calloc(i32 %120, i32 1)
%122 = load i8**, i8*** %10
store i8* %121, i8** %122
%123 = load i8**, i8*** %10
%124 = load i8*, i8** %123
%125 = icmp eq i8* %124, null
br i1 %125, label %126, label %130
126: ; preds = %118
%127 = load i8*, i8** %9
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %127)
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %118
%131 = load i8**, i8*** %8
%132 = load i32, i32* %13
%133 = add nsw i32 %132, 1
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8*, i8** %131, i64 %134
%136 = load i8*, i8** %135
%137 = load i8**, i8*** %10
%138 = load i8*, i8** %137
%139 = call i32 @sscanf(i8* %136, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %138)
store i32 %139, i32* %14
%140 = load i32, i32* %14
%141 = icmp ne i32 %140, 1
br i1 %141, label %142, label %146
142: ; preds = %130
%143 = load i8*, i8** %9
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %143)
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %130
br label %150
147: ; preds = %94, %63
%148 = load i32, i32* %13
%149 = add nsw i32 %148, 1
store i32 %149, i32* %13
br label %51
150: ; preds = %146, %51
%151 = load i32, i32* %13
%152 = load i32, i32* %7
%153 = icmp eq i32 %151, %152
br i1 %153, label %154, label %195
154: ; preds = %150
%155 = load i32, i32* %11
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %190
157: ; preds = %154
%158 = load i8*, i8** %12
%159 = call i32 @strlen(i8* %158)
store i32 %159, i32* %15
%160 = load i32, i32* %15
%161 = icmp sgt i32 %160, 5000
br i1 %161, label %162, label %166
162: ; preds = %157
%163 = load i8*, i8** %9
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %163)
%165 = call i32 @exit(i32 1)
unreachable
166: ; preds = %157
%167 = load i32, i32* %15
%168 = add nsw i32 %167, 1
%169 = call i8* @calloc(i32 %168, i32 1)
%170 = load i8**, i8*** %10
store i8* %169, i8** %170
%171 = load i8**, i8*** %10
%172 = load i8*, i8** %171
%173 = icmp eq i8* %172, null
br i1 %173, label %174, label %178
174: ; preds = %166
%175 = load i8*, i8** %9
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %175)
%177 = call i32 @exit(i32 1)
unreachable
178: ; preds = %166
%179 = load i8*, i8** %12
%180 = load i8**, i8*** %10
%181 = load i8*, i8** %180
%182 = call i32 @sscanf(i8* %179, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %181)
store i32 %182, i32* %14
%183 = load i32, i32* %14
%184 = icmp ne i32 %183, 1
br i1 %184, label %185, label %189
185: ; preds = %178
%186 = load i8*, i8** %9
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %186)
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %178
br label %194
190: ; preds = %154
%191 = load i8*, i8** %9
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %191)
%193 = call i32 @exit(i32 1)
unreachable
194: ; preds = %189
br label %195
195: ; preds = %44, %194, %150
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [11 x i8] c"--%s <str>\00"
@.str.3 = [14 x i8] c" (DEFAULT:%s)\00"
@.str.5 = [25 x i8] c"option %s value missing\0A\00"
@.str.6 = [26 x i8] c"option %s value too long\0A\00"
@.str.7 = [24 x i8] c"option %s memory error\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [33 x i8] c"option %s failed to parse value\0A\00"
@.str.10 = [23 x i8] c"option %s is required\0A\00"
define void @parsestr(i32 %0, i8** nocapture %1, i8* %2, i8** nocapture writeonly %3, i32 %4, i8* %5) {
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %85
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 %85
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 ([11 x i8], [11 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), i8* %5)
br label %31
31: ; preds = %29, %26
%32 = tail call i32 @putchar(i32 10)
br label %112
33: ; preds = %13, %82
%34 = phi i64 [ 1, %13 ], [ %83, %82 ]
%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 %82, 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 %82
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 %82
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 %82
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 @strlen(i8* %62)
%64 = icmp sgt i32 %63, 5000
br i1 %64, label %65, label %68
65: ; preds = %58
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%67 = tail call i32 @exit(i32 1)
unreachable
68: ; preds = %58
%69 = add nsw i32 %63, 1
%70 = tail call i8* @calloc(i32 %69, i32 1)
store i8* %70, i8** %3
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%74 = tail call i32 @exit(i32 1)
unreachable
75: ; preds = %68
%76 = load i8*, i8** %61
%77 = tail call i32 @sscanf(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %70)
%78 = icmp eq i32 %77, 1
br i1 %78, label %85, label %79
79: ; preds = %75
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%81 = tail call i32 @exit(i32 1)
unreachable
82: ; preds = %39, %43, %47, %33
%83 = add nuw nsw i64 %34, 1
%84 = icmp eq i64 %83, %14
br i1 %84, label %88, label %33
85: ; preds = %6, %12, %75
%86 = phi i32 [ %52, %75 ], [ 1, %12 ], [ 1, %6 ]
%87 = icmp eq i32 %86, %0
br i1 %87, label %88, label %112
88: ; preds = %82, %85
%89 = icmp eq i32 %4, 0
br i1 %89, label %109, label %90
90: ; preds = %88
%91 = tail call i32 @strlen(i8* %5)
%92 = icmp sgt i32 %91, 5000
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%95 = tail call i32 @exit(i32 1)
unreachable
96: ; preds = %90
%97 = add nsw i32 %91, 1
%98 = tail call i8* @calloc(i32 %97, i32 1)
store i8* %98, i8** %3
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %103
100: ; preds = %96
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%102 = tail call i32 @exit(i32 1)
unreachable
103: ; preds = %96
%104 = tail call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %98)
%105 = icmp eq i32 %104, 1
br i1 %105, label %112, label %106
106: ; preds = %103
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%108 = tail call i32 @exit(i32 1)
unreachable
109: ; preds = %88
%110 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%111 = tail call i32 @exit(i32 1)
unreachable
112: ; preds = %85, %103, %31
ret void
}