#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_IFSOCK;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int make_device(char const *, int, scalar_t__);
int make_fifo(char const *, int);
int make_socket(char const *, int);
char *optarg;
int optind;
int /*<<< orphan*/ parse_device(char *, scalar_t__ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int umask(int);
int /*<<< orphan*/ unlink(char const *);
int verify_file_stat(char const *, int, scalar_t__, int);
int nfsmknod(int argc, char **argv) {
  enum { TYPE_SOCKET, TYPE_FIFO, TYPE_BLKDEV, TYPE_CHRDEV, __TYPE_MAX };
  int opt_type = TYPE_SOCKET;
  int opt_mode = -1;
  int opt_remove = 0;
  dev_t opt_device = 0;
  int c;
  int rv = 0;
  while ((c = getopt(argc, argv, "d:m:rt:")) != -1) {
    switch (c) {
    case 'd':
      if (!parse_device(optarg, &opt_device)) {
        fprintf(stderr, "cannot parse device major:minor \"%s\"\n", optarg);
        return 1;
      }
      break;
    case 'm':
      opt_mode = strtol(optarg, NULL, 0);
      if (opt_mode & ~0777) {
        fprintf(stderr, "bad permissions in -m option: 0%o\n", opt_mode);
        return 1;
      }
      break;
    case 'r':
      opt_remove = 1;
      break;
    case 't':
      if (!strcasecmp(optarg, "socket"))
        opt_type = TYPE_SOCKET;
      else if (!strcasecmp(optarg, "fifo"))
        opt_type = TYPE_FIFO;
      else if (!strcasecmp(optarg, "blkdev"))
        opt_type = TYPE_BLKDEV;
      else if (!strcasecmp(optarg, "chrdev"))
        opt_type = TYPE_CHRDEV;
      else {
        fprintf(stderr, "Unknown special file type\n");
        return 1;
      }
      break;
    default:
      fprintf(stderr, "Invalid option\n");
      return 1;
    }
  }
  if (opt_type == TYPE_BLKDEV || opt_type == TYPE_CHRDEV) {
    if (opt_device == 0) {
      fprintf(stderr, "Block and char devices need a -d major:minor option\n");
      return 1;
    }
  }
  if (optind == argc) {
    fprintf(stderr, "need file name(s)\n");
    return 1;
  }
  if (opt_mode < 0) {
    umask(~(opt_mode & 0777));
  } else {
    mode_t mask;
    mask = umask(0);
    opt_mode = ~mask & 0777;
  }
  while (optind < argc) {
    const char *pathname = argv[optind++];
    int format, mode = opt_mode;
    int okay = 0;
    if (opt_remove)
      unlink(pathname);
    switch (opt_type) {
    case TYPE_SOCKET:
      format = S_IFSOCK;
      okay = make_socket(pathname, mode);
      break;
    case TYPE_FIFO:
      format = S_IFIFO;
      okay = make_fifo(pathname, mode);
      break;
    case TYPE_BLKDEV:
      format = S_IFBLK;
      okay = make_device(pathname, format | mode, opt_device);
      break;
    case TYPE_CHRDEV:
      format = S_IFCHR;
      okay = make_device(pathname, format | mode, opt_device);
      break;
    default:
      fprintf(stderr, "Special file type not implemented\n");
      return 1;
    }
    if (okay)
      okay = verify_file_stat(pathname, format, opt_device, mode);
    rv |= !okay;
  }
  return 0;
}


x86 assembly (clang, -O0):
<nfsmknod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe63(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     13e4 <nfsmknod+0x234>
mov    -0x2c(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x10,%eax
ja     13bc <nfsmknod+0x20c>
mov    -0x58(%rbp),%rax
lea    0xdee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dc6(%rip),%rax
mov    (%rax),%rdi
lea    -0x28(%rbp),%rsi
call   1090 <parse_device@plt>
cmp    $0x0,%eax
jne    1274 <nfsmknod+0xc4>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
mov    0x2da1(%rip),%rax
mov    (%rax),%rdx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
jmp    13df <nfsmknod+0x22f>
mov    0x2d78(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xfffffe00,%eax
cmp    $0x0,%eax
je     12c8 <nfsmknod+0x118>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
jmp    13df <nfsmknod+0x22f>
movl   $0x1,-0x1c(%rbp)
jmp    13df <nfsmknod+0x22f>
mov    0x2d18(%rip),%rax
mov    (%rax),%rdi
lea    0xdbb(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1304 <nfsmknod+0x154>
movl   $0x0,-0x14(%rbp)
jmp    13b7 <nfsmknod+0x207>
mov    0x2ced(%rip),%rax
mov    (%rax),%rdi
lea    0xd97(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    132f <nfsmknod+0x17f>
movl   $0x1,-0x14(%rbp)
jmp    13b2 <nfsmknod+0x202>
mov    0x2cc2(%rip),%rax
mov    (%rax),%rdi
lea    0xd71(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    135a <nfsmknod+0x1aa>
movl   $0x2,-0x14(%rbp)
jmp    13ad <nfsmknod+0x1fd>
mov    0x2c97(%rip),%rax
mov    (%rax),%rdi
lea    0xd4d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1385 <nfsmknod+0x1d5>
movl   $0x3,-0x14(%rbp)
jmp    13a8 <nfsmknod+0x1f8>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
jmp    13ad <nfsmknod+0x1fd>
jmp    13b2 <nfsmknod+0x202>
jmp    13b7 <nfsmknod+0x207>
jmp    13df <nfsmknod+0x22f>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
jmp    11e3 <nfsmknod+0x33>
cmpl   $0x2,-0x14(%rbp)
je     13f8 <nfsmknod+0x248>
cmpl   $0x3,-0x14(%rbp)
jne    142b <nfsmknod+0x27b>
cmpq   $0x0,-0x28(%rbp)
jne    1426 <nfsmknod+0x276>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
lea    0xcd7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
jmp    142b <nfsmknod+0x27b>
mov    0x2bae(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1460 <nfsmknod+0x2b0>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
lea    0xcd2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
cmpl   $0x0,-0x18(%rbp)
jge    1480 <nfsmknod+0x2d0>
mov    -0x18(%rbp),%edi
and    $0x1ff,%edi
xor    $0xffffffff,%edi
call   10a0 <umask@plt>
jmp    1498 <nfsmknod+0x2e8>
xor    %edi,%edi
call   10a0 <umask@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
xor    $0xffffffff,%eax
and    $0x1ff,%eax
mov    %eax,-0x18(%rbp)
jmp    149d <nfsmknod+0x2ed>
mov    0x2b3c(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1604 <nfsmknod+0x454>
mov    -0x10(%rbp),%rax
mov    0x2b26(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2b18(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     14f5 <nfsmknod+0x345>
mov    -0x40(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x14(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x3,%rax
ja     15a8 <nfsmknod+0x3f8>
mov    -0x60(%rbp),%rax
lea    0xaef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2aaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   10c0 <make_socket@plt>
mov    %eax,-0x4c(%rbp)
jmp    15cb <nfsmknod+0x41b>
mov    0x2a6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1050 <make_fifo@plt>
mov    %eax,-0x4c(%rbp)
jmp    15cb <nfsmknod+0x41b>
mov    0x2a67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
or     -0x48(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1070 <make_device@plt>
mov    %eax,-0x4c(%rbp)
jmp    15cb <nfsmknod+0x41b>
mov    0x2a30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
or     -0x48(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1070 <make_device@plt>
mov    %eax,-0x4c(%rbp)
jmp    15cb <nfsmknod+0x41b>
mov    0x2a11(%rip),%rax
mov    (%rax),%edi
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160b <nfsmknod+0x45b>
cmpl   $0x0,-0x4c(%rbp)
je     15eb <nfsmknod+0x43b>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x48(%rbp),%ecx
call   1060 <verify_file_stat@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    149d <nfsmknod+0x2ed>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nfsmknod>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
movq   $0x0,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
movl   $0xffffffff,0x14(%rsp)
ff
mov    $0x1,%al
mov    %eax,0x24(%rsp)
lea    0xe28(%rip),%r15
mov    0x2e09(%rip),%r14
lea    0x18(%rsp),%r12
jmp    1213 <nfsmknod+0x63>
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%rdi
mov    %r12,%rsi
call   1090 <parse_device@plt>
test   %eax,%eax
je     1333 <nfsmknod+0x183>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   10d0 <getopt@plt>
cmp    $0x64,%eax
je     1200 <nfsmknod+0x50>
cmp    $0x71,%eax
jg     1258 <nfsmknod+0xa8>
cmp    $0xffffffff,%eax
je     12fc <nfsmknod+0x14c>
cmp    $0x6d,%eax
jne    1321 <nfsmknod+0x171>
mov    (%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,0x14(%rsp)
cmp    $0x200,%eax
jb     1213 <nfsmknod+0x63>
jmp    14aa <nfsmknod+0x2fa>
cmp    $0x72,%eax
je     12ef <nfsmknod+0x13f>
cmp    $0x74,%eax
jne    1321 <nfsmknod+0x171>
mov    (%r14),%rbx
mov    %rbx,%rdi
lea    0xdea(%rip),%rsi
call   1030 <strcasecmp@plt>
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
test   %eax,%eax
je     1213 <nfsmknod+0x63>
mov    %rbx,%rdi
lea    0xdd7(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x1,%ecx
mov    %rcx,0x8(%rsp)
test   %eax,%eax
je     1213 <nfsmknod+0x63>
mov    %rbx,%rdi
lea    0xdbb(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x2,%ecx
mov    %rcx,0x8(%rsp)
test   %eax,%eax
je     1213 <nfsmknod+0x63>
mov    %rbx,%rdi
lea    0xda1(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x3,%ecx
mov    %rcx,0x8(%rsp)
test   %eax,%eax
je     1213 <nfsmknod+0x63>
jmp    14ca <nfsmknod+0x31a>
movl   $0x0,0x24(%rsp)
jmp    1213 <nfsmknod+0x63>
mov    0x8(%rsp),%r12
test   $0x2,%r12b
je     134f <nfsmknod+0x19f>
cmpq   $0x0,0x18(%rsp)
jne    134f <nfsmknod+0x19f>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
jmp    136a <nfsmknod+0x1ba>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
jmp    136a <nfsmknod+0x1ba>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcd2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1371 <nfsmknod+0x1c1>
mov    0x2c8a(%rip),%rbx
cmp    %ebp,(%rbx)
jne    1389 <nfsmknod+0x1d9>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xd71(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x14(%rsp),%r14d
test   %r14d,%r14d
js     13a9 <nfsmknod+0x1f9>
xor    %edi,%edi
call   10a0 <umask@plt>
mov    %eax,%r14d
not    %r14d
and    $0x1ff,%r14d
jmp    13b9 <nfsmknod+0x209>
mov    %r14d,%edi
not    %edi
or     $0xfffffe00,%edi
call   10a0 <umask@plt>
mov    (%rbx),%eax
xor    %r15d,%r15d
cmp    %ebp,%eax
jge    1377 <nfsmknod+0x1c7>
mov    %r12d,%ecx
lea    0xc34(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
mov    %rcx,0x8(%rsp)
jmp    13ed <nfsmknod+0x23d>
nopw   0x0(%rax,%rax,1)
mov    0x2bf9(%rip),%rbx
mov    (%rbx),%eax
cmp    %ebp,%eax
jge    1377 <nfsmknod+0x1c7>
lea    0x1(%rax),%ecx
mov    %ecx,(%rbx)
cltq
mov    0x0(%r13,%rax,8),%r12
testb  $0x1,0x24(%rsp)
je     1410 <nfsmknod+0x260>
jmp    *0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <unlink@plt>
jmp    *0x8(%rsp)
mov    0x2bad(%rip),%rax
mov    (%rax),%ebx
mov    %r12,%rdi
mov    %r14d,%esi
call   10c0 <make_socket@plt>
jmp    148b <nfsmknod+0x2db>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2b69(%rip),%rax
mov    (%rax),%ebx
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <make_fifo@plt>
jmp    148b <nfsmknod+0x2db>
cs nopw 0x0(%rax,%rax,1)
mov    0x2b61(%rip),%rax
jmp    1477 <nfsmknod+0x2c7>
nopl   0x0(%rax)
mov    0x2b41(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%esi
or     %r14d,%esi
mov    0x18(%rsp),%rdx
mov    %r12,%rdi
call   1070 <make_device@plt>
test   %eax,%eax
je     13e0 <nfsmknod+0x230>
mov    0x18(%rsp),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14d,%ecx
call   1060 <verify_file_stat@plt>
jmp    13e0 <nfsmknod+0x230>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
lea    0xb84(%rip),%rsi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1371 <nfsmknod+0x1c1>
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
lea    0xba1(%rip),%rsi
jmp    136a <nfsmknod+0x1ba>

LLVM IR (-O0):
@.str = [8 x i8] c"d:m:rt:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [38 x i8] c"cannot parse device major:minor \22%s\22\0A\00"
@.str.2 = [35 x i8] c"bad permissions in -m option: 0%o\0A\00"
@.str.3 = [7 x i8] c"socket\00"
@.str.4 = [5 x i8] c"fifo\00"
@.str.5 = [7 x i8] c"blkdev\00"
@.str.6 = [7 x i8] c"chrdev\00"
@.str.7 = [27 x i8] c"Unknown special file type\0A\00"
@.str.8 = [16 x i8] c"Invalid option\0A\00"
@.str.9 = [53 x i8] c"Block and char devices need a -d major:minor option\0A\00"
@optind = global i32 0
@.str.10 = [19 x i8] c"need file name(s)\0A\00"
@S_IFSOCK = global i32 0
@S_IFIFO = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@.str.11 = [35 x i8] c"Special file type not implemented\0A\00"
define i32 @nfsmknod(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
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 -1, i32* %7
store i32 0, i32* %8
store i64 0, i64* %9
store i32 0, i32* %11
br label %17
17: ; preds = %75, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %10
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %76
22: ; preds = %17
%23 = load i32, i32* %10
switch i32 %23, label %72 [
i32 100, label %24
i32 109, label %33
i32 114, label %44
i32 116, label %45
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
%26 = call i32 @parse_device(i8* %25, i64* %9)
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i8*, i8** @optarg
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %175
32: ; preds = %24
br label %75
33: ; preds = %22
%34 = load i8*, i8** @optarg
%35 = call i32 @strtol(i8* %34, i32* null, i32 0)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = and i32 %36, -512
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = load i32, i32* %7
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %41)
store i32 1, i32* %3
br label %175
43: ; preds = %33
br label %75
44: ; preds = %22
store i32 1, i32* %8
br label %75
45: ; preds = %22
%46 = load i8*, i8** @optarg
%47 = call i32 @strcasecmp(i8* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45
store i32 0, i32* %6
br label %71
50: ; preds = %45
%51 = load i8*, i8** @optarg
%52 = call i32 @strcasecmp(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %55, label %54
54: ; preds = %50
store i32 1, i32* %6
br label %70
55: ; preds = %50
%56 = load i8*, i8** @optarg
%57 = call i32 @strcasecmp(i8* %56, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %55
store i32 2, i32* %6
br label %69
60: ; preds = %55
%61 = load i8*, i8** @optarg
%62 = call i32 @strcasecmp(i8* %61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %65, label %64
64: ; preds = %60
store i32 3, i32* %6
br label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %175
68: ; preds = %64
br label %69
69: ; preds = %68, %59
br label %70
70: ; preds = %69, %54
br label %71
71: ; preds = %70, %49
br label %75
72: ; preds = %22
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %175
75: ; preds = %71, %44, %43, %32
br label %17
76: ; preds = %17
%77 = load i32, i32* %6
%78 = icmp eq i32 %77, 2
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = load i32, i32* %6
%81 = icmp eq i32 %80, 3
br i1 %81, label %82, label %89
82: ; preds = %79, %76
%83 = load i64, i64* %9
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %175
88: ; preds = %82
br label %89
89: ; preds = %88, %79
%90 = load i32, i32* @optind
%91 = load i32, i32* %4
%92 = icmp eq i32 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %175
96: ; preds = %89
%97 = load i32, i32* %7
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %96
%100 = load i32, i32* %7
%101 = and i32 %100, 511
%102 = xor i32 %101, -1
%103 = call i32 @umask(i32 %102)
br label %109
104: ; preds = %96
%105 = call i32 @umask(i32 0)
store i32 %105, i32* %12
%106 = load i32, i32* %12
%107 = xor i32 %106, -1
%108 = and i32 %107, 511
store i32 %108, i32* %7
br label %109
109: ; preds = %104, %99
br label %110
110: ; preds = %167, %109
%111 = load i32, i32* @optind
%112 = load i32, i32* %4
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %174
114: ; preds = %110
%115 = load i8**, i8*** %5
%116 = load i32, i32* @optind
%117 = add nsw i32 %116, 1
store i32 %117, i32* @optind
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds i8*, i8** %115, i64 %118
%120 = load i8*, i8** %119
store i8* %120, i8** %13
%121 = load i32, i32* %7
store i32 %121, i32* %15
store i32 0, i32* %16
%122 = load i32, i32* %8
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %114
%125 = load i8*, i8** %13
%126 = call i32 @unlink(i8* %125)
br label %127
127: ; preds = %124, %114
%128 = load i32, i32* %6
switch i32 %128, label %155 [
i32 0, label %129
i32 1, label %134
i32 2, label %139
i32 3, label %147
]
129: ; preds = %127
%130 = load i32, i32* @S_IFSOCK
store i32 %130, i32* %14
%131 = load i8*, i8** %13
%132 = load i32, i32* %15
%133 = call i32 @make_socket(i8* %131, i32 %132)
store i32 %133, i32* %16
br label %158
134: ; preds = %127
%135 = load i32, i32* @S_IFIFO
store i32 %135, i32* %14
%136 = load i8*, i8** %13
%137 = load i32, i32* %15
%138 = call i32 @make_fifo(i8* %136, i32 %137)
store i32 %138, i32* %16
br label %158
139: ; preds = %127
%140 = load i32, i32* @S_IFBLK
store i32 %140, i32* %14
%141 = load i8*, i8** %13
%142 = load i32, i32* %14
%143 = load i32, i32* %15
%144 = or i32 %142, %143
%145 = load i64, i64* %9
%146 = call i32 @make_device(i8* %141, i32 %144, i64 %145)
store i32 %146, i32* %16
br label %158
147: ; preds = %127
%148 = load i32, i32* @S_IFCHR
store i32 %148, i32* %14
%149 = load i8*, i8** %13
%150 = load i32, i32* %14
%151 = load i32, i32* %15
%152 = or i32 %150, %151
%153 = load i64, i64* %9
%154 = call i32 @make_device(i8* %149, i32 %152, i64 %153)
store i32 %154, i32* %16
br label %158
155: ; preds = %127
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %175
158: ; preds = %147, %139, %134, %129
%159 = load i32, i32* %16
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %167
161: ; preds = %158
%162 = load i8*, i8** %13
%163 = load i32, i32* %14
%164 = load i64, i64* %9
%165 = load i32, i32* %15
%166 = call i32 @verify_file_stat(i8* %162, i32 %163, i64 %164, i32 %165)
store i32 %166, i32* %16
br label %167
167: ; preds = %161, %158
%168 = load i32, i32* %16
%169 = icmp ne i32 %168, 0
%170 = xor i1 %169, true
%171 = zext i1 %170 to i32
%172 = load i32, i32* %11
%173 = or i32 %172, %171
store i32 %173, i32* %11
br label %110
174: ; preds = %110
store i32 0, i32* %3
br label %175
175: ; preds = %174, %155, %93, %85, %72, %65, %39, %28
%176 = load i32, i32* %3
ret i32 %176
}

LLVM IR (-O2):
@.str = [8 x i8] c"d:m:rt:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [38 x i8] c"cannot parse device major:minor \22%s\22\0A\00"
@.str.2 = [35 x i8] c"bad permissions in -m option: 0%o\0A\00"
@.str.3 = [7 x i8] c"socket\00"
@.str.4 = [5 x i8] c"fifo\00"
@.str.5 = [7 x i8] c"blkdev\00"
@.str.6 = [7 x i8] c"chrdev\00"
@.str.7 = [27 x i8] c"Unknown special file type\0A\00"
@.str.8 = [16 x i8] c"Invalid option\0A\00"
@.str.9 = [53 x i8] c"Block and char devices need a -d major:minor option\0A\00"
@optind = global i32 0
@.str.10 = [19 x i8] c"need file name(s)\0A\00"
@S_IFSOCK = global i32 0
@S_IFIFO = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
define i32 @nfsmknod(i32 %0, i8** %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
br label %5
5: ; preds = %14, %2
%6 = phi i1 [ true, %2 ], [ false, %14 ]
%7 = phi i32 [ -1, %2 ], [ %10, %14 ]
%8 = phi i32 [ 0, %2 ], [ %13, %14 ]
br label %9
9: ; preds = %5, %24
%10 = phi i32 [ %7, %5 ], [ %26, %24 ]
%11 = phi i32 [ %8, %5 ], [ %13, %24 ]
br label %12
12: ; preds = %35, %9
%13 = phi i32 [ %11, %9 ], [ %36, %35 ]
br label %14
14: ; preds = %12, %16
%15 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %15, label %49 [
i32 -1, label %52
i32 100, label %16
i32 109, label %24
i32 114, label %5
i32 116, label %31
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
%18 = call i32 @parse_device(i8* %17, i64* %3)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %14
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i8*, i8** @optarg
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %117
24: ; preds = %14
%25 = load i8*, i8** @optarg
%26 = call i32 @strtol(i8* nocapture %25, i32* null, i32 0)
%27 = icmp ult i32 %26, 512
br i1 %27, label %9, label %28
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %117
31: ; preds = %14
%32 = load i8*, i8** @optarg
%33 = call i32 @strcasecmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31, %37, %40, %43
%36 = phi i32 [ 3, %43 ], [ 2, %40 ], [ 1, %37 ], [ 0, %31 ]
br label %12
37: ; preds = %31
%38 = call i32 @strcasecmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %35, label %40
40: ; preds = %37
%41 = call i32 @strcasecmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %35, label %43
43: ; preds = %40
%44 = call i32 @strcasecmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %35, label %46
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %117
49: ; preds = %14
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %117
52: ; preds = %14
%53 = and i32 %13, 2
%54 = icmp ne i32 %53, 0
%55 = load i64, i64* %3
%56 = icmp eq i64 %55, 0
%57 = select i1 %54, i1 %56, i1 false
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
br label %117
61: ; preds = %52
%62 = load i32, i32* @optind
%63 = icmp eq i32 %62, %0
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %117
67: ; preds = %61
%68 = icmp slt i32 %10, 0
br i1 %68, label %69, label %73
69: ; preds = %67
%70 = and i32 %10, 511
%71 = xor i32 %70, -1
%72 = call i32 @umask(i32 %71)
br label %77
73: ; preds = %67
%74 = call i32 @umask(i32 0)
%75 = and i32 %74, 511
%76 = xor i32 %75, 511
br label %77
77: ; preds = %73, %69
%78 = phi i32 [ %10, %69 ], [ %76, %73 ]
%79 = load i32, i32* @optind
%80 = icmp slt i32 %79, %0
br i1 %80, label %81, label %117
81: ; preds = %77, %114
%82 = phi i32 [ %115, %114 ], [ %79, %77 ]
%83 = add nsw i32 %82, 1
store i32 %83, i32* @optind
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds i8*, i8** %1, i64 %84
%86 = load i8*, i8** %85
br i1 %6, label %89, label %87
87: ; preds = %81
%88 = call i32 @unlink(i8* %86)
br label %89
89: ; preds = %87, %81
switch i32 %13, label %106 [
i32 0, label %90
i32 1, label %93
i32 2, label %96
i32 3, label %101
]
90: ; preds = %89
%91 = load i32, i32* @S_IFSOCK
%92 = call i32 @make_socket(i8* %86, i32 %78)
br label %107
93: ; preds = %89
%94 = load i32, i32* @S_IFIFO
%95 = call i32 @make_fifo(i8* %86, i32 %78)
br label %107
96: ; preds = %89
%97 = load i32, i32* @S_IFBLK
%98 = or i32 %97, %78
%99 = load i64, i64* %3
%100 = call i32 @make_device(i8* %86, i32 %98, i64 %99)
br label %107
101: ; preds = %89
%102 = load i32, i32* @S_IFCHR
%103 = or i32 %102, %78
%104 = load i64, i64* %3
%105 = call i32 @make_device(i8* %86, i32 %103, i64 %104)
br label %107
106: ; preds = %89
unreachable
107: ; preds = %101, %96, %93, %90
%108 = phi i32 [ %102, %101 ], [ %97, %96 ], [ %94, %93 ], [ %91, %90 ]
%109 = phi i32 [ %105, %101 ], [ %100, %96 ], [ %95, %93 ], [ %92, %90 ]
%110 = icmp eq i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %107
%112 = load i64, i64* %3
%113 = call i32 @verify_file_stat(i8* %86, i32 %108, i64 %112, i32 %78)
br label %114
114: ; preds = %107, %111
%115 = load i32, i32* @optind
%116 = icmp slt i32 %115, %0
br i1 %116, label %81, label %117
117: ; preds = %114, %77, %64, %58, %49, %46, %28, %20
%118 = phi i32 [ 1, %49 ], [ 1, %46 ], [ 1, %28 ], [ 1, %20 ], [ 1, %58 ], [ 1, %64 ], [ 0, %77 ], [ 0, %114 ]
ret i32 %118
}