#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 nflag, tflag;
  int opt;
  int nsecs;
  nsecs = 0;
  nflag = 0;
  tflag = 0;
  while ((opt = getopt(argc, argv, "nt:")) != -1) {
    switch (opt) {
    case 'n':
      nflag = 1;
      break;
    case 't':
      nsecs = atoi(optarg);
      tflag = 1;
      break;
    default:
      fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  printf("nflag=%d; tflag=%d; optind=%d\n", nflag, tflag, optind);
  if (tflag) {
    printf("nsecs=%d\n", nsecs);
  }
  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,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe77(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1219 <main+0xc9>
mov    -0x1c(%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,-0x20(%rbp)
movl   $0x1,-0x18(%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    -0x18(%rbp),%edx
mov    0x2dba(%rip),%rax
mov    (%rax),%ecx
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1251 <main+0x101>
mov    -0x20(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jle    1288 <main+0x138>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d4d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d11(%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,%r12
mov    %edi,%ebp
xor    %r15d,%r15d
mov    $0x1,%r14b
lea    0xe93(%rip),%r13
xor    %ebx,%ebx
movl   $0x0,0x4(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x6e,%eax
je     1190 <main+0x40>
cmp    $0x74,%eax
jne    11cb <main+0x7b>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    $0x1,%r15d
xor    %r14d,%r14d
jmp    1180 <main+0x30>
cmp    $0xffffffff,%eax
jne    1227 <main+0xd7>
mov    0x2e09(%rip),%r13
mov    0x0(%r13),%ecx
lea    0xe42(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x1,%r14b
jne    1206 <main+0xb6>
lea    0xe48(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0x0(%r13),%rax
cmp    %ebp,%eax
jle    1250 <main+0x100>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1242 <main+0xf2>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    (%r12,%rax,8),%rsi
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d57(%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 = [31 x i8] c"nflag=%d; tflag=%d; optind=%d\0A\00"
@optind = global i32 0
@.str.3 = [10 x i8] c"nsecs=%d\0A\00"
@.str.4 = [33 x i8] c"Expected argument after options\0A\00"
@.str.5 = [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* %9
store i32 0, i32* %6
store i32 0, i32* %7
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* %8
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = load i32, i32* %8
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* %9
store i32 1, i32* %7
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* %7
%33 = load i32, i32* @optind
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %30
%41 = load i32, i32* @optind
%42 = load i32, i32* %4
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = load i32, i32* @optind
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_SUCCESS
%57 = call i32 @exit(i32 %56)
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 = [31 x i8] c"nflag=%d; tflag=%d; optind=%d\0A\00"
@optind = global i32 0
@.str.3 = [10 x i8] c"nsecs=%d\0A\00"
@.str.4 = [33 x i8] c"Expected argument after options\0A\00"
@.str.5 = [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 = %11, %2
%4 = phi i1 [ false, %11 ], [ true, %2 ]
%5 = phi i32 [ 1, %11 ], [ 0, %2 ]
%6 = phi i32 [ %9, %11 ], [ 0, %2 ]
%7 = phi i32 [ %13, %11 ], [ 0, %2 ]
br label %8
8: ; preds = %3, %8
%9 = phi i32 [ 1, %8 ], [ %6, %3 ]
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %14 [
i32 -1, label %20
i32 110, label %8
i32 116, label %11
]
11: ; preds = %8
%12 = load i32, i32* @optarg
%13 = tail call i32 @atoi(i32 %12)
br label %3
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %8
%21 = load i32, i32* @optind
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %5, i32 %21)
br i1 %4, label %25, label %23
23: ; preds = %20
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %7)
br label %25
25: ; preds = %23, %20
%26 = load i32, i32* @optind
%27 = icmp sgt i32 %26, %0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %25
%34 = sext i32 %26 to i64
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_SUCCESS
%39 = tail call i32 @exit(i32 %38)
unreachable
}