#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 */
char *index(char *, char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
char *strsep(char **, char const *);
int parse_app_opts(char *app_opts, int verbose_mode) {
  char *tok, *comment;
  const char *delim = " \t";
  int found_comment = 0;
  int opts = 0;
  opts = opts & 0xfffffb;
  opts = opts & 0xfffff7;
  tok = strsep(&app_opts, delim);
  while (tok) {
    if (tok[0] != '\0') {
      if (comment = index(tok, '#')) {
        comment[0] = '\0';
        if (tok[0] != '\0')
          found_comment = 1;
        else
          break;
      }
      if (!(strcmp(tok, "PERMIT_APP"))) {
        if (verbose_mode)
          printf("PERMIT_APP ");
        opts = opts | 1;
        opts = opts | 4;
      } else if (!(strcmp(tok, "PERMIT_SERVER"))) {
        if (verbose_mode)
          printf("PERMIT_SERVER ");
        opts = opts | 2;
        opts = opts | 8;
      } else if (!(strcmp(tok, "DENY_SERVER"))) {
        if (verbose_mode)
          printf("DENY_SERVER ");
        opts = opts & 0xfffffd;
        opts = opts | 8;
      } else if (!(strcmp(tok, "DENY_APP"))) {
        if (verbose_mode)
          printf("DENY_APP ");
        opts = opts & 0xfffffe;
        opts = opts | 4;
      } else
        printf("(err parsing file: %s) ", tok);
      if (found_comment)
        break;
    }
    tok = strsep(&app_opts, delim);
  }
  return opts;
}


x86 assembly (clang, -O0):
<parse_app_opts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
and    $0xfffffb,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
and    $0xfffff7,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1362 <parse_app_opts+0x222>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     134c <parse_app_opts+0x20c>
mov    -0x18(%rbp),%rdi
mov    $0x23,%esi
call   1040 <index@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11f3 <parse_app_opts+0xb3>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e9 <parse_app_opts+0xa9>
movl   $0x1,-0x2c(%rbp)
jmp    11ee <parse_app_opts+0xae>
jmp    1362 <parse_app_opts+0x222>
jmp    11f3 <parse_app_opts+0xb3>
mov    -0x18(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    123b <parse_app_opts+0xfb>
cmpl   $0x0,-0xc(%rbp)
je     1224 <parse_app_opts+0xe4>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x30(%rbp)
jmp    1338 <parse_app_opts+0x1f8>
mov    -0x18(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1283 <parse_app_opts+0x143>
cmpl   $0x0,-0xc(%rbp)
je     126c <parse_app_opts+0x12c>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x30(%rbp)
jmp    1333 <parse_app_opts+0x1f3>
mov    -0x18(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12cd <parse_app_opts+0x18d>
cmpl   $0x0,-0xc(%rbp)
je     12b4 <parse_app_opts+0x174>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0xfffffd,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x30(%rbp)
jmp    132e <parse_app_opts+0x1ee>
mov    -0x18(%rbp),%rdi
lea    0xd78(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1317 <parse_app_opts+0x1d7>
cmpl   $0x0,-0xc(%rbp)
je     12fe <parse_app_opts+0x1be>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0xfffffe,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x30(%rbp)
jmp    1329 <parse_app_opts+0x1e9>
mov    -0x18(%rbp),%rsi
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132e <parse_app_opts+0x1ee>
jmp    1333 <parse_app_opts+0x1f3>
jmp    1338 <parse_app_opts+0x1f8>
cmpl   $0x0,-0x2c(%rbp)
je     1347 <parse_app_opts+0x207>
jmp    1362 <parse_app_opts+0x222>
jmp    134c <parse_app_opts+0x20c>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
call   1060 <strsep@plt>
mov    %rax,-0x18(%rbp)
jmp    118f <parse_app_opts+0x4f>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_app_opts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,(%rsp)
lea    0xea8(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strsep@plt>
test   %rax,%rax
je     12b5 <parse_app_opts+0x175>
mov    %rax,%r12
lea    0xe8d(%rip),%r14
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    11a3 <parse_app_opts+0x63>
nopw   0x0(%rax,%rax,1)
or     $0x5,%ebp
test   %r13,%r13
jne    12b7 <parse_app_opts+0x177>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strsep@plt>
mov    %rax,%r12
test   %rax,%rax
je     12b7 <parse_app_opts+0x177>
cmpb   $0x0,(%r12)
je     118c <parse_app_opts+0x4c>
mov    %r12,%rdi
mov    $0x23,%esi
call   1040 <index@plt>
mov    %rax,%r13
test   %rax,%rax
je     11cf <parse_app_opts+0x8f>
movb   $0x0,0x0(%r13)
cmpb   $0x0,(%r12)
je     12b7 <parse_app_opts+0x177>
mov    %r12,%rdi
lea    0xe2a(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1240 <parse_app_opts+0x100>
mov    %r12,%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     125b <parse_app_opts+0x11b>
mov    %r12,%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1275 <parse_app_opts+0x135>
mov    %r12,%rdi
lea    0xe3e(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1295 <parse_app_opts+0x155>
lea    0xe41(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1183 <parse_app_opts+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
je     1180 <parse_app_opts+0x40>
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1180 <parse_app_opts+0x40>
test   %ebx,%ebx
je     126d <parse_app_opts+0x12d>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
or     $0xa,%ebp
jmp    1183 <parse_app_opts+0x43>
test   %ebx,%ebx
je     1287 <parse_app_opts+0x147>
lea    0xdc3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
and    $0xfffff5,%ebp
or     $0x8,%ebp
jmp    1183 <parse_app_opts+0x43>
test   %ebx,%ebx
je     12a7 <parse_app_opts+0x167>
lea    0xdb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
and    $0xfffffa,%ebp
or     $0x4,%ebp
jmp    1183 <parse_app_opts+0x43>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@.str.1 = [11 x i8] c"PERMIT_APP\00"
@.str.2 = [12 x i8] c"PERMIT_APP \00"
@.str.3 = [14 x i8] c"PERMIT_SERVER\00"
@.str.4 = [15 x i8] c"PERMIT_SERVER \00"
@.str.5 = [12 x i8] c"DENY_SERVER\00"
@.str.6 = [13 x i8] c"DENY_SERVER \00"
@.str.7 = [9 x i8] c"DENY_APP\00"
@.str.8 = [10 x i8] c"DENY_APP \00"
@.str.9 = [24 x i8] c"(err parsing file: %s) \00"
define i32 @parse_app_opts(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %9
%11 = and i32 %10, 16777211
store i32 %11, i32* %9
%12 = load i32, i32* %9
%13 = and i32 %12, 16777207
store i32 %13, i32* %9
%14 = load i8*, i8** %7
%15 = call i8* @strsep(i8** %3, i8* %14)
store i8* %15, i8** %5
br label %16
16: ; preds = %107, %2
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %110
19: ; preds = %16
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %107
25: ; preds = %19
%26 = load i8*, i8** %5
%27 = call i8* @index(i8* %26, i8 signext 35)
store i8* %27, i8** %6
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 0, i8* %31
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %29
store i32 1, i32* %8
br label %39
38: ; preds = %29
br label %110
39: ; preds = %37
br label %40
40: ; preds = %39, %25
%41 = load i8*, i8** %5
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %54, label %44
44: ; preds = %40
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = load i32, i32* %9
%51 = or i32 %50, 1
store i32 %51, i32* %9
%52 = load i32, i32* %9
%53 = or i32 %52, 4
store i32 %53, i32* %9
br label %102
54: ; preds = %40
%55 = load i8*, i8** %5
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %68, label %58
58: ; preds = %54
%59 = load i32, i32* %4
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = load i32, i32* %9
%65 = or i32 %64, 2
store i32 %65, i32* %9
%66 = load i32, i32* %9
%67 = or i32 %66, 8
store i32 %67, i32* %9
br label %101
68: ; preds = %54
%69 = load i8*, i8** %5
%70 = call i32 @strcmp(i8* %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %82, label %72
72: ; preds = %68
%73 = load i32, i32* %4
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
%78 = load i32, i32* %9
%79 = and i32 %78, 16777213
store i32 %79, i32* %9
%80 = load i32, i32* %9
%81 = or i32 %80, 8
store i32 %81, i32* %9
br label %100
82: ; preds = %68
%83 = load i8*, i8** %5
%84 = call i32 @strcmp(i8* %83, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%85 = icmp ne i32 %84, 0
br i1 %85, label %96, label %86
86: ; preds = %82
%87 = load i32, i32* %4
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %91
91: ; preds = %89, %86
%92 = load i32, i32* %9
%93 = and i32 %92, 16777214
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = or i32 %94, 4
store i32 %95, i32* %9
br label %99
96: ; preds = %82
%97 = load i8*, i8** %5
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %96, %91
br label %100
100: ; preds = %99, %77
br label %101
101: ; preds = %100, %63
br label %102
102: ; preds = %101, %49
%103 = load i32, i32* %8
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %102
br label %110
106: ; preds = %102
br label %107
107: ; preds = %106, %19
%108 = load i8*, i8** %7
%109 = call i8* @strsep(i8** %3, i8* %108)
store i8* %109, i8** %5
br label %16
110: ; preds = %105, %38, %16
%111 = load i32, i32* %9
ret i32 %111
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@.str.1 = [11 x i8] c"PERMIT_APP\00"
@.str.2 = [12 x i8] c"PERMIT_APP \00"
@.str.3 = [14 x i8] c"PERMIT_SERVER\00"
@.str.4 = [15 x i8] c"PERMIT_SERVER \00"
@.str.5 = [12 x i8] c"DENY_SERVER\00"
@.str.6 = [13 x i8] c"DENY_SERVER \00"
@.str.7 = [9 x i8] c"DENY_APP\00"
@.str.8 = [10 x i8] c"DENY_APP \00"
@.str.9 = [24 x i8] c"(err parsing file: %s) \00"
define i32 @parse_app_opts(i8* %0, i32 %1) {
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %61, label %6
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br label %8
8: ; preds = %6, %57
%9 = phi i32 [ 0, %6 ], [ %58, %57 ]
%10 = phi i8* [ %4, %6 ], [ %59, %57 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %57, label %13
13: ; preds = %8
%14 = call i8* @index(i8* %10, i8 signext 35)
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %13
store i8 0, i8* %14
%17 = load i8, i8* %10
%18 = icmp eq i8 %17, 0
br i1 %18, label %61, label %19
19: ; preds = %16, %13
%20 = call i32 @strcmp(i8* %10, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
br i1 %7, label %25, label %23
23: ; preds = %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %22
%26 = or i32 %9, 5
br label %55
27: ; preds = %19
%28 = call i32 @strcmp(i8* %10, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
br i1 %7, label %33, label %31
31: ; preds = %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %30
%34 = or i32 %9, 10
br label %55
35: ; preds = %27
%36 = call i32 @strcmp(i8* %10, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %35
br i1 %7, label %41, label %39
39: ; preds = %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %39, %38
%42 = and i32 %9, 16777205
%43 = or i32 %42, 8
br label %55
44: ; preds = %35
%45 = call i32 @strcmp(i8* %10, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %44
br i1 %7, label %50, label %48
48: ; preds = %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %50
50: ; preds = %48, %47
%51 = and i32 %9, 16777210
%52 = or i32 %51, 4
br label %55
53: ; preds = %44
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %10)
br label %55
55: ; preds = %33, %50, %53, %41, %25
%56 = phi i32 [ %9, %53 ], [ %52, %50 ], [ %43, %41 ], [ %34, %33 ], [ %26, %25 ]
br i1 %15, label %57, label %61
57: ; preds = %55, %8
%58 = phi i32 [ %56, %55 ], [ %9, %8 ]
%59 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%60 = icmp eq i8* %59, null
br i1 %60, label %61, label %8
61: ; preds = %57, %16, %55, %2
%62 = phi i32 [ 0, %2 ], [ %56, %55 ], [ %9, %16 ], [ %58, %57 ]
ret i32 %62
}