#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_stats(char *const);
int errno;
int /*<<< orphan*/ exit(int);
int getopt(int, char *const *, char *);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ umask(int);
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);
  }
  (void)umask(022);
  while (optind < argc)
    do_stats(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    0xe69(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11c1 <main+0x41>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1196 <main+0x16>
call   1070 <_test_sysio_startup@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11f7 <main+0x77>
xor    %ecx,%ecx
sub    -0x18(%rbp),%ecx
mov    0x2df9(%rip),%rax
mov    %ecx,(%rax)
lea    0xe18(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x12,%edi
call   1050 <umask@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    123f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x2dca(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2dbc(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <do_stats@plt>
jmp    1201 <main+0x81>
mov    $0x0,%al
call   1040 <_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    0xe7d(%rip),%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
je     11c9 <main+0x49>
lea    0xe6c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x30>
call   1070 <_test_sysio_startup@plt>
test   %eax,%eax
jne    1218 <main+0x98>
mov    $0x12,%edi
call   1050 <umask@plt>
mov    0x2e05(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%eax
cmp    %ebp,%eax
jge    120a <main+0x8a>
lea    0x1(%rax),%ecx
mov    %ecx,(%r14)
cltq
mov    (%rbx,%rax,8),%rdi
call   1030 <do_stats@plt>
jmp    11f0 <main+0x70>
xor    %eax,%eax
call   1040 <_test_sysio_shutdown@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
neg    %eax
mov    0x2db7(%rip),%rcx
mov    %eax,(%rcx)
lea    0xdd6(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <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
%28 = call i32 @umask(i32 18)
br label %29
29: ; preds = %33, %27
%30 = load i32, i32* @optind
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* @optind
%36 = add nsw i32 %35, 1
store i32 %36, i32* @optind
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @do_stats(i8* %39)
br label %29
41: ; preds = %29
%42 = 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 %16, label %12
12: ; preds = %9
%13 = sub nsw i32 0, %10
store i32 %13, i32* @errno
%14 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = tail call i32 @umask(i32 18)
%18 = load i32, i32* @optind
%19 = icmp slt i32 %18, %0
br i1 %19, label %20, label %29
20: ; preds = %16, %20
%21 = phi i32 [ %27, %20 ], [ %18, %16 ]
%22 = add nsw i32 %21, 1
store i32 %22, i32* @optind
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = tail call i32 @do_stats(i8* %25)
%27 = load i32, i32* @optind
%28 = icmp slt i32 %27, %0
br i1 %28, label %20, label %29
29: ; preds = %20, %16
%30 = tail call i32 (...) @_test_sysio_shutdown()
ret i32 0
}