#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 mode_t;
typedef scalar_t__ dev_t;

/* Variables and functions */
int S_IFBLK;
int S_IFCHR;
int S_IFIFO;
int S_IFREG;
scalar_t__ S_ISFIFO(int);
scalar_t__ S_ISREG(int);
int /*<<< orphan*/ _test_sysio_shutdown();
scalar_t__ atoi(char *const);
int /*<<< orphan*/ do_mknod(char *const, int, scalar_t__);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char *const *, char *);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int strlen(char *const);
int /*<<< orphan*/ usage();
int main(int argc, char *const argv[]) {
  int i;
  int err;
  mode_t mode;
  dev_t dev;
  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);
  }
  if (argc - optind < 2)
    usage();
  if (strlen(argv[optind + 1]) != 1)
    usage();
  mode = 0666;
  switch (*argv[optind + 1]) {
  case 'f':
    mode |= S_IFREG;
    break;
  case 'b':
    mode |= S_IFBLK;
    break;
  case 'c':
    mode |= S_IFCHR;
    break;
  case 'p':
    mode |= S_IFIFO;
    break;
  default:
    usage();
  }
  dev = 0;
  if (!(S_ISREG(mode) || S_ISFIFO(mode)))
    dev = atoi(argv[optind + 2]);
  else if (argc - optind != 2) {
    (void)fprintf(stderr, "Too many arguments\n");
    usage();
  }
  (void)do_mknod(argv[optind + 0], mode, dev);
  _test_sysio_shutdown();
  return 0;
}


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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1201 <main+0x41>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    11d6 <main+0x16>
call   10a0 <_test_sysio_startup@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1237 <main+0x77>
xor    %ecx,%ecx
sub    -0x18(%rbp),%ecx
mov    0x2d99(%rip),%rax
mov    %ecx,(%rax)
lea    0xe14(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2d9f(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jge    1253 <main+0x93>
mov    $0x0,%al
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d82(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
je     127f <main+0xbf>
mov    $0x0,%al
call   1090 <usage@plt>
movl   $0x1b6,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2d4f(%rip),%rcx
movslq (%rcx),%rcx
mov    0x8(%rax,%rcx,8),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xe,%eax
ja     1312 <main+0x152>
mov    -0x30(%rbp),%rax
lea    0xd47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1319 <main+0x159>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1319 <main+0x159>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1319 <main+0x159>
mov    0x2cab(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1319 <main+0x159>
mov    $0x0,%al
call   1090 <usage@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <S_ISREG@plt>
cmp    $0x0,%rax
jne    136a <main+0x1aa>
mov    -0x1c(%rbp),%edi
call   1050 <S_ISFIFO@plt>
cmp    $0x0,%rax
jne    136a <main+0x1aa>
mov    -0x10(%rbp),%rax
mov    0x2c90(%rip),%rcx
mov    (%rcx),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x28(%rbp)
jmp    13a0 <main+0x1e0>
mov    -0x8(%rbp),%eax
mov    0x2c6c(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
je     139b <main+0x1db>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
lea    0xcbb(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    13a0 <main+0x1e0>
mov    -0x10(%rbp),%rax
mov    0x2c35(%rip),%rcx
mov    (%rcx),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1060 <do_mknod@plt>
mov    $0x0,%al
call   1030 <_test_sysio_shutdown@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xe89(%rip),%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1209 <main+0x49>
lea    0xe78(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <usage@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11f0 <main+0x30>
call   10a0 <_test_sysio_startup@plt>
test   %eax,%eax
jne    132d <main+0x16d>
mov    0x2dc3(%rip),%r12
mov    (%r12),%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
jg     1235 <main+0x75>
xor    %eax,%eax
call   1090 <usage@plt>
mov    (%r12),%eax
cltq
mov    0x8(%r15,%rax,8),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
je     124d <main+0x8d>
xor    %eax,%eax
call   1090 <usage@plt>
movslq (%r12),%rax
mov    0x8(%r15,%rax,8),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
cmp    $0xe,%eax
ja     128c <main+0xcc>
lea    0xd98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d58(%rip),%rax
jmp    12a2 <main+0xe2>
mov    0x2d3f(%rip),%rax
jmp    12a2 <main+0xe2>
mov    0x2d5e(%rip),%rax
jmp    12a2 <main+0xe2>
xor    %eax,%eax
call   1090 <usage@plt>
mov    $0x1b6,%r14d
jmp    12ab <main+0xeb>
mov    0x2d0e(%rip),%rax
mov    $0x1b6,%r14d
or     (%rax),%r14d
mov    %r14d,%edi
call   1080 <S_ISREG@plt>
test   %rax,%rax
jne    12c5 <main+0x105>
mov    %r14d,%edi
call   1050 <S_ISFIFO@plt>
test   %rax,%rax
je     12f8 <main+0x138>
mov    (%r12),%ebx
sub    %ebx,%ebp
cmp    $0x2,%ebp
jne    12d4 <main+0x114>
xor    %ebp,%ebp
jmp    1309 <main+0x149>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
call   1070 <fprintf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <usage@plt>
mov    (%r12),%ebx
jmp    1309 <main+0x149>
movslq (%r12),%rbx
mov    0x10(%r15,%rbx,8),%rdi
call   10d0 <atoi@plt>
mov    %rax,%rbp
movslq %ebx,%rax
mov    (%r15,%rax,8),%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
call   1060 <do_mknod@plt>
xor    %eax,%eax
call   1030 <_test_sysio_shutdown@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %eax
mov    0x2c82(%rip),%rcx
mov    %eax,(%rcx)
lea    0xcfd(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <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
@S_IFREG = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
@stderr = global i32 0
@.str.2 = [20 x i8] c"Too many arguments\0A\00"
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 i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %19, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %17 [
]
17: ; preds = %15
%18 = call i32 (...) @usage()
br label %19
19: ; preds = %17
br label %10
20: ; preds = %10
%21 = call i32 @_test_sysio_startup()
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* %7
%26 = sub nsw i32 0, %25
store i32 %26, i32* @errno
%27 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %20
%30 = load i32, i32* %4
%31 = load i32, i32* @optind
%32 = sub nsw i32 %30, %31
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 (...) @usage()
br label %36
36: ; preds = %34, %29
%37 = load i8**, i8*** %5
%38 = load i32, i32* @optind
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @strlen(i8* %42)
%44 = icmp ne i32 %43, 1
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = call i32 (...) @usage()
br label %47
47: ; preds = %45, %36
store i32 438, i32* %8
%48 = load i8**, i8*** %5
%49 = load i32, i32* @optind
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %48, i64 %51
%53 = load i8*, i8** %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
switch i32 %55, label %72 [
i32 102, label %56
i32 98, label %60
i32 99, label %64
i32 112, label %68
]
56: ; preds = %47
%57 = load i32, i32* @S_IFREG
%58 = load i32, i32* %8
%59 = or i32 %58, %57
store i32 %59, i32* %8
br label %74
60: ; preds = %47
%61 = load i32, i32* @S_IFBLK
%62 = load i32, i32* %8
%63 = or i32 %62, %61
store i32 %63, i32* %8
br label %74
64: ; preds = %47
%65 = load i32, i32* @S_IFCHR
%66 = load i32, i32* %8
%67 = or i32 %66, %65
store i32 %67, i32* %8
br label %74
68: ; preds = %47
%69 = load i32, i32* @S_IFIFO
%70 = load i32, i32* %8
%71 = or i32 %70, %69
store i32 %71, i32* %8
br label %74
72: ; preds = %47
%73 = call i32 (...) @usage()
br label %74
74: ; preds = %72, %68, %64, %60, %56
store i64 0, i64* %9
%75 = load i32, i32* %8
%76 = call i64 @S_ISREG(i32 %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %90, label %78
78: ; preds = %74
%79 = load i32, i32* %8
%80 = call i64 @S_ISFIFO(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %90, label %82
82: ; preds = %78
%83 = load i8**, i8*** %5
%84 = load i32, i32* @optind
%85 = add nsw i32 %84, 2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %83, i64 %86
%88 = load i8*, i8** %87
%89 = call i64 @atoi(i8* %88)
store i64 %89, i64* %9
br label %100
90: ; preds = %78, %74
%91 = load i32, i32* %4
%92 = load i32, i32* @optind
%93 = sub nsw i32 %91, %92
%94 = icmp ne i32 %93, 2
br i1 %94, label %95, label %99
95: ; preds = %90
%96 = load i32, i32* @stderr
%97 = call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%98 = call i32 (...) @usage()
br label %99
99: ; preds = %95, %90
br label %100
100: ; preds = %99, %82
%101 = load i8**, i8*** %5
%102 = load i32, i32* @optind
%103 = add nsw i32 %102, 0
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8*, i8** %101, i64 %104
%106 = load i8*, i8** %105
%107 = load i32, i32* %8
%108 = load i64, i64* %9
%109 = call i32 @do_mknod(i8* %106, i32 %107, i64 %108)
%110 = 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
@S_IFREG = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
@stderr = global i32 0
@.str.2 = [20 x i8] c"Too many arguments\0A\00"
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 = sub nsw i32 %0, %17
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = tail call i32 (...) @usage()
%22 = load i32, i32* @optind
br label %23
23: ; preds = %20, %16
%24 = phi i32 [ %22, %20 ], [ %17, %16 ]
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 @strlen(i8* %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %33, label %31
31: ; preds = %23
%32 = tail call i32 (...) @usage()
br label %33
33: ; preds = %31, %23
%34 = load i32, i32* @optind
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
switch i32 %40, label %53 [
i32 102, label %41
i32 98, label %44
i32 99, label %47
i32 112, label %50
]
41: ; preds = %33
%42 = load i32, i32* @S_IFREG
%43 = or i32 %42, 438
br label %55
44: ; preds = %33
%45 = load i32, i32* @S_IFBLK
%46 = or i32 %45, 438
br label %55
47: ; preds = %33
%48 = load i32, i32* @S_IFCHR
%49 = or i32 %48, 438
br label %55
50: ; preds = %33
%51 = load i32, i32* @S_IFIFO
%52 = or i32 %51, 438
br label %55
53: ; preds = %33
%54 = tail call i32 (...) @usage()
br label %55
55: ; preds = %53, %50, %47, %44, %41
%56 = phi i32 [ 438, %53 ], [ %52, %50 ], [ %49, %47 ], [ %46, %44 ], [ %43, %41 ]
%57 = tail call i64 @S_ISREG(i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %69
59: ; preds = %55
%60 = tail call i64 @S_ISFIFO(i32 %56)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* @optind
%64 = add nsw i32 %63, 2
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %1, i64 %65
%67 = load i8*, i8** %66
%68 = tail call i64 @atoi(i8* %67)
br label %78
69: ; preds = %59, %55
%70 = load i32, i32* @optind
%71 = sub nsw i32 %0, %70
%72 = icmp eq i32 %71, 2
br i1 %72, label %78, label %73
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = tail call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%76 = tail call i32 (...) @usage()
%77 = load i32, i32* @optind
br label %78
78: ; preds = %69, %73, %62
%79 = phi i32 [ %77, %73 ], [ %70, %69 ], [ %63, %62 ]
%80 = phi i64 [ 0, %73 ], [ 0, %69 ], [ %68, %62 ]
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds i8*, i8** %1, i64 %81
%83 = load i8*, i8** %82
%84 = tail call i32 @do_mknod(i8* %83, i32 %56, i64 %80)
%85 = tail call i32 (...) @_test_sysio_shutdown()
ret i32 0
}