#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 UINT16_MAX;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ printf(char *, ...);
void read_options(int argc, char **argv, int *mode, int *count, char **filename,
                  int *max_length, int *min_length) {
  int c;
  if (argc == 1) {
    print_help();
  }
  while ((c = getopt(argc, argv, "n:m:f:a:i:")) != -1) {
    switch (c) {
    case 'n':
      *count = atoi(optarg);
      break;
    case 'm':
      *mode = atoi(optarg);
      break;
    case 'a':
      *max_length = atoi(optarg);
      break;
    case 'i':
      *min_length = atoi(optarg);
      break;
    case 'f':
      *filename = optarg;
      break;
    default:
      print_help();
      break;
    }
  }
  if (*max_length < *min_length) {
    printf("Max-length is shorter than min-length.\n");
    exit(1);
  }
  if (*min_length <= 1) {
    printf("Min-length set to 1!\n");
    *min_length = 1;
  }
  if (*max_length > UINT16_MAX) {
    printf("Max-length set to %d!\n", UINT16_MAX);
    *max_length = UINT16_MAX;
  }
}


x86 assembly (clang, -O0):
<read_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1184 <read_options+0x34>
mov    $0x0,%al
call   1060 <print_help@plt>
jmp    1189 <read_options+0x39>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea1(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1263 <read_options+0x113>
mov    -0x34(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0xd,%eax
ja     1257 <read_options+0x107>
mov    -0x40(%rbp),%rax
lea    0xe38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e20(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    125e <read_options+0x10e>
mov    0x2e04(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    125e <read_options+0x10e>
mov    0x2de8(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    125e <read_options+0x10e>
mov    0x2dcc(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    125e <read_options+0x10e>
mov    0x2db0(%rip),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    125e <read_options+0x10e>
mov    $0x0,%al
call   1060 <print_help@plt>
jmp    1189 <read_options+0x39>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    128d <read_options+0x13d>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jg     12b2 <read_options+0x162>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2d19(%rip),%rcx
cmp    (%rcx),%eax
jle    12ed <read_options+0x19d>
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cf3(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jne    1190 <read_options+0x30>
xor    %eax,%eax
call   1070 <print_help@plt>
lea    0xea1(%rip),%r14
lea    0xe62(%rip),%r15
mov    0x2e53(%rip),%r12
jmp    11c0 <read_options+0x60>
mov    (%r12),%rdi
call   1060 <atoi@plt>
mov    %eax,0x0(%r13)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0xd,%ecx
ja     1221 <read_options+0xc1>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%rdi
call   1060 <atoi@plt>
mov    (%rsp),%rcx
mov    %eax,(%rcx)
jmp    11c0 <read_options+0x60>
mov    (%r12),%rdi
call   1060 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
jmp    11c0 <read_options+0x60>
mov    (%r12),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
jmp    11c0 <read_options+0x60>
mov    (%r12),%rdi
call   1060 <atoi@plt>
mov    0x50(%rsp),%rcx
mov    %eax,(%rcx)
jmp    11c0 <read_options+0x60>
cmp    $0xffffffff,%eax
je     122f <read_options+0xcf>
xor    %eax,%eax
call   1070 <print_help@plt>
jmp    11c0 <read_options+0x60>
mov    (%rsp),%rax
mov    (%rax),%eax
mov    0x50(%rsp),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%eax
jl     1294 <read_options+0x134>
cmp    $0x1,%ecx
jg     1262 <read_options+0x102>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
mov    0x50(%rsp),%rax
movl   $0x1,(%rax)
mov    (%rsp),%rax
mov    (%rax),%eax
mov    0x2d6f(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%eax
jle    1285 <read_options+0x125>
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%eax
mov    (%rsp),%rcx
mov    %eax,(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"n:m:f:a:i:\00"
@optarg = global i8* null
@.str.1 = [40 x i8] c"Max-length is shorter than min-length.\0A\00"
@.str.2 = [22 x i8] c"Min-length set to 1!\0A\00"
@UINT16_MAX = global i32 0
@.str.3 = [23 x i8] c"Max-length set to %d!\0A\00"
define void @read_options(i32 %0, i8** %1, i32* %2, i32* %3, i8** %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i8** %4, i8*** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %7
%19 = call i32 (...) @print_help()
br label %20
20: ; preds = %18, %7
br label %21
21: ; preds = %49, %20
%22 = load i32, i32* %8
%23 = load i8**, i8*** %9
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %24, i32* %15
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %50
26: ; preds = %21
%27 = load i32, i32* %15
switch i32 %27, label %47 [
i32 110, label %28
i32 109, label %32
i32 97, label %36
i32 105, label %40
i32 102, label %44
]
28: ; preds = %26
%29 = load i8*, i8** @optarg
%30 = call i32 @atoi(i8* %29)
%31 = load i32*, i32** %11
store i32 %30, i32* %31
br label %49
32: ; preds = %26
%33 = load i8*, i8** @optarg
%34 = call i32 @atoi(i8* %33)
%35 = load i32*, i32** %10
store i32 %34, i32* %35
br label %49
36: ; preds = %26
%37 = load i8*, i8** @optarg
%38 = call i32 @atoi(i8* %37)
%39 = load i32*, i32** %13
store i32 %38, i32* %39
br label %49
40: ; preds = %26
%41 = load i8*, i8** @optarg
%42 = call i32 @atoi(i8* %41)
%43 = load i32*, i32** %14
store i32 %42, i32* %43
br label %49
44: ; preds = %26
%45 = load i8*, i8** @optarg
%46 = load i8**, i8*** %12
store i8* %45, i8** %46
br label %49
47: ; preds = %26
%48 = call i32 (...) @print_help()
br label %49
49: ; preds = %47, %44, %40, %36, %32, %28
br label %21
50: ; preds = %21
%51 = load i32*, i32** %13
%52 = load i32, i32* %51
%53 = load i32*, i32** %14
%54 = load i32, i32* %53
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %50
%60 = load i32*, i32** %14
%61 = load i32, i32* %60
%62 = icmp sle i32 %61, 1
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32*, i32** %14
store i32 1, i32* %65
br label %66
66: ; preds = %63, %59
%67 = load i32*, i32** %13
%68 = load i32, i32* %67
%69 = load i32, i32* @UINT16_MAX
%70 = icmp sgt i32 %68, %69
br i1 %70, label %71, label %76
71: ; preds = %66
%72 = load i32, i32* @UINT16_MAX
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %72)
%74 = load i32, i32* @UINT16_MAX
%75 = load i32*, i32** %13
store i32 %74, i32* %75
br label %76
76: ; preds = %71, %66
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"n:m:f:a:i:\00"
@optarg = global i8* null
@UINT16_MAX = global i32 0
@.str.3 = [23 x i8] c"Max-length set to %d!\0A\00"
@str = [21 x i8] c"Min-length set to 1!\00"
@str.4 = [39 x i8] c"Max-length is shorter than min-length.\00"
define void @read_options(i32 %0, i8** %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i8** nocapture writeonly %4, i32* nocapture %5, i32* nocapture %6) {
%8 = icmp eq i32 %0, 1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (...) @print_help()
br label %11
11: ; preds = %9, %7
br label %12
12: ; preds = %30, %11
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %28 [
i32 -1, label %31
i32 110, label %14
i32 109, label %17
i32 97, label %20
i32 105, label %23
i32 102, label %26
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
%16 = tail call i32 @atoi(i8* %15)
store i32 %16, i32* %3
br label %30
17: ; preds = %12
%18 = load i8*, i8** @optarg
%19 = tail call i32 @atoi(i8* %18)
store i32 %19, i32* %2
br label %30
20: ; preds = %12
%21 = load i8*, i8** @optarg
%22 = tail call i32 @atoi(i8* %21)
store i32 %22, i32* %5
br label %30
23: ; preds = %12
%24 = load i8*, i8** @optarg
%25 = tail call i32 @atoi(i8* %24)
store i32 %25, i32* %6
br label %30
26: ; preds = %12
%27 = load i8*, i8** @optarg
store i8* %27, i8** %4
br label %30
28: ; preds = %12
%29 = tail call i32 (...) @print_help()
br label %30
30: ; preds = %28, %26, %23, %20, %17, %14
br label %12
31: ; preds = %12
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %31
%39 = icmp slt i32 %33, 2
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
store i32 1, i32* %6
%42 = load i32, i32* %5
br label %43
43: ; preds = %40, %38
%44 = phi i32 [ %42, %40 ], [ %32, %38 ]
%45 = load i32, i32* @UINT16_MAX
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%49 = load i32, i32* @UINT16_MAX
store i32 %49, i32* %5
br label %50
50: ; preds = %47, %43
ret void
}