#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 */
typedef scalar_t__ u_int;

/* Variables and functions */
int UINT_MAX;
int /*<<< orphan*/ errx(int, char *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ explicit_bzero(unsigned char *, size_t);
int /*<<< orphan*/ generate(unsigned char *, size_t);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
scalar_t__ optind;
int /*<<< orphan*/ printpass(unsigned char *, size_t);
int /*<<< orphan*/ sandbox_post();
int /*<<< orphan*/ sandbox_pre();
void *strtonum(int /*<<< orphan*/, int, int, char const **);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int c;
  const char *errstr;
  sandbox_pre();
  size_t length = 13;
  u_int passnum = 1;
  while ((c = getopt(argc, argv, "l:n:")) != -1) {
    switch (c) {
    case 'l':
      length = strtonum(optarg, 13, 50, &errstr);
      if (errstr) {
        errx(1, "length is %s: %s", errstr, optarg);
      }
      break;
    case 'n':
      passnum = strtonum(optarg, 1, UINT_MAX, &errstr);
      if (errstr) {
        errx(1, "passnum is %s: %s", errstr, optarg);
      }
      break;
    default:
      usage();
      break;
    }
  }
  argc -= optind;
  argv += optind;
  if (argc > 1) {
    usage();
  }
  sandbox_post();
  unsigned char p[length];
  for (u_int i = 0; i < passnum; i++) {
    generate(p, length);
    printpass(p, length);
    explicit_bzero(p, length);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <sandbox_pre@plt>
movq   $0xd,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe35(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12ad <main+0x11d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x6c,%eax
je     1201 <main+0x71>
jmp    11f0 <main+0x60>
mov    -0x4c(%rbp),%eax
sub    $0x6e,%eax
je     124f <main+0xbf>
jmp    12a1 <main+0x111>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    $0xd,%esi
mov    $0x32,%edx
lea    -0x20(%rbp),%rcx
call   1060 <strtonum@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     124a <main+0xba>
mov    -0x20(%rbp),%rdx
mov    0x2dc1(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edi
lea    0xdc0(%rip),%rsi
call   1040 <errx@plt>
jmp    12a8 <main+0x118>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
lea    -0x20(%rbp),%rcx
call   1060 <strtonum@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     129c <main+0x10c>
mov    -0x20(%rbp),%rdx
mov    0x2d6f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edi
lea    0xd7f(%rip),%rsi
call   1040 <errx@plt>
jmp    12a8 <main+0x118>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    11bd <main+0x2d>
mov    0x2d24(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d10(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12e8 <main+0x158>
mov    $0x0,%al
call   1070 <usage@plt>
xor    %eax,%eax
call   1050 <sandbox_post@plt>
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    1364 <main+0x1d4>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <generate@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <printpass@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <explicit_bzero@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    131e <main+0x18e>
movl   $0x0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r15d
xor    %eax,%eax
call   10b0 <sandbox_pre@plt>
mov    $0x1,%r13d
mov    $0xd,%r14d
lea    0xe42(%rip),%rbx
xchg   %ax,%ax
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <getopt@plt>
cmp    $0xffffffff,%eax
je     127d <main+0xed>
cmp    $0x6e,%eax
je     11ea <main+0x5a>
cmp    $0x6c,%eax
je     1232 <main+0xa2>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    11c0 <main+0x30>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
lea    -0x30(%rbp),%rcx
call   1060 <strtonum@plt>
mov    %rax,%r13
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
je     11c0 <main+0x30>
mov    0x2ddb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edi
lea    0xdeb(%rip),%rsi
call   1040 <errx@plt>
jmp    11c0 <main+0x30>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    $0xd,%esi
mov    $0x32,%edx
lea    -0x30(%rbp),%rcx
call   1060 <strtonum@plt>
mov    %rax,%r14
mov    -0x30(%rbp),%rdx
test   %rdx,%rdx
je     11c0 <main+0x30>
mov    0x2d93(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edi
lea    0xd92(%rip),%rsi
call   1040 <errx@plt>
jmp    11c0 <main+0x30>
mov    0x2d54(%rip),%rax
sub    (%rax),%r15d
cmp    $0x2,%r15d
jl     1294 <main+0x104>
xor    %eax,%eax
call   1070 <usage@plt>
xor    %eax,%eax
call   1050 <sandbox_post@plt>
mov    %rsp,%r15
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
test   %r13,%r13
jle    12e7 <main+0x157>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <generate@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printpass@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <explicit_bzero@plt>
add    $0xffffffffffffffff,%r13
jne    12c0 <main+0x130>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"l:n:\00"
@optarg = global i32 0
@.str.1 = [17 x i8] c"length is %s: %s\00"
@UINT_MAX = global i32 0
@.str.2 = [18 x i8] c"passnum is %s: %s\00"
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (...) @sandbox_pre()
store i64 13, i64* %8
store i64 1, i64* %9
br label %14
14: ; preds = %46, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %6
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %47
19: ; preds = %14
%20 = load i32, i32* %6
switch i32 %20, label %44 [
i32 108, label %21
i32 110, label %32
]
21: ; preds = %19
%22 = load i32, i32* @optarg
%23 = call i8* @strtonum(i32 %22, i32 13, i32 50, i8** %7)
%24 = ptrtoint i8* %23 to i64
store i64 %24, i64* %8
%25 = load i8*, i8** %7
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i8*, i8** %7
%29 = load i32, i32* @optarg
%30 = call i32 @errx(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %28, i32 %29)
br label %31
31: ; preds = %27, %21
br label %46
32: ; preds = %19
%33 = load i32, i32* @optarg
%34 = load i32, i32* @UINT_MAX
%35 = call i8* @strtonum(i32 %33, i32 1, i32 %34, i8** %7)
%36 = ptrtoint i8* %35 to i64
store i64 %36, i64* %9
%37 = load i8*, i8** %7
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %32
%40 = load i8*, i8** %7
%41 = load i32, i32* @optarg
%42 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32 %41)
br label %43
43: ; preds = %39, %32
br label %46
44: ; preds = %19
%45 = call i32 (...) @usage()
br label %46
46: ; preds = %44, %43, %31
br label %14
47: ; preds = %14
%48 = load i64, i64* @optind
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = sub nsw i64 %50, %48
%52 = trunc i64 %51 to i32
store i32 %52, i32* %4
%53 = load i64, i64* @optind
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 %53
store i8** %55, i8*** %5
%56 = load i32, i32* %4
%57 = icmp sgt i32 %56, 1
br i1 %57, label %58, label %60
58: ; preds = %47
%59 = call i32 (...) @usage()
br label %60
60: ; preds = %58, %47
%61 = call i32 (...) @sandbox_post()
%62 = load i64, i64* %8
%63 = call i8* @llvm.stacksave()
store i8* %63, i8** %10
%64 = alloca i8, i64 %62
store i64 %62, i64* %11
store i64 0, i64* %12
br label %65
65: ; preds = %76, %60
%66 = load i64, i64* %12
%67 = load i64, i64* %9
%68 = icmp slt i64 %66, %67
br i1 %68, label %69, label %79
69: ; preds = %65
%70 = load i64, i64* %8
%71 = call i32 @generate(i8* %64, i64 %70)
%72 = load i64, i64* %8
%73 = call i32 @printpass(i8* %64, i64 %72)
%74 = load i64, i64* %8
%75 = call i32 @explicit_bzero(i8* %64, i64 %74)
br label %76
76: ; preds = %69
%77 = load i64, i64* %12
%78 = add nsw i64 %77, 1
store i64 %78, i64* %12
br label %65
79: ; preds = %65
store i32 0, i32* %3
%80 = load i8*, i8** %10
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str = [5 x i8] c"l:n:\00"
@optarg = global i32 0
@.str.1 = [17 x i8] c"length is %s: %s\00"
@UINT_MAX = global i32 0
@.str.2 = [18 x i8] c"passnum is %s: %s\00"
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i32 (...) @sandbox_pre()
br label %6
6: ; preds = %22, %2
%7 = phi i64 [ 13, %2 ], [ %16, %22 ]
%8 = phi i64 [ 1, %2 ], [ %10, %22 ]
br label %9
9: ; preds = %33, %6
%10 = phi i64 [ %8, %6 ], [ %27, %33 ]
br label %11
11: ; preds = %9, %34
%12 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %34 [
i32 -1, label %36
i32 108, label %13
i32 110, label %23
]
13: ; preds = %11
%14 = load i32, i32* @optarg
%15 = call i8* @strtonum(i32 %14, i32 13, i32 50, i8** %3)
%16 = ptrtoint i8* %15 to i64
%17 = load i8*, i8** %3
%18 = icmp eq i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = load i32, i32* @optarg
%21 = call i32 @errx(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %20)
br label %22
22: ; preds = %19, %13
br label %6
23: ; preds = %11
%24 = load i32, i32* @optarg
%25 = load i32, i32* @UINT_MAX
%26 = call i8* @strtonum(i32 %24, i32 1, i32 %25, i8** %3)
%27 = ptrtoint i8* %26 to i64
%28 = load i8*, i8** %3
%29 = icmp eq i8* %28, null
br i1 %29, label %33, label %30
30: ; preds = %23
%31 = load i32, i32* @optarg
%32 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %28, i32 %31)
br label %33
33: ; preds = %30, %23
br label %9
34: ; preds = %11
%35 = call i32 (...) @usage()
br label %11
36: ; preds = %11
%37 = load i64, i64* @optind
%38 = trunc i64 %37 to i32
%39 = sub i32 %0, %38
%40 = icmp sgt i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (...) @usage()
br label %43
43: ; preds = %41, %36
%44 = call i32 (...) @sandbox_post()
%45 = call i8* @llvm.stacksave()
%46 = alloca i8, i64 %7
%47 = icmp sgt i64 %10, 0
br i1 %47, label %49, label %48
48: ; preds = %49, %43
ret i32 0
49: ; preds = %43, %49
%50 = phi i64 [ %54, %49 ], [ 0, %43 ]
%51 = call i32 @generate(i8* %46, i64 %7)
%52 = call i32 @printpass(i8* %46, i64 %7)
%53 = call i32 @explicit_bzero(i8* %46, i64 %7)
%54 = add nuw nsw i64 %50, 1
%55 = icmp eq i64 %54, %10
br i1 %55, label %48, label %49
}