#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ _test_sysio_shutdown();
int _test_sysio_startup();
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
int testit(char const *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int err;
  int i;
  int n;
  const char *path;
  while ((i = getopt(argc, argv, "")) != -1)
    switch (i) {
    default:
      usage();
    }
  err = _test_sysio_startup();
  if (err) {
    errno = -err;
    perror("sysio startup");
    exit(1);
  }
  n = argc - optind;
  if (!n) {
    int doflush;
    static char buf[4096];
    size_t len;
    char *cp;
    char c;
    doflush = 0;
    while (fgets(buf, sizeof(buf), stdin) != NULL) {
      len = strlen(buf);
      cp = buf + len - 1;
      c = *cp;
      *cp = '\0';
      if (!doflush)
        err = testit(buf);
      if (err)
        break;
      doflush = c == '\n' ? 0 : 1;
    }
  }
  while (optind < argc) {
    path = argv[optind++];
    err = testit(path);
    if (err)
      break;
  }
  _test_sysio_shutdown();
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11d1 <main+0x41>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   1080 <_test_sysio_startup@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1209 <main+0x79>
xor    %ecx,%ecx
sub    -0x14(%rbp),%ecx
mov    0x2ddf(%rip),%rax
mov    %ecx,(%rax)
lea    0xe06(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2dcd(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12c6 <main+0x136>
movl   $0x0,-0x2c(%rbp)
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
lea    0x2e57(%rip),%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12c1 <main+0x131>
lea    0x2e3c(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
lea    0x2e2c(%rip),%rax
add    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x41(%rbp)
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x0,-0x2c(%rbp)
jne    1299 <main+0x109>
lea    0x2dff(%rip),%rdi
call   1060 <testit@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12a8 <main+0x118>
jmp    12c1 <main+0x131>
movsbl -0x41(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0xa,%edx
cmove  %ecx,%eax
mov    %eax,-0x2c(%rbp)
jmp    1229 <main+0x99>
jmp    12c6 <main+0x136>
jmp    12cb <main+0x13b>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1323 <main+0x193>
mov    -0x10(%rbp),%rax
mov    0x2cf8(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2cea(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <testit@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     131e <main+0x18e>
jmp    1323 <main+0x193>
jmp    12cb <main+0x13b>
mov    $0x0,%al
call   1030 <_test_sysio_shutdown@plt>
mov    -0x14(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0xe65(%rip),%rdx
call   10a0 <getopt@plt>
cmp    $0xffffffff,%eax
je     11da <main+0x4a>
lea    0xe54(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <usage@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10a0 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11c0 <main+0x30>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <_test_sysio_startup@plt>
test   %eax,%eax
jne    12bd <main+0x12d>
mov    0x2dee(%rip),%r12
cmp    %r15d,(%r12)
jne    126d <main+0xdd>
mov    0x2de9(%rip),%rax
mov    (%rax),%edx
lea    0x2e88(%rip),%rbp
mov    %rbp,%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     126d <main+0xdd>
xor    %ebx,%ebx
jmp    1244 <main+0xb4>
xchg   %ax,%ax
xor    %ebx,%ebx
cmp    $0xa,%r13b
setne  %bl
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     126b <main+0xdb>
mov    %rbp,%rdi
call   1040 <strlen@plt>
movzbl -0x1(%rax,%rbp,1),%r13d
movb   $0x0,-0x1(%rax,%rbp,1)
test   %ebx,%ebx
jne    1220 <main+0x90>
mov    %rbp,%rdi
call   1060 <testit@plt>
test   %eax,%eax
je     1220 <main+0x90>
mov    %eax,%ebx
jmp    126d <main+0xdd>
xor    %ebx,%ebx
mov    (%r12),%eax
cmp    %r15d,%eax
jge    12a5 <main+0x115>
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rax),%ecx
mov    %ecx,(%r12)
cltq
mov    (%r14,%rax,8),%rdi
call   1060 <testit@plt>
test   %eax,%eax
jne    12a3 <main+0x113>
mov    (%r12),%eax
cmp    %r15d,%eax
jl     1280 <main+0xf0>
xor    %ebx,%ebx
jmp    12a5 <main+0x115>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <_test_sysio_shutdown@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %eax
mov    0x2d0a(%rip),%rcx
mov    %eax,(%rcx)
lea    0xd31(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10b0 <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
@main.buf = internal global [4096 x i8] zeroinitializer
@stdin = 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 i8*
%10 = alloca i32
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %14
14: ; preds = %23, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %7
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* %7
switch i32 %20, label %21 [
]
21: ; preds = %19
%22 = call i32 (...) @usage()
br label %23
23: ; preds = %21
br label %14
24: ; preds = %14
%25 = call i32 (...) @_test_sysio_startup()
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* %6
%30 = sub nsw i32 0, %29
store i32 %30, i32* @errno
%31 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %24
%34 = load i32, i32* %4
%35 = load i32, i32* @optind
%36 = sub nsw i32 %34, %35
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = icmp ne i32 %37, 0
br i1 %38, label %67, label %39
39: ; preds = %33
store i32 0, i32* %10
br label %40
40: ; preds = %60, %39
%41 = load i32, i32* @stdin
%42 = call i32* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i32 4096, i32 %41)
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %66
44: ; preds = %40
%45 = call i64 @strlen(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0))
store i64 %45, i64* %11
%46 = load i64, i64* %11
%47 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i64 %46
%48 = getelementptr inbounds i8, i8* %47, i64 -1
store i8* %48, i8** %12
%49 = load i8*, i8** %12
%50 = load i8, i8* %49
store i8 %50, i8* %13
%51 = load i8*, i8** %12
store i8 0, i8* %51
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %44
%55 = call i32 @testit(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0))
store i32 %55, i32* %6
br label %56
56: ; preds = %54, %44
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %56
br label %66
60: ; preds = %56
%61 = load i8, i8* %13
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 10
%64 = zext i1 %63 to i64
%65 = select i1 %63, i32 0, i32 1
store i32 %65, i32* %10
br label %40
66: ; preds = %59, %40
br label %67
67: ; preds = %66, %33
br label %68
68: ; preds = %84, %67
%69 = load i32, i32* @optind
%70 = load i32, i32* %4
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %85
72: ; preds = %68
%73 = load i8**, i8*** %5
%74 = load i32, i32* @optind
%75 = add nsw i32 %74, 1
store i32 %75, i32* @optind
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8*, i8** %73, i64 %76
%78 = load i8*, i8** %77
store i8* %78, i8** %9
%79 = load i8*, i8** %9
%80 = call i32 @testit(i8* %79)
store i32 %80, i32* %6
%81 = load i32, i32* %6
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %72
br label %85
84: ; preds = %72
br label %68
85: ; preds = %83, %68
%86 = call i32 (...) @_test_sysio_shutdown()
%87 = load i32, i32* %6
ret i32 %87
}

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
@main.buf = internal global [4096 x i8] zeroinitializer
@stdin = 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 = load i32, i32* @optind
%18 = icmp eq i32 %17, %0
br i1 %18, label %19, label %39
19: ; preds = %16
%20 = load i32, i32* @stdin
%21 = tail call i32* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i32 4096, i32 %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %39, label %23
23: ; preds = %19, %33
%24 = phi i32 [ %35, %33 ], [ 0, %19 ]
%25 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0))
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -1
%28 = load i8, i8* %27
store i8 0, i8* %27
%29 = icmp eq i32 %24, 0
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = tail call i32 @testit(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %23, %30
%34 = icmp ne i8 %28, 10
%35 = zext i1 %34 to i32
%36 = load i32, i32* @stdin
%37 = tail call i32* @fgets(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i32 4096, i32 %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %23
39: ; preds = %30, %33, %19, %16
%40 = phi i32 [ 0, %16 ], [ 0, %19 ], [ %31, %30 ], [ 0, %33 ]
%41 = load i32, i32* @optind
%42 = icmp slt i32 %41, %0
br i1 %42, label %46, label %54
43: ; preds = %46
%44 = load i32, i32* @optind
%45 = icmp slt i32 %44, %0
br i1 %45, label %46, label %54
46: ; preds = %39, %43
%47 = phi i32 [ %44, %43 ], [ %41, %39 ]
%48 = add nsw i32 %47, 1
store i32 %48, i32* @optind
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = tail call i32 @testit(i8* %51)
%53 = icmp eq i32 %52, 0
br i1 %53, label %43, label %54
54: ; preds = %43, %46, %39
%55 = phi i32 [ %40, %39 ], [ %52, %46 ], [ 0, %43 ]
%56 = tail call i32 (...) @_test_sysio_shutdown()
ret i32 %55
}