#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int O_NONBLOCK;
int O_RDONLY;
int S_IFIFO;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int fchmod(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fstat(int, struct stat *);
int mknod(char *, int, int /*<<< orphan*/);
int open(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int unlink(char *);
int main(int argc, char **argv) {
  char *dname1, *dname2;
  int fddev1, fddev2, rc;
  struct stat st1, st2;
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "usage: %s filename1 [filename2]\n", argv[0]);
    exit(1);
  }
  dname1 = argv[1];
  if (argc == 3)
    dname2 = argv[2];
  else
    dname2 = argv[1];
  fprintf(stderr, "creating special file %s\n", dname1);
  rc = mknod(dname1, 0777 | S_IFIFO, 0);
  if (rc == -1) {
    fprintf(stderr, "creating %s fails: %s\n", dname1, strerror(errno));
    exit(1);
  }
  fprintf(stderr, "opening file\n");
  fddev1 = open(dname1, O_RDONLY | O_NONBLOCK);
  if (fddev1 == -1) {
    fprintf(stderr, "open %s fails: %s\n", dname1, strerror(errno));
    exit(1);
  }
  fddev2 = open(dname2, O_RDONLY | O_NONBLOCK);
  if (fddev2 == -1) {
    fprintf(stderr, "open %s fails: %s\n", dname2, strerror(errno));
    exit(1);
  }
  fprintf(stderr, "unlinking %s\n", dname1);
  rc = unlink(dname1);
  if (rc) {
    fprintf(stderr, "unlink %s error: %s\n", dname1, strerror(errno));
    exit(1);
  }
  if (access(dname2, F_OK) == 0) {
    fprintf(stderr, "%s still exists\n", dname2);
    exit(1);
  }
  if (access(dname1, F_OK) == 0) {
    fprintf(stderr, "%s still exists\n", dname1);
    exit(1);
  }
  rc = fchmod(fddev1, 0777);
  if (rc == -1) {
    fprintf(stderr, "fchmod unlinked special file %s fails: %s\n", dname1,
            strerror(errno));
    exit(1);
  }
  rc = fstat(fddev1, &st1);
  if (rc == -1) {
    fprintf(stderr, "fstat unlinked special file %s fails: %s\n", dname1,
            strerror(errno));
    exit(1);
  }
  rc = fstat(fddev2, &st2);
  if (rc == -1) {
    fprintf(stderr, "fstat file %s fails: %s\n", dname2, strerror(errno));
    exit(1);
  }
  fprintf(stderr, "Ok, everything goes well.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11bd <main+0x2d>
cmpl   $0x3,-0x8(%rbp)
jle    11e5 <main+0x55>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    120c <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1218 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
or     $0x1ff,%esi
xor    %edx,%edx
call   1050 <mknod@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    129e <main+0x10e>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
mov    0x2d1f(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1321 <main+0x191>
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2cb4(%rip),%rax
mov    (%rax),%esi
mov    0x2cb3(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    138d <main+0x1fd>
mov    0x2c80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rdx
mov    %rax,%rcx
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2c3c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xcd2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1402 <main+0x272>
mov    0x2c0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xc90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2ba3(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0x0,%rax
jne    1443 <main+0x2b3>
mov    0x2bab(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2b62(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0x0,%rax
jne    1484 <main+0x2f4>
mov    0x2b6a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xc23(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0x1ff,%esi
call   1060 <fchmod@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    14e8 <main+0x358>
mov    0x2b2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2b0c(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xbd0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10b0 <fstat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1551 <main+0x3c1>
mov    0x2ac8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x2aa6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rdx
mov    %rax,%rcx
lea    0xb92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   10b0 <fstat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    15ba <main+0x42a>
mov    0x2a5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rdx
mov    %rax,%rcx
lea    0xb53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2a0f(%rip),%rax
mov    (%rax),%edi
lea    0xb4b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    -0x4(%rdi),%eax
cmp    $0xfffffffd,%eax
jbe    1303 <main+0x173>
mov    0x8(%rsi),%r12
mov    %r12,%r14
cmp    $0x3,%edi
jne    11ba <main+0x2a>
mov    0x10(%rsi),%r14
mov    0x2e0f(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe55(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2de3(%rip),%rax
mov    $0x1ff,%esi
or     (%rax),%esi
mov    %r12,%rdi
xor    %edx,%edx
call   1050 <mknod@plt>
mov    0x0(%r13),%ebp
cmp    $0xffffffff,%eax
je     131b <main+0x18b>
lea    0xe50(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2dce(%rip),%r15
mov    0x2dcf(%rip),%rbx
mov    (%rbx),%esi
or     (%r15),%esi
mov    %r12,%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1337 <main+0x1a7>
mov    %eax,%ebp
mov    (%rbx),%esi
or     (%r15),%esi
mov    %r14,%rdi
call   1070 <open@plt>
mov    0x0(%r13),%ebx
cmp    $0xffffffff,%eax
je     1355 <main+0x1c5>
mov    %eax,%r15d
lea    0xe1e(%rip),%rsi
mov    %ebx,%edi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r12,%rdi
call   1030 <unlink@plt>
test   %eax,%eax
jne    136f <main+0x1df>
mov    0x2d38(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
call   1080 <access@plt>
test   %rax,%rax
je     138a <main+0x1fa>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1080 <access@plt>
test   %rax,%rax
je     139a <main+0x20a>
mov    %ebp,%edi
mov    $0x1ff,%esi
call   1060 <fchmod@plt>
cmp    $0xffffffff,%eax
je     13b9 <main+0x229>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
call   10b0 <fstat@plt>
cmp    $0xffffffff,%eax
je     13d4 <main+0x244>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
call   10b0 <fstat@plt>
mov    0x0(%r13),%ebx
cmp    $0xffffffff,%eax
je     13f4 <main+0x264>
lea    0xe2c(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xcea(%rip),%rsi
jmp    13a8 <main+0x218>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd0b(%rip),%rsi
mov    %ebp,%edi
jmp    13ef <main+0x25f>
mov    0x0(%r13),%ebx
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd10(%rip),%rsi
jmp    13ed <main+0x25d>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xcf6(%rip),%rsi
jmp    1409 <main+0x279>
mov    0x0(%r13),%ebx
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xcf9(%rip),%rsi
jmp    13ed <main+0x25d>
mov    0x0(%r13),%edi
lea    0xd01(%rip),%rsi
mov    %r14,%rdx
jmp    13a8 <main+0x218>
mov    0x0(%r13),%edi
lea    0xcf1(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x0(%r13),%ebx
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xcd5(%rip),%rsi
jmp    13ed <main+0x25d>
mov    0x0(%r13),%ebx
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xce5(%rip),%rsi
mov    %ebx,%edi
mov    %r12,%rdx
jmp    140e <main+0x27e>
mov    0x2bcd(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xcf3(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"usage: %s filename1 [filename2]\0A\00"
@.str.1 = [26 x i8] c"creating special file %s\0A\00"
@S_IFIFO = global i32 0
@.str.2 = [23 x i8] c"creating %s fails: %s\0A\00"
@errno = global i32 0
@.str.3 = [14 x i8] c"opening file\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [19 x i8] c"open %s fails: %s\0A\00"
@.str.5 = [14 x i8] c"unlinking %s\0A\00"
@.str.6 = [21 x i8] c"unlink %s error: %s\0A\00"
@F_OK = global i32 0
@.str.7 = [17 x i8] c"%s still exists\0A\00"
@.str.8 = [43 x i8] c"fchmod unlinked special file %s fails: %s\0A\00"
@.str.9 = [42 x i8] c"fstat unlinked special file %s fails: %s\0A\00"
@.str.10 = [25 x i8] c"fstat file %s fails: %s\0A\00"
@.str.11 = [27 x i8] c"Ok, everything goes well.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.stat
%12 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %15, %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
store i8* %34, i8** %7
br label %39
35: ; preds = %25
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
store i8* %38, i8** %7
br label %39
39: ; preds = %35, %31
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %6
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %6
%44 = load i32, i32* @S_IFIFO
%45 = or i32 511, %44
%46 = call i32 @mknod(i8* %43, i32 %45, i32 0)
store i32 %46, i32* %10
%47 = load i32, i32* %10
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %56
49: ; preds = %39
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %6
%52 = load i32, i32* @errno
%53 = call i8* @strerror(i32 %52)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %51, i8* %53)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %39
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%59 = load i8*, i8** %6
%60 = load i32, i32* @O_RDONLY
%61 = load i32, i32* @O_NONBLOCK
%62 = or i32 %60, %61
%63 = call i32 @open(i8* %59, i32 %62)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %73
66: ; preds = %56
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %6
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %68, i8* %70)
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %56
%74 = load i8*, i8** %7
%75 = load i32, i32* @O_RDONLY
%76 = load i32, i32* @O_NONBLOCK
%77 = or i32 %75, %76
%78 = call i32 @open(i8* %74, i32 %77)
store i32 %78, i32* %9
%79 = load i32, i32* %9
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %88
81: ; preds = %73
%82 = load i32, i32* @stderr
%83 = load i8*, i8** %7
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %83, i8* %85)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %73
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %6
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %90)
%92 = load i8*, i8** %6
%93 = call i32 @unlink(i8* %92)
store i32 %93, i32* %10
%94 = load i32, i32* %10
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %88
%97 = load i32, i32* @stderr
%98 = load i8*, i8** %6
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %98, i8* %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %88
%104 = load i8*, i8** %7
%105 = load i32, i32* @F_OK
%106 = call i64 @access(i8* %104, i32 %105)
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %113
108: ; preds = %103
%109 = load i32, i32* @stderr
%110 = load i8*, i8** %7
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %103
%114 = load i8*, i8** %6
%115 = load i32, i32* @F_OK
%116 = call i64 @access(i8* %114, i32 %115)
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %113
%119 = load i32, i32* @stderr
%120 = load i8*, i8** %6
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %120)
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %113
%124 = load i32, i32* %8
%125 = call i32 @fchmod(i32 %124, i32 511)
store i32 %125, i32* %10
%126 = load i32, i32* %10
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %135
128: ; preds = %123
%129 = load i32, i32* @stderr
%130 = load i8*, i8** %6
%131 = load i32, i32* @errno
%132 = call i8* @strerror(i32 %131)
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %130, i8* %132)
%134 = call i32 @exit(i32 1)
unreachable
135: ; preds = %123
%136 = load i32, i32* %8
%137 = call i32 @fstat(i32 %136, %struct.stat* %11)
store i32 %137, i32* %10
%138 = load i32, i32* %10
%139 = icmp eq i32 %138, -1
br i1 %139, label %140, label %147
140: ; preds = %135
%141 = load i32, i32* @stderr
%142 = load i8*, i8** %6
%143 = load i32, i32* @errno
%144 = call i8* @strerror(i32 %143)
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %142, i8* %144)
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %135
%148 = load i32, i32* %9
%149 = call i32 @fstat(i32 %148, %struct.stat* %12)
store i32 %149, i32* %10
%150 = load i32, i32* %10
%151 = icmp eq i32 %150, -1
br i1 %151, label %152, label %159
152: ; preds = %147
%153 = load i32, i32* @stderr
%154 = load i8*, i8** %7
%155 = load i32, i32* @errno
%156 = call i8* @strerror(i32 %155)
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %154, i8* %156)
%158 = call i32 @exit(i32 1)
unreachable
159: ; preds = %147
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"usage: %s filename1 [filename2]\0A\00"
@.str.1 = [26 x i8] c"creating special file %s\0A\00"
@S_IFIFO = global i32 0
@.str.2 = [23 x i8] c"creating %s fails: %s\0A\00"
@errno = global i32 0
@.str.3 = [14 x i8] c"opening file\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [19 x i8] c"open %s fails: %s\0A\00"
@.str.5 = [14 x i8] c"unlinking %s\0A\00"
@.str.6 = [21 x i8] c"unlink %s error: %s\0A\00"
@F_OK = global i32 0
@.str.7 = [17 x i8] c"%s still exists\0A\00"
@.str.8 = [43 x i8] c"fchmod unlinked special file %s fails: %s\0A\00"
@.str.9 = [42 x i8] c"fstat unlinked special file %s fails: %s\0A\00"
@.str.10 = [25 x i8] c"fstat file %s fails: %s\0A\00"
@.str.11 = [27 x i8] c"Ok, everything goes well.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = add i32 %0, -4
%8 = icmp ult i32 %7, -2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i32 %0, 3
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
br label %21
21: ; preds = %14, %18
%22 = phi i8* [ %20, %18 ], [ %16, %14 ]
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%25 = load i32, i32* @S_IFIFO
%26 = or i32 %25, 511
%27 = tail call i32 @mknod(i8* %16, i32 %26, i32 0)
%28 = icmp eq i32 %27, -1
%29 = load i32, i32* @stderr
br i1 %28, label %30, label %35
30: ; preds = %21
%31 = load i32, i32* @errno
%32 = tail call i8* @strerror(i32 %31)
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %32)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %21
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @O_RDONLY
%38 = load i32, i32* @O_NONBLOCK
%39 = or i32 %38, %37
%40 = tail call i32 @open(i8* %16, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %16, i8* %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %35
%49 = load i32, i32* @O_RDONLY
%50 = load i32, i32* @O_NONBLOCK
%51 = or i32 %50, %49
%52 = tail call i32 @open(i8* %22, i32 %51)
%53 = icmp eq i32 %52, -1
%54 = load i32, i32* @stderr
br i1 %53, label %55, label %60
55: ; preds = %48
%56 = load i32, i32* @errno
%57 = tail call i8* @strerror(i32 %56)
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %22, i8* %57)
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %48
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %16)
%62 = tail call i32 @unlink(i8* %16)
%63 = icmp eq i32 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = load i32, i32* @errno
%67 = tail call i8* @strerror(i32 %66)
%68 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %16, i8* %67)
%69 = tail call i32 @exit(i32 1)
unreachable
70: ; preds = %60
%71 = load i32, i32* @F_OK
%72 = tail call i64 @access(i8* %22, i32 %71)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = tail call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %22)
%77 = tail call i32 @exit(i32 1)
unreachable
78: ; preds = %70
%79 = load i32, i32* @F_OK
%80 = tail call i64 @access(i8* %16, i32 %79)
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = tail call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %16)
%85 = tail call i32 @exit(i32 1)
unreachable
86: ; preds = %78
%87 = tail call i32 @fchmod(i32 %40, i32 511)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %95
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = load i32, i32* @errno
%92 = tail call i8* @strerror(i32 %91)
%93 = tail call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %16, i8* %92)
%94 = tail call i32 @exit(i32 1)
unreachable
95: ; preds = %86
%96 = call i32 @fstat(i32 %40, %struct.stat* %3)
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %104
98: ; preds = %95
%99 = load i32, i32* @stderr
%100 = load i32, i32* @errno
%101 = tail call i8* @strerror(i32 %100)
%102 = tail call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %16, i8* %101)
%103 = tail call i32 @exit(i32 1)
unreachable
104: ; preds = %95
%105 = call i32 @fstat(i32 %52, %struct.stat* %4)
%106 = icmp eq i32 %105, -1
%107 = load i32, i32* @stderr
br i1 %106, label %108, label %113
108: ; preds = %104
%109 = load i32, i32* @errno
%110 = tail call i8* @strerror(i32 %109)
%111 = tail call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %22, i8* %110)
%112 = tail call i32 @exit(i32 1)
unreachable
113: ; preds = %104
%114 = tail call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}