#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int opterr;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int opt;
  int nsecs, tfnd, flags;
  nsecs = tfnd = flags = opterr = 0;
  while ((opt = getopt(argc, argv, "nt:")) != -1) {
    switch (opt) {
    case 'n':
      flags = 1;
      break;
    case 't':
      nsecs = strtol(optarg, NULL, 10);
      tfnd = 1;
      break;
    case '?':
      fprintf(stderr, "Option '%s' unknow\n", argv[optind - 1]);
      break;
    default:
      fprintf(stderr, "Usage: %s [-s nsecs] [-m] 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)
mov    0x2e53(%rip),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6a(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1273 <main+0x123>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     120f <main+0xbf>
jmp    11bb <main+0x6b>
mov    -0x24(%rbp),%eax
sub    $0x6e,%eax
je     11dd <main+0x8d>
jmp    11cc <main+0x7c>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
je     11e9 <main+0x99>
jmp    1242 <main+0xf2>
movl   $0x1,-0x20(%rbp)
jmp    126e <main+0x11e>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    126e <main+0x11e>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2dbd(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    126e <main+0x11e>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1188 <main+0x38>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2d60(%rip),%rax
mov    (%rax),%ecx
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12c7 <main+0x177>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d0e(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cca(%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,%rbx
mov    %edi,%ebp
mov    0x2e59(%rip),%rax
movl   $0x0,(%rax)
lea    0xe8c(%rip),%r15
mov    0x2e55(%rip),%r14
mov    0x2e5e(%rip),%r13
lea    0xe7b(%rip),%r12
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
jmp    11b6 <main+0x66>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
movslq 0x0(%r13),%rax
mov    -0x8(%rbx,%rax,8),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x3f,%eax
je     11a0 <main+0x50>
cmp    $0x6e,%eax
je     11f0 <main+0xa0>
cmp    $0x74,%eax
jne    11fa <main+0xaa>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
movl   $0x1,(%rsp)
jmp    11b6 <main+0x66>
movl   $0x1,0x4(%rsp)
jmp    11b6 <main+0x66>
cmp    $0xffffffff,%eax
jne    1240 <main+0xf0>
mov    0x0(%r13),%ecx
lea    0xe2e(%rip),%rdi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0x0(%r13),%rax
cmp    %ebp,%eax
jge    1256 <main+0x106>
mov    (%rbx,%rax,8),%rsi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xdcb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1267 <main+0x117>
mov    (%r14),%edi
lea    0xdfc(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

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

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