#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 /*<<< orphan*/ F_OK;
int S_IFREG;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ server(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char **argv) {
  argv++;
  if (*argv && !strcmp(*argv, "add")) {
    while (*++argv)
      mknod(*argv, S_IFREG | 0644, 0);
  } else if (*argv && !strcmp(*argv, "drop")) {
    while (*++argv)
      unlink(*argv);
  } else if (*argv && !strcmp(*argv, "ask")) {
    while (*++argv)
      printf("%s: %s\n", *argv, access(*argv, F_OK) ? "DENIED" : "ALLOWED");
  } else if (*argv && !strcmp(*argv, "server")) {
    server(*++argv);
  } else {
    printf("usage: %s add|drop|ask|server files...\n", *--argv);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe62(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11f2 <main+0x92>
jmp    11b1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     11ed <main+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
or     $0x1a4,%esi
xor    %edx,%edx
call   1060 <mknod@plt>
jmp    11b1 <main+0x51>
jmp    1366 <main+0x206>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1251 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1251 <main+0xf1>
jmp    1221 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     124c <main+0xec>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <unlink@plt>
jmp    1221 <main+0xc1>
jmp    1361 <main+0x201>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     12ef <main+0x18f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd9c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12ef <main+0x18f>
jmp    1280 <main+0x120>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     12ea <main+0x18a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rcx
lea    0xd54(%rip),%rdx
lea    0xd46(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <main+0x120>
jmp    135c <main+0x1fc>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1336 <main+0x1d6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd19(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1336 <main+0x1d6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1070 <server@plt>
jmp    1357 <main+0x1f7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
mov    -0x8(%rax),%rsi
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135c <main+0x1fc>
jmp    1361 <main+0x201>
jmp    1366 <main+0x206>
xor    %eax,%eax
add    $0x20,%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,%rbx
mov    0x8(%rsi),%r14
test   %r14,%r14
je     11cf <main+0x6f>
lea    0xe82(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11e5 <main+0x85>
lea    0xe73(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     122d <main+0xcd>
lea    0xe61(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1253 <main+0xf3>
lea    0xe65(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     12b1 <main+0x151>
mov    (%rbx),%rsi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12ba <main+0x15a>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     12ba <main+0x15a>
add    $0x18,%rbx
mov    0x2deb(%rip),%r14
mov    $0x1a4,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14),%esi
or     %ebp,%esi
xor    %edx,%edx
call   1060 <mknod@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1210 <main+0xb0>
jmp    12ba <main+0x15a>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     12ba <main+0x15a>
add    $0x18,%rbx
xchg   %ax,%ax
call   1030 <unlink@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1240 <main+0xe0>
jmp    12ba <main+0x15a>
mov    0x10(%rbx),%r14
test   %r14,%r14
je     12ba <main+0x15a>
add    $0x18,%rbx
mov    0x2d69(%rip),%r12
lea    0xdae(%rip),%r13
lea    0xda0(%rip),%rbp
lea    0xd91(%rip),%r15
nopl   0x0(%rax)
mov    (%r12),%esi
mov    %r14,%rdi
call   1080 <access@plt>
test   %rax,%rax
mov    %rbp,%rdx
cmove  %r13,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%r14
add    $0x8,%rbx
test   %r14,%r14
jne    1280 <main+0x120>
jmp    12ba <main+0x15a>
mov    0x10(%rbx),%rdi
call   1070 <server@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"add\00"
@S_IFREG = global i32 0
@.str.1 = [5 x i8] c"drop\00"
@.str.2 = [4 x i8] c"ask\00"
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@F_OK = global i32 0
@.str.4 = [7 x i8] c"DENIED\00"
@.str.5 = [8 x i8] c"ALLOWED\00"
@.str.6 = [7 x i8] c"server\00"
@.str.7 = [40 x i8] c"usage: %s add|drop|ask|server files...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i32 1
store i8** %7, i8*** %5
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %29
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %29, label %16
16: ; preds = %11
br label %17
17: ; preds = %22, %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = load i32, i32* @S_IFREG
%26 = or i32 %25, 420
%27 = call i32 @mknod(i8* %24, i32 %26, i32 0)
br label %17
28: ; preds = %17
br label %98
29: ; preds = %11, %2
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %49
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %49, label %38
38: ; preds = %33
br label %39
39: ; preds = %44, %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %5
%42 = load i8*, i8** %41
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = load i8**, i8*** %5
%46 = load i8*, i8** %45
%47 = call i32 @unlink(i8* %46)
br label %39
48: ; preds = %39
br label %97
49: ; preds = %33, %29
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %76
53: ; preds = %49
%54 = load i8**, i8*** %5
%55 = load i8*, i8** %54
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %76, label %58
58: ; preds = %53
br label %59
59: ; preds = %64, %58
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i32 1
store i8** %61, i8*** %5
%62 = load i8*, i8** %61
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %75
64: ; preds = %59
%65 = load i8**, i8*** %5
%66 = load i8*, i8** %65
%67 = load i8**, i8*** %5
%68 = load i8*, i8** %67
%69 = load i32, i32* @F_OK
%70 = call i64 @access(i8* %68, i32 %69)
%71 = icmp ne i64 %70, 0
%72 = zext i1 %71 to i64
%73 = select i1 %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0)
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %66, i8* %73)
br label %59
75: ; preds = %59
br label %96
76: ; preds = %53, %49
%77 = load i8**, i8*** %5
%78 = load i8*, i8** %77
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %90
80: ; preds = %76
%81 = load i8**, i8*** %5
%82 = load i8*, i8** %81
%83 = call i32 @strcmp(i8* %82, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%84 = icmp ne i32 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i32 1
store i8** %87, i8*** %5
%88 = load i8*, i8** %87
%89 = call i32 @server(i8* %88)
br label %95
90: ; preds = %80, %76
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i32 -1
store i8** %92, i8*** %5
%93 = load i8*, i8** %92
%94 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %90, %85
br label %96
96: ; preds = %95, %75
br label %97
97: ; preds = %96, %48
br label %98
98: ; preds = %97, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"add\00"
@S_IFREG = global i32 0
@.str.1 = [5 x i8] c"drop\00"
@.str.2 = [4 x i8] c"ask\00"
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@F_OK = global i32 0
@.str.4 = [7 x i8] c"DENIED\00"
@.str.5 = [8 x i8] c"ALLOWED\00"
@.str.6 = [7 x i8] c"server\00"
@.str.7 = [40 x i8] c"usage: %s add|drop|ask|server files...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %61, label %6
6: ; preds = %2
%7 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %64, label %13
13: ; preds = %9, %13
%14 = phi i8* [ %20, %13 ], [ %11, %9 ]
%15 = phi i8** [ %19, %13 ], [ %10, %9 ]
%16 = load i32, i32* @S_IFREG
%17 = or i32 %16, 420
%18 = tail call i32 @mknod(i8* %14, i32 %17, i32 0)
%19 = getelementptr inbounds i8*, i8** %15, i64 1
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %64, label %13
22: ; preds = %6
%23 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %64, label %29
29: ; preds = %25, %29
%30 = phi i8* [ %34, %29 ], [ %27, %25 ]
%31 = phi i8** [ %33, %29 ], [ %26, %25 ]
%32 = tail call i32 @unlink(i8* %30)
%33 = getelementptr inbounds i8*, i8** %31, i64 1
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %64, label %29
36: ; preds = %22
%37 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = getelementptr inbounds i8*, i8** %1, i64 2
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %64, label %43
43: ; preds = %39, %43
%44 = phi i8* [ %52, %43 ], [ %41, %39 ]
%45 = phi i8** [ %51, %43 ], [ %40, %39 ]
%46 = load i32, i32* @F_OK
%47 = tail call i64 @access(i8* %44, i32 %46)
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0)
%50 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %49)
%51 = getelementptr inbounds i8*, i8** %45, i64 1
%52 = load i8*, i8** %51
%53 = icmp eq i8* %52, null
br i1 %53, label %64, label %43
54: ; preds = %36
%55 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = getelementptr inbounds i8*, i8** %1, i64 2
%59 = load i8*, i8** %58
%60 = tail call i32 @server(i8* %59)
br label %64
61: ; preds = %2, %54
%62 = load i8*, i8** %1
%63 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %43, %29, %13, %39, %25, %9, %57, %61
ret i32 0
}