#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*/ isdigit(int /*<<< orphan*/);
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;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  while ((opt = getopt(argc, argv, "nt:")) != -1) {
    switch (opt) {
    case 'n':
      flags = 1;
      break;
    case 't':
      if (!isdigit(*optarg)) {
        fprintf(stderr, "lack digit param\n");
        break;
      }
      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)
cmpl   $0x2,-0x8(%rbp)
jge    11c1 <main+0x61>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11c6 <main+0x66>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4c(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     129b <main+0x13b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x6e,%eax
je     120a <main+0xaa>
jmp    11f9 <main+0x99>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
je     1216 <main+0xb6>
jmp    126a <main+0x10a>
movl   $0x1,-0x14(%rbp)
jmp    1296 <main+0x136>
mov    0x2ddb(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    124c <main+0xec>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1296 <main+0x136>
mov    0x2da5(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1296 <main+0x136>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11c6 <main+0x66>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    0x2d38(%rip),%rax
mov    (%rax),%ecx
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12ef <main+0x18f>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2ce6(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1254 <main+0x114>
mov    %edi,%ebp
lea    0xec0(%rip),%r12
mov    0x2e91(%rip),%r15
mov    0x2e62(%rip),%r14
lea    0xeaf(%rip),%r13
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
jmp    119d <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0x74,%eax
jne    11c5 <main+0x85>
mov    (%r15),%rax
mov    (%rax),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1190 <main+0x50>
movl   $0x1,(%rsp)
jmp    119d <main+0x5d>
cmp    $0x6e,%eax
jne    11d4 <main+0x94>
movl   $0x1,0x4(%rsp)
jmp    119d <main+0x5d>
cmp    $0xffffffff,%eax
jne    121f <main+0xdf>
mov    0x2e00(%rip),%r15
mov    (%r15),%ecx
lea    0xe4c(%rip),%rdi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq (%r15),%rax
cmp    %ebp,%eax
jge    1235 <main+0xf5>
mov    (%rbx,%rax,8),%rsi
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xdd4(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1246 <main+0x106>
mov    (%r14),%edi
lea    0xe15(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
jmp    1222 <main+0xe2>

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

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