#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ factorKey(unsigned long, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
scalar_t__ opterr;
int optind;
int optopt;
int /*<<< orphan*/ printUse(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  bool flagSteps = false;
  opterr = 0;
  printf("optind = %i\n", optind);
  int arg = getopt(argc, argv, "s:");
  while (arg != -1) {
    switch (arg) {
    case 's':
      flagSteps = true;
      break;
    default:
      fprintf(stderr, "Argument found: %i.\n", optopt);
      printUse(argv[0]);
      exit(1);
    }
    arg = getopt(argc, argv, "s:");
  }
  printf("arg = %i; optind = %i\n", argc, optind);
  if (optind == 1 && optind >= argc) {
    printUse(argv[0]);
    exit(1);
  }
  unsigned long key = strtoul(argv[argc - 1], NULL, 10);
  fprintf(stdout, "Key = %lu\n", key);
  if (key == 1) {
    exit(EXIT_SUCCESS);
  }
  fprintf(stdout, "\\begin{align*}\n%lu%%\n", key);
  factorKey(key, flagSteps);
  fprintf(stdout, "\\end{align*}\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e34(%rip),%rax
movq   $0x0,(%rax)
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe40(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     1240 <main+0xd0>
mov    -0x18(%rbp),%eax
sub    $0x73,%eax
jne    11ef <main+0x7f>
jmp    11e3 <main+0x73>
movl   $0x1,-0x14(%rbp)
jmp    1225 <main+0xb5>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    0x2de9(%rip),%rax
mov    (%rax),%edx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <printUse@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdcd(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x18(%rbp)
jmp    11c8 <main+0x58>
mov    -0x8(%rbp),%esi
mov    0x2d96(%rip),%rax
mov    (%rax),%edx
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d7f(%rip),%rax
cmpl   $0x1,(%rax)
jne    1292 <main+0x122>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1292 <main+0x122>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <printUse@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpq   $0x1,-0x20(%rbp)
jne    12e9 <main+0x179>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <factorKey@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r13d
mov    0x2e40(%rip),%rax
movq   $0x0,(%rax)
mov    0x2e4a(%rip),%r12
mov    (%r12),%esi
lea    0xe81(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ebp
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
mov    $0x1,%ebx
cmp    $0x73,%eax
je     11c0 <main+0x50>
cmp    $0xffffffff,%eax
jne    127e <main+0x10e>
mov    (%r12),%edx
lea    0xe2a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%r13d
jg     1209 <main+0x99>
cmpl   $0x1,(%r12)
je     129e <main+0x12e>
movslq %r13d,%rax
mov    -0x8(%r14,%rax,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,%rbx
mov    0x2d99(%rip),%r14
mov    (%r14),%edi
lea    0xdfe(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1,%rbx
je     1270 <main+0x100>
mov    (%r14),%edi
lea    0xdef(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <factorKey@plt>
mov    (%r14),%edi
lea    0xde7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x2d5a(%rip),%rax
mov    (%rax),%edx
lea    0xd6c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%rdi
call   1070 <printUse@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [13 x i8] c"optind = %i\0A\00"
@optind = global i32 0
@.str.1 = [3 x i8] c"s:\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"Argument found: %i.\0A\00"
@optopt = global i32 0
@.str.3 = [23 x i8] c"arg = %i; optind = %i\0A\00"
@stdout = global i32 0
@.str.4 = [11 x i8] c"Key = %lu\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.5 = [22 x i8] c"\\begin{align*}\0A%lu%%\0A\00"
@.str.6 = [14 x i8] c"\\end{align*}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i64 0, i64* @opterr
%9 = load i32, i32* @optind
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %13, i32* %7
br label %14
14: ; preds = %29, %2
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i32, i32* %7
switch i32 %18, label %20 [
i32 115, label %19
]
19: ; preds = %17
store i32 1, i32* %6
br label %29
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i32, i32* @optopt
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @printUse(i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @getopt(i32 %30, i8** %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %32, i32* %7
br label %14
33: ; preds = %14
%34 = load i32, i32* %4
%35 = load i32, i32* @optind
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32, i32* @optind
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %49
39: ; preds = %33
%40 = load i32, i32* @optind
%41 = load i32, i32* %4
%42 = icmp sge i32 %40, %41
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 @printUse(i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %39, %33
%50 = load i8**, i8*** %5
%51 = load i32, i32* %4
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %50, i64 %53
%55 = load i8*, i8** %54
%56 = call i64 @strtoul(i8* %55, i32* null, i32 10)
store i64 %56, i64* %8
%57 = load i32, i32* @stdout
%58 = load i64, i64* %8
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %58)
%60 = load i64, i64* %8
%61 = icmp eq i64 %60, 1
br i1 %61, label %62, label %65
62: ; preds = %49
%63 = load i32, i32* @EXIT_SUCCESS
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %49
%66 = load i32, i32* @stdout
%67 = load i64, i64* %8
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %67)
%69 = load i64, i64* %8
%70 = load i32, i32* %6
%71 = call i32 @factorKey(i64 %69, i32 %70)
%72 = load i32, i32* @stdout
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%74 = load i32, i32* @EXIT_SUCCESS
%75 = call i32 @exit(i32 %74)
unreachable
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [13 x i8] c"optind = %i\0A\00"
@optind = global i32 0
@.str.1 = [3 x i8] c"s:\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"Argument found: %i.\0A\00"
@optopt = global i32 0
@.str.3 = [23 x i8] c"arg = %i; optind = %i\0A\00"
@stdout = global i32 0
@.str.4 = [11 x i8] c"Key = %lu\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.5 = [22 x i8] c"\\begin{align*}\0A%lu%%\0A\00"
@.str.6 = [14 x i8] c"\\end{align*}\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
%3 = load i32, i32* @optind
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %5
5: ; preds = %5, %2
%6 = phi i32 [ 0, %2 ], [ 1, %5 ]
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
switch i32 %7, label %8 [
i32 -1, label %15
i32 115, label %5
]
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = load i32, i32* @optopt
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i8*, i8** %1
%13 = tail call i32 @printUse(i8* %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %5
%16 = load i32, i32* @optind
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32 %16)
%18 = load i32, i32* @optind
%19 = icmp eq i32 %18, 1
%20 = icmp slt i32 %0, 2
%21 = and i1 %20, %19
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i8*, i8** %1
%24 = tail call i32 @printUse(i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %15
%27 = add nsw i32 %0, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i64 @strtoul(i8* nocapture %30, i32* null, i32 10)
%32 = load i32, i32* @stdout
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %31)
%34 = icmp eq i64 %31, 1
br i1 %34, label %35, label %38
35: ; preds = %26
%36 = load i32, i32* @EXIT_SUCCESS
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %26
%39 = load i32, i32* @stdout
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %31)
%41 = tail call i32 @factorKey(i64 %31, i32 %6)
%42 = load i32, i32* @stdout
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* @EXIT_SUCCESS
%45 = tail call i32 @exit(i32 %44)
unreachable
}