#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int flags, opt;
  int nsecs, tfnd;
  nsecs = 0;
  tfnd = 0;
  flags = 0;
  while ((opt = getopt(argc, argv, "nt:")) != -1) {
    switch (opt) {
    case 'n':
      flags = 1;
      break;
    case 't':
      nsecs = atoi(optarg);
      tfnd = 1;
      break;
    default:
      fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  printf("flags=%d; tfnd=%d; optind=%d\n", flags, tfnd, optind);
  if (optind >= argc) {
    fprintf(stderr, "Expected argument after options\n");
    exit(EXIT_FAILURE);
  }
  printf("name argument = %s\n", argv[optind]);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe77(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1219 <main+0xc9>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x6e,%eax
je     11bf <main+0x6f>
jmp    11ae <main+0x5e>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
je     11cb <main+0x7b>
jmp    11e8 <main+0x98>
movl   $0x1,-0x14(%rbp)
jmp    1214 <main+0xc4>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1214 <main+0xc4>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    117b <main+0x2b>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    0x2dba(%rip),%rax
mov    (%rax),%ecx
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     126d <main+0x11d>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d68(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xe96(%rip),%r12
mov    0x2e87(%rip),%r13
xor    %ebx,%ebx
jmp    118e <main+0x3e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%edi
call   1060 <atoi@plt>
mov    $0x1,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0x74,%eax
je     1180 <main+0x30>
cmp    $0x6e,%eax
jne    11ad <main+0x5d>
mov    $0x1,%r14d
jmp    118e <main+0x3e>
cmp    $0xffffffff,%eax
jne    11f8 <main+0xa8>
mov    0x2e27(%rip),%r12
mov    (%r12),%ecx
lea    0xe60(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq (%r12),%rax
cmp    %ebp,%eax
jge    1214 <main+0xc4>
mov    (%r15,%rax,8),%rsi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    122b <main+0xdb>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"nt:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Usage: %s [-t nsecs] [-n] name\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"flags=%d; tfnd=%d; optind=%d\0A\00"
@optind = global i32 0
@.str.3 = [33 x i8] c"Expected argument after options\0A\00"
@.str.4 = [20 x i8] c"name argument = %s\0A\00"
@EXIT_SUCCESS = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %6
br label %10
10: ; preds = %29, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %7
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = load i32, i32* %7
switch i32 %16, label %21 [
i32 110, label %17
i32 116, label %18
]
17: ; preds = %15
store i32 1, i32* %6
br label %29
18: ; preds = %15
%19 = load i32, i32* @optarg
%20 = call i32 @atoi(i32 %19)
store i32 %20, i32* %8
store i32 1, i32* %9
br label %29
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %18, %17
br label %10
30: ; preds = %10
%31 = load i32, i32* %6
%32 = load i32, i32* %9
%33 = load i32, i32* @optind
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* @optind
%36 = load i32, i32* %4
%37 = icmp sge i32 %35, %36
br i1 %37, label %38, label %43
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %30
%44 = load i8**, i8*** %5
%45 = load i32, i32* @optind
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = load i32, i32* @EXIT_SUCCESS
%51 = call i32 @exit(i32 %50)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"nt:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Usage: %s [-t nsecs] [-n] name\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"flags=%d; tfnd=%d; optind=%d\0A\00"
@optind = global i32 0
@.str.3 = [33 x i8] c"Expected argument after options\0A\00"
@.str.4 = [20 x i8] c"name argument = %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i32 [ 0, %2 ], [ 1, %6 ]
%5 = phi i32 [ 0, %2 ], [ %7, %6 ]
br label %6
6: ; preds = %3, %9
%7 = phi i32 [ 1, %9 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %12 [
i32 -1, label %18
i32 110, label %3
i32 116, label %9
]
9: ; preds = %6
%10 = load i32, i32* @optarg
%11 = tail call i32 @atoi(i32 %10)
br label %6
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %6
%19 = load i32, i32* @optind
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %7, i32 %19)
%21 = load i32, i32* @optind
%22 = icmp slt i32 %21, %0
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %18
%29 = sext i32 %21 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_SUCCESS
%34 = tail call i32 @exit(i32 %33)
unreachable
}