#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 S_IFBLK;
int S_IFCHR;
int S_IFIFO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ makedev(int, int);
scalar_t__ mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int strtol(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int major = 0, minor = 0;
  char *path;
  int mode = 0666;
  char *end;
  int args;
  if (argc < 3)
    usage();
  path = argv[1];
  if (!strcmp(argv[2], "b")) {
    mode |= S_IFBLK;
    args = 5;
  } else if (!strcmp(argv[2], "c") || !strcmp(argv[2], "u")) {
    mode |= S_IFCHR;
    args = 5;
  } else if (!strcmp(argv[2], "p")) {
    mode |= S_IFIFO;
    args = 3;
  } else {
    fprintf(stderr, "unknown node type %s\n", argv[2]);
    return 1;
  }
  if (argc != args)
    usage();
  if (args == 5) {
    major = strtol(argv[3], &end, 0);
    if (*end) {
      fprintf(stderr, "bad major number %s\n", argv[3]);
      return 1;
    }
    minor = strtol(argv[4], &end, 0);
    if (*end) {
      fprintf(stderr, "bad minor number %s\n", argv[4]);
      return 1;
    }
  }
  if (mknod(path, mode, makedev(major, minor))) {
    fprintf(stderr, "mknod failed: %s\n", strerror(errno));
    return 1;
  }
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1b6,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11ac <main+0x3c>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe39(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f0 <main+0x80>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x5,-0x34(%rbp)
jmp    12b0 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     122a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1245 <main+0xd5>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x5,-0x34(%rbp)
jmp    12ab <main+0x13b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    127d <main+0x10d>
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x3,-0x34(%rbp)
jmp    12a6 <main+0x136>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd73(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13da <main+0x26a>
jmp    12ab <main+0x13b>
jmp    12b0 <main+0x140>
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
je     12c3 <main+0x153>
mov    $0x0,%al
call   1070 <usage@plt>
cmpl   $0x5,-0x34(%rbp)
jne    136a <main+0x1fa>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1319 <main+0x1a9>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xd16(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13da <main+0x26a>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1365 <main+0x1f5>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xcdf(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13da <main+0x26a>
jmp    136a <main+0x1fa>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1080 <makedev@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    %eax,%edx
call   1050 <mknod@plt>
cmp    $0x0,%rax
je     13d3 <main+0x263>
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xc86(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13da <main+0x26a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%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
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
cmp    $0x2,%edi
jg     118f <main+0x1f>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x8(%r15),%rax
mov    %rax,0x10(%rsp)
mov    0x10(%r15),%rbx
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x5,%r12d
mov    $0x1,%r13b
test   %eax,%eax
je     1210 <main+0xa0>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    0x2e02(%rip),%r14
test   %eax,%eax
je     1229 <main+0xb9>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1229 <main+0xb9>
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1219 <main+0xa9>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
mov    %rbx,%rdx
jmp    12f0 <main+0x180>
mov    0x2dc9(%rip),%r14
jmp    1229 <main+0xb9>
mov    $0x3,%r12d
mov    0x2d9a(%rip),%r14
xor    %r13d,%r13d
mov    $0x1b6,%ebx
or     (%r14),%ebx
cmp    %ebp,%r12d
je     123d <main+0xcd>
xor    %eax,%eax
call   1070 <usage@plt>
xor    %r12d,%r12d
mov    $0x0,%ebp
mov    $0x0,%esi
test   %r13b,%r13b
je     12b3 <main+0x143>
mov    0x18(%r15),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1281 <main+0x111>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    0x18(%r15),%rdx
lea    0xd9f(%rip),%rsi
jmp    12f0 <main+0x180>
mov    0x20(%r15),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,%esi
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     12b3 <main+0x143>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    0x20(%r15),%rdx
lea    0xd82(%rip),%rsi
jmp    12f0 <main+0x180>
mov    %ebp,%edi
call   1080 <makedev@plt>
mov    0x10(%rsp),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <mknod@plt>
test   %rax,%rax
je     12fb <main+0x18b>
mov    0x2d04(%rip),%rax
mov    (%rax),%ebx
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd5d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"b\00"
@S_IFBLK = global i32 0
@.str.1 = [2 x i8] c"c\00"
@.str.2 = [2 x i8] c"u\00"
@S_IFCHR = global i32 0
@.str.3 = [2 x i8] c"p\00"
@S_IFIFO = global i32 0
@stderr = global i32 0
@.str.4 = [22 x i8] c"unknown node type %s\0A\00"
@.str.5 = [21 x i8] c"bad major number %s\0A\00"
@.str.6 = [21 x i8] c"bad minor number %s\0A\00"
@.str.7 = [18 x i8] c"mknod failed: %s\0A\00"
@errno = 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 i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 438, i32* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
br label %16
16: ; preds = %14, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %8
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %16
%26 = load i32, i32* @S_IFBLK
%27 = load i32, i32* %9
%28 = or i32 %27, %26
store i32 %28, i32* %9
store i32 5, i32* %11
br label %63
29: ; preds = %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %35, %29
%42 = load i32, i32* @S_IFCHR
%43 = load i32, i32* %9
%44 = or i32 %43, %42
store i32 %44, i32* %9
store i32 5, i32* %11
br label %62
45: ; preds = %35
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @strcmp(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%50 = icmp ne i32 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %45
%52 = load i32, i32* @S_IFIFO
%53 = load i32, i32* %9
%54 = or i32 %53, %52
store i32 %54, i32* %9
store i32 3, i32* %11
br label %61
55: ; preds = %45
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %59)
store i32 1, i32* %3
br label %115
61: ; preds = %51
br label %62
62: ; preds = %61, %41
br label %63
63: ; preds = %62, %25
%64 = load i32, i32* %4
%65 = load i32, i32* %11
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = call i32 (...) @usage()
br label %69
69: ; preds = %67, %63
%70 = load i32, i32* %11
%71 = icmp eq i32 %70, 5
br i1 %71, label %72, label %101
72: ; preds = %69
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 3
%75 = load i8*, i8** %74
%76 = call i32 @strtol(i8* %75, i8** %10, i32 0)
store i32 %76, i32* %6
%77 = load i8*, i8** %10
%78 = load i8, i8* %77
%79 = icmp ne i8 %78, 0
br i1 %79, label %80, label %86
80: ; preds = %72
%81 = load i32, i32* @stderr
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 3
%84 = load i8*, i8** %83
%85 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %84)
store i32 1, i32* %3
br label %115
86: ; preds = %72
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 4
%89 = load i8*, i8** %88
%90 = call i32 @strtol(i8* %89, i8** %10, i32 0)
store i32 %90, i32* %7
%91 = load i8*, i8** %10
%92 = load i8, i8* %91
%93 = icmp ne i8 %92, 0
br i1 %93, label %94, label %100
94: ; preds = %86
%95 = load i32, i32* @stderr
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 4
%98 = load i8*, i8** %97
%99 = call i32 @fprintf(i32 %95, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %98)
store i32 1, i32* %3
br label %115
100: ; preds = %86
br label %101
101: ; preds = %100, %69
%102 = load i8*, i8** %8
%103 = load i32, i32* %9
%104 = load i32, i32* %6
%105 = load i32, i32* %7
%106 = call i32 @makedev(i32 %104, i32 %105)
%107 = call i64 @mknod(i8* %102, i32 %103, i32 %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %114
109: ; preds = %101
%110 = load i32, i32* @stderr
%111 = load i32, i32* @errno
%112 = call i8* @strerror(i32 %111)
%113 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %112)
store i32 1, i32* %3
br label %115
114: ; preds = %101
store i32 0, i32* %3
br label %115
115: ; preds = %114, %109, %94, %80, %55
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
@.str = [2 x i8] c"b\00"
@S_IFBLK = global i32 0
@.str.1 = [2 x i8] c"c\00"
@.str.2 = [2 x i8] c"u\00"
@S_IFCHR = global i32 0
@.str.3 = [2 x i8] c"p\00"
@S_IFIFO = global i32 0
@stderr = global i32 0
@.str.4 = [22 x i8] c"unknown node type %s\0A\00"
@.str.5 = [21 x i8] c"bad major number %s\0A\00"
@.str.6 = [21 x i8] c"bad minor number %s\0A\00"
@.str.7 = [18 x i8] c"mknod failed: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @usage()
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %8
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %70
27: ; preds = %21, %15, %18, %8
%28 = phi i32* [ @S_IFBLK, %8 ], [ @S_IFCHR, %18 ], [ @S_IFCHR, %15 ], [ @S_IFIFO, %21 ]
%29 = phi i1 [ true, %8 ], [ true, %18 ], [ true, %15 ], [ false, %21 ]
%30 = phi i32 [ 5, %8 ], [ 5, %18 ], [ 5, %15 ], [ 3, %21 ]
%31 = load i32, i32* %28
%32 = or i32 %31, 438
%33 = icmp eq i32 %30, %0
br i1 %33, label %36, label %34
34: ; preds = %27
%35 = tail call i32 (...) @usage()
br label %36
36: ; preds = %34, %27
br i1 %29, label %37, label %59
37: ; preds = %36
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = call i32 @strtol(i8* %39, i8** %3, i32 0)
%41 = load i8*, i8** %3
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %37
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %38
%47 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %70
48: ; preds = %37
%49 = getelementptr inbounds i8*, i8** %1, i64 4
%50 = load i8*, i8** %49
%51 = call i32 @strtol(i8* %50, i8** %3, i32 0)
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %48
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %49
%58 = tail call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %57)
br label %70
59: ; preds = %48, %36
%60 = phi i32 [ %40, %48 ], [ 0, %36 ]
%61 = phi i32 [ %51, %48 ], [ 0, %36 ]
%62 = tail call i32 @makedev(i32 %60, i32 %61)
%63 = tail call i64 @mknod(i8* %10, i32 %32, i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %59
%66 = load i32, i32* @stderr
%67 = load i32, i32* @errno
%68 = tail call i8* @strerror(i32 %67)
%69 = tail call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %59, %65, %55, %44, %24
%71 = phi i32 [ 1, %24 ], [ 1, %44 ], [ 1, %55 ], [ 1, %65 ], [ 0, %59 ]
ret i32 %71
}