#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fputs("A room value and an option are needed to be analysed\n", stderr);
    return 1;
  }
  char *endptr;
  int value = strtol(argv[1], &endptr, 10);
  if (*endptr != '\0') {
    fputs("The given value is not a valid integer\n", stderr);
    return 1;
  }
  if (strcmp(argv[2], "used") == 0) {
    printf("%d", value != 0);
  } else if (strcmp(argv[2], "entrance") == 0) {
    printf("%d", ((value & 0x02) == 0x02));
  } else if (strcmp(argv[2], "north") == 0) {
    printf("%d", ((value & 0x04) == 0x04));
  } else if (strcmp(argv[2], "west") == 0) {
    printf("%d", ((value & 0x20) == 0x20));
  } else if (strcmp(argv[2], "south") == 0) {
    printf("%d", ((value & 0x10) == 0x10));
  } else if (strcmp(argv[2], "east") == 0) {
    printf("%d", ((value & 0x08) == 0x08));
  } else {
    fputs("The given option is not valid\n", stderr);
    return 1;
  }
  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)
cmpl   $0x3,-0x8(%rbp)
je     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1387 <main+0x247>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cb <main+0x8b>
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1387 <main+0x247>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1206 <main+0xc6>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    1380 <main+0x240>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1246 <main+0x106>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
jmp    137b <main+0x23b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1286 <main+0x146>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
jmp    1376 <main+0x236>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12c6 <main+0x186>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x20,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xda7(%rip),%rdi
call   1030 <printf@plt>
jmp    1371 <main+0x231>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xda5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1306 <main+0x1c6>
mov    -0x1c(%rbp),%eax
and    $0x10,%eax
cmp    $0x10,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xd67(%rip),%rdi
call   1030 <printf@plt>
jmp    136c <main+0x22c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd6b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1346 <main+0x206>
mov    -0x1c(%rbp),%eax
and    $0x8,%eax
cmp    $0x8,%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xd27(%rip),%rdi
call   1030 <printf@plt>
jmp    1367 <main+0x227>
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
lea    0xd2f(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1387 <main+0x247>
jmp    136c <main+0x22c>
jmp    1371 <main+0x231>
jmp    1376 <main+0x236>
jmp    137b <main+0x23b>
jmp    1380 <main+0x240>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1179 <main+0x39>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     119a <main+0x5a>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
jmp    1189 <main+0x49>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    0xe77(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x10(%rbx),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     122d <main+0xed>
mov    0x10(%rbx),%rdi
lea    0xeac(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     123e <main+0xfe>
mov    0x10(%rbx),%rdi
lea    0xea0(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1242 <main+0x102>
mov    0x10(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1247 <main+0x107>
mov    0x10(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     124c <main+0x10c>
mov    0x10(%rbx),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1251 <main+0x111>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
lea    0xe5d(%rip),%rdi
jmp    1189 <main+0x49>
xor    %esi,%esi
test   %ebp,%ebp
setne  %sil
lea    0xe27(%rip),%rdi
jmp    1260 <main+0x120>
shr    %ebp
jmp    1254 <main+0x114>
shr    $0x2,%ebp
jmp    1254 <main+0x114>
shr    $0x5,%ebp
jmp    1254 <main+0x114>
shr    $0x4,%ebp
jmp    1254 <main+0x114>
shr    $0x3,%ebp
and    $0x1,%ebp
lea    0xe05(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    1193 <main+0x53>

LLVM IR (-O0):
@.str = [54 x i8] c"A room value and an option are needed to be analysed\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"The given value is not a valid integer\0A\00"
@.str.2 = [5 x i8] c"used\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"entrance\00"
@.str.5 = [6 x i8] c"north\00"
@.str.6 = [5 x i8] c"west\00"
@.str.7 = [6 x i8] c"south\00"
@.str.8 = [5 x i8] c"east\00"
@.str.9 = [31 x i8] c"The given option is not valid\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 1, i32* %3
br label %105
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i8** %6, i32 10)
store i32 %17, i32* %7
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = call i32 @fputs(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 1, i32* %3
br label %105
25: ; preds = %13
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %104
36: ; preds = %25
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %36
%43 = load i32, i32* %7
%44 = and i32 %43, 2
%45 = icmp eq i32 %44, 2
%46 = zext i1 %45 to i32
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %103
48: ; preds = %36
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %48
%55 = load i32, i32* %7
%56 = and i32 %55, 4
%57 = icmp eq i32 %56, 4
%58 = zext i1 %57 to i32
%59 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %102
60: ; preds = %48
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %60
%67 = load i32, i32* %7
%68 = and i32 %67, 32
%69 = icmp eq i32 %68, 32
%70 = zext i1 %69 to i32
%71 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %70)
br label %101
72: ; preds = %60
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %72
%79 = load i32, i32* %7
%80 = and i32 %79, 16
%81 = icmp eq i32 %80, 16
%82 = zext i1 %81 to i32
%83 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %82)
br label %100
84: ; preds = %72
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 2
%87 = load i8*, i8** %86
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %96
90: ; preds = %84
%91 = load i32, i32* %7
%92 = and i32 %91, 8
%93 = icmp eq i32 %92, 8
%94 = zext i1 %93 to i32
%95 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %94)
br label %99
96: ; preds = %84
%97 = load i32, i32* @stderr
%98 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %97)
store i32 1, i32* %3
br label %105
99: ; preds = %90
br label %100
100: ; preds = %99, %78
br label %101
101: ; preds = %100, %66
br label %102
102: ; preds = %101, %54
br label %103
103: ; preds = %102, %42
br label %104
104: ; preds = %103, %31
store i32 0, i32* %3
br label %105
105: ; preds = %104, %96, %22, %10
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@.str = [54 x i8] c"A room value and an option are needed to be analysed\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"The given value is not a valid integer\0A\00"
@.str.2 = [5 x i8] c"used\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"entrance\00"
@.str.5 = [6 x i8] c"north\00"
@.str.6 = [5 x i8] c"west\00"
@.str.7 = [6 x i8] c"south\00"
@.str.8 = [5 x i8] c"east\00"
@.str.9 = [31 x i8] c"The given option is not valid\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %73
8: ; preds = %2
%9 = bitcast i8** %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strtol(i8* %11, i8** %3, i32 10)
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = tail call i32 @fputs(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %71
19: ; preds = %8
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = icmp ne i32 %12, 0
%26 = zext i1 %25 to i32
%27 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %71
28: ; preds = %19
%29 = load i8*, i8** %20
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = lshr i32 %12, 1
%34 = and i32 %33, 1
%35 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %71
36: ; preds = %28
%37 = load i8*, i8** %20
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = lshr i32 %12, 2
%42 = and i32 %41, 1
%43 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %71
44: ; preds = %36
%45 = load i8*, i8** %20
%46 = tail call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = lshr i32 %12, 5
%50 = and i32 %49, 1
%51 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %50)
br label %71
52: ; preds = %44
%53 = load i8*, i8** %20
%54 = tail call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = lshr i32 %12, 4
%58 = and i32 %57, 1
%59 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %71
60: ; preds = %52
%61 = load i8*, i8** %20
%62 = tail call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = lshr i32 %12, 3
%66 = and i32 %65, 1
%67 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %71
68: ; preds = %60
%69 = load i32, i32* @stderr
%70 = tail call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %24, %40, %56, %64, %48, %32, %68, %16
%72 = phi i32 [ 1, %16 ], [ 1, %68 ], [ 0, %32 ], [ 0, %48 ], [ 0, %64 ], [ 0, %56 ], [ 0, %40 ], [ 0, %24 ]
br label %73
73: ; preds = %71, %5
%74 = phi i32 [ 1, %5 ], [ %72, %71 ]
ret i32 %74
}