#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*/ _test_sysio_shutdown();
int /*<<< orphan*/ do_tests(char *const);
int errno;
int /*<<< orphan*/ exit(int);
int getopt(int, char *const *, char *);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *const argv[]) {
  int i;
  int err;
  extern int _test_sysio_startup(void);
  while ((i = getopt(argc, argv, "")) != -1)
    switch (i) {
    default:
      usage();
    }
  err = _test_sysio_startup();
  if (err) {
    errno = -err;
    perror("sysio startup");
    exit(1);
  }
  while (optind < argc)
    do_tests(argv[optind++]);
  _test_sysio_shutdown();
  return 0;
}


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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11b1 <main+0x41>
mov    $0x0,%al
call   1040 <usage@plt>
jmp    1186 <main+0x16>
call   1050 <_test_sysio_startup@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11e7 <main+0x77>
xor    %ecx,%ecx
sub    -0x18(%rbp),%ecx
mov    0x2e09(%rip),%rax
mov    %ecx,(%rax)
lea    0xe28(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11ec <main+0x7c>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    122a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x2ddf(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2dd1(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <do_tests@plt>
jmp    11ec <main+0x7c>
mov    $0x0,%al
call   1030 <_test_sysio_shutdown@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe8d(%rip),%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     11b9 <main+0x49>
lea    0xe7c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11a0 <main+0x30>
call   1050 <_test_sysio_startup@plt>
test   %eax,%eax
jne    11f8 <main+0x88>
mov    0x2e1f(%rip),%r14
nopl   0x0(%rax)
mov    (%r14),%eax
cmp    %ebp,%eax
jge    11ea <main+0x7a>
lea    0x1(%rax),%ecx
mov    %ecx,(%r14)
cltq
mov    (%rbx,%rax,8),%rdi
call   1080 <do_tests@plt>
jmp    11d0 <main+0x60>
xor    %eax,%eax
call   1030 <_test_sysio_shutdown@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
neg    %eax
mov    0x2dd7(%rip),%rcx
mov    %eax,(%rcx)
lea    0xdf6(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@errno = global i32 0
@.str.1 = [14 x i8] c"sysio startup\00"
@optind = 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %15 [
]
15: ; preds = %13
%16 = call i32 (...) @usage()
br label %17
17: ; preds = %15
br label %8
18: ; preds = %8
%19 = call i32 @_test_sysio_startup()
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i32, i32* %7
%24 = sub nsw i32 0, %23
store i32 %24, i32* @errno
%25 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %18
br label %28
28: ; preds = %32, %27
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = load i32, i32* @optind
%35 = add nsw i32 %34, 1
store i32 %35, i32* @optind
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @do_tests(i8* %38)
br label %28
40: ; preds = %28
%41 = call i32 (...) @_test_sysio_shutdown()
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@errno = global i32 0
@.str.1 = [14 x i8] c"sysio startup\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %9, label %5
5: ; preds = %2, %5
%6 = tail call i32 (...) @usage()
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %5
9: ; preds = %5, %2
%10 = tail call i32 @_test_sysio_startup()
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @optind
%14 = icmp slt i32 %13, %0
br i1 %14, label %19, label %28
15: ; preds = %9
%16 = sub nsw i32 0, %10
store i32 %16, i32* @errno
%17 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %12, %19
%20 = phi i32 [ %26, %19 ], [ %13, %12 ]
%21 = add nsw i32 %20, 1
store i32 %21, i32* @optind
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 @do_tests(i8* %24)
%26 = load i32, i32* @optind
%27 = icmp slt i32 %26, %0
br i1 %27, label %19, label %28
28: ; preds = %19, %12
%29 = tail call i32 (...) @_test_sysio_shutdown()
ret i32 0
}