#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 atoi(char *);
int /*<<< orphan*/ dolot(int, char *, int, int, int, char *);
int /*<<< orphan*/ exit(int);
char getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *);
main(int argc, char *argv[]) {
  int LotNr, i;
  if (argc < 3) {
    printf(
        "Error. Pleas specify a lot nr and a collection.\n\nExample, this will "
        "read the first lot in the \"www\" colection:\n\trread 1 www\n");
    exit(1);
  }
  int optPrintHtml = 0;
  int optPrintAcl = 0;
  int optStatistics = 0;
  char *optReponame = NULL;
  extern char *optarg;
  extern int optind, opterr, optopt;
  char c;
  while ((c = getopt(argc, argv, "hsr:a")) != -1) {
    switch (c) {
    case 'h':
      optPrintHtml = 1;
      break;
    case 'a':
      optPrintAcl = 1;
      break;
    case 's':
      optStatistics = 1;
      break;
    case 'r':
      optReponame = optarg;
      break;
    default:
      exit(1);
    }
  }
  --optind;
  LotNr = atoi(argv[1 + optind]);
  char *subname = argv[2 + optind];
  if (LotNr == 0) {
    for (i = 0; i < 10000; i++) {
      dolot(i, subname, optPrintHtml, optPrintAcl, optStatistics, optReponame);
    }
  } else {
    dolot(LotNr, subname, optPrintHtml, optPrintAcl, optStatistics,
          optReponame);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1186 <main+0x36>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf18(%rip),%rdx
call   1050 <getopt@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     1235 <main+0xe5>
movsbl -0x31(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x12,%eax
ja     1226 <main+0xd6>
mov    -0x48(%rbp),%rax
lea    0xe1a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x1c(%rbp)
jmp    1230 <main+0xe0>
movl   $0x1,-0x20(%rbp)
jmp    1230 <main+0xe0>
movl   $0x1,-0x24(%rbp)
jmp    1230 <main+0xe0>
mov    0x2dc6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1230 <main+0xe0>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11a3 <main+0x53>
mov    0x2d9c(%rip),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    0x2d90(%rip),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x2d83(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2d64(%rip),%rcx
mov    (%rcx),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12cf <main+0x17f>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    12ca <main+0x17a>
mov    -0x18(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x30(%rbp),%r9
call   1040 <dolot@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1295 <main+0x145>
jmp    12e9 <main+0x199>
mov    -0x14(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x30(%rbp),%r9
call   1040 <dolot@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     127b <main+0x12b>
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xedc(%rip),%rdx
call   1050 <getopt@plt>
cmp    $0xff,%al
je     11e8 <main+0x98>
xor    %ecx,%ecx
lea    0xe7e(%rip),%r14
xor    %edx,%edx
mov    %rdx,(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
jmp    11b7 <main+0x67>
mov    0x2e49(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r13,%rsi
lea    0xea0(%rip),%rdx
call   1050 <getopt@plt>
mov    %ebx,%ecx
cmp    $0xff,%al
je     11f6 <main+0xa6>
movsbl %al,%eax
add    $0xffffff9f,%eax
cmp    $0x12,%eax
ja     1271 <main+0x121>
mov    $0x1,%ebx
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    $0x1,%r15d
jmp    119e <main+0x4e>
nopl   0x0(%rax)
mov    $0x1,%r12d
jmp    119e <main+0x4e>
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,(%rsp)
xor    %ebx,%ebx
mov    0x2ddb(%rip),%rax
movslq (%rax),%rbp
lea    -0x1(%rbp),%ecx
mov    %ecx,(%rax)
mov    0x0(%r13,%rbp,8),%rdi
call   1060 <atoi@plt>
mov    0x8(%r13,%rbp,8),%r13
test   %eax,%eax
je     1230 <main+0xe0>
mov    %eax,%edi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    (%rsp),%r9
call   1040 <dolot@plt>
jmp    1260 <main+0x110>
xor    %ebp,%ebp
mov    (%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    %r14,%r9
call   1040 <dolot@plt>
add    $0x1,%ebp
cmp    $0x2710,%ebp
jne    1240 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [125 x i8] c"Error. Pleas specify a lot nr and a collection.\0A\0AExample, this will read the first lot in the \22www\22 colection:\0A\09rread 1 www\0A\00"
@.str.1 = [6 x i8] c"hsr:a\00"
@optarg = external global i8*
@optind = external global i32
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i8* null, i8** %11
br label %20
20: ; preds = %36, %19
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call signext i8 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8 %23, i8* %12
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %37
26: ; preds = %20
%27 = load i8, i8* %12
%28 = sext i8 %27 to i32
switch i32 %28, label %34 [
i32 104, label %29
i32 97, label %30
i32 115, label %31
i32 114, label %32
]
29: ; preds = %26
store i32 1, i32* %8
br label %36
30: ; preds = %26
store i32 1, i32* %9
br label %36
31: ; preds = %26
store i32 1, i32* %10
br label %36
32: ; preds = %26
%33 = load i8*, i8** @optarg
store i8* %33, i8** %11
br label %36
34: ; preds = %26
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %32, %31, %30, %29
br label %20
37: ; preds = %20
%38 = load i32, i32* @optind
%39 = add nsw i32 %38, -1
store i32 %39, i32* @optind
%40 = load i8**, i8*** %5
%41 = load i32, i32* @optind
%42 = add nsw i32 1, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %6
%47 = load i8**, i8*** %5
%48 = load i32, i32* @optind
%49 = add nsw i32 2, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %47, i64 %50
%52 = load i8*, i8** %51
store i8* %52, i8** %13
%53 = load i32, i32* %6
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %71
55: ; preds = %37
store i32 0, i32* %7
br label %56
56: ; preds = %67, %55
%57 = load i32, i32* %7
%58 = icmp slt i32 %57, 10000
br i1 %58, label %59, label %70
59: ; preds = %56
%60 = load i32, i32* %7
%61 = load i8*, i8** %13
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = load i32, i32* %10
%65 = load i8*, i8** %11
%66 = call i32 @dolot(i32 %60, i8* %61, i32 %62, i32 %63, i32 %64, i8* %65)
br label %67
67: ; preds = %59
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %56
70: ; preds = %56
br label %79
71: ; preds = %37
%72 = load i32, i32* %6
%73 = load i8*, i8** %13
%74 = load i32, i32* %8
%75 = load i32, i32* %9
%76 = load i32, i32* %10
%77 = load i8*, i8** %11
%78 = call i32 @dolot(i32 %72, i8* %73, i32 %74, i32 %75, i32 %76, i8* %77)
br label %79
79: ; preds = %71, %70
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"hsr:a\00"
@optarg = external global i8*
@optind = external global i32
@str = [124 x i8] c"Error. Pleas specify a lot nr and a collection.\0A\0AExample, this will read the first lot in the \22www\22 colection:\0A\09rread 1 www\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8 %5, -1
br i1 %6, label %30, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %4, %23
%11 = phi i8 [ %28, %23 ], [ %5, %4 ]
%12 = phi i32 [ %27, %23 ], [ 0, %4 ]
%13 = phi i8* [ %26, %23 ], [ null, %4 ]
%14 = phi i32 [ %25, %23 ], [ 0, %4 ]
%15 = phi i32 [ %24, %23 ], [ 0, %4 ]
%16 = sext i8 %11 to i32
switch i32 %16, label %21 [
i32 104, label %23
i32 97, label %17
i32 115, label %18
i32 114, label %19
]
17: ; preds = %10
br label %23
18: ; preds = %10
br label %23
19: ; preds = %10
%20 = load i8*, i8** @optarg
br label %23
21: ; preds = %10
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %10, %19, %18, %17
%24 = phi i32 [ %15, %19 ], [ %15, %18 ], [ 1, %17 ], [ %15, %10 ]
%25 = phi i32 [ %14, %19 ], [ 1, %18 ], [ %14, %17 ], [ %14, %10 ]
%26 = phi i8* [ %20, %19 ], [ %13, %18 ], [ %13, %17 ], [ %13, %10 ]
%27 = phi i32 [ %12, %19 ], [ %12, %18 ], [ %12, %17 ], [ 1, %10 ]
%28 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i8 %28, -1
br i1 %29, label %30, label %10
30: ; preds = %23, %4
%31 = phi i32 [ 0, %4 ], [ %24, %23 ]
%32 = phi i32 [ 0, %4 ], [ %25, %23 ]
%33 = phi i8* [ null, %4 ], [ %26, %23 ]
%34 = phi i32 [ 0, %4 ], [ %27, %23 ]
%35 = load i32, i32* @optind
%36 = add nsw i32 %35, -1
store i32 %36, i32* @optind
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i8*, i8** %38
%40 = tail call i32 @atoi(i8* %39)
%41 = add nsw i32 %35, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = icmp eq i32 %40, 0
br i1 %45, label %46, label %51
46: ; preds = %30, %46
%47 = phi i32 [ %49, %46 ], [ 0, %30 ]
%48 = tail call i32 @dolot(i32 %47, i8* %44, i32 %34, i32 %31, i32 %32, i8* %33)
%49 = add nuw nsw i32 %47, 1
%50 = icmp eq i32 %49, 10000
br i1 %50, label %53, label %46
51: ; preds = %30
%52 = tail call i32 @dolot(i32 %40, i8* %44, i32 %34, i32 %31, i32 %32, i8* %33)
br label %53
53: ; preds = %46, %51
ret i32 0
}