#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 get_permissoins();
int /*<<< orphan*/ printf(char *);
void read_perms(int perms) {
  if (perms == 0)
    perms = get_permissoins();
  printf("Set permissions: \n");
  if (perms & 1 << 1)
    printf("\t BLOCK_ALL\n");
  if (perms & 1 << 0)
    printf("\t ALLOW_ALL\n");
  if (perms & 1 << 2)
    printf("\t BLOCK_USBHID\n");
  if (perms & 1 << 3)
    printf("\t BLOCK_USB_INTERFACE\n");
}


x86 assembly (clang, -O0):
<read_perms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113f <read_perms+0x1f>
mov    $0x0,%al
call   1040 <get_permissoins@plt>
mov    %eax,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1166 <read_perms+0x46>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1181 <read_perms+0x61>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     119c <read_perms+0x7c>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11b7 <read_perms+0x97>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_perms>:
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
jne    1130 <read_perms+0x10>
xor    %eax,%eax
call   1040 <get_permissoins@plt>
mov    %eax,%ebx
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
test   $0x2,%bl
jne    1152 <read_perms+0x32>
test   $0x1,%bl
jne    1163 <read_perms+0x43>
test   $0x4,%bl
jne    1174 <read_perms+0x54>
test   $0x8,%bl
jne    1185 <read_perms+0x65>
pop    %rbx
ret
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
test   $0x1,%bl
je     1146 <read_perms+0x26>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
test   $0x4,%bl
je     114b <read_perms+0x2b>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
test   $0x8,%bl
je     1150 <read_perms+0x30>
lea    0xe86(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Set permissions: \0A\00"
@.str.1 = [13 x i8] c"\09 BLOCK_ALL\0A\00"
@.str.2 = [13 x i8] c"\09 ALLOW_ALL\0A\00"
@.str.3 = [16 x i8] c"\09 BLOCK_USBHID\0A\00"
@.str.4 = [23 x i8] c"\09 BLOCK_USB_INTERFACE\0A\00"
define void @read_perms(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (...) @get_permissoins()
store i32 %6, i32* %2
br label %7
7: ; preds = %5, %1
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = and i32 %9, 2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
%15 = load i32, i32* %2
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* %2
%22 = and i32 %21, 4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %2
%28 = and i32 %27, 8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"Set permissions: \00"
@str.5 = [22 x i8] c"\09 BLOCK_USB_INTERFACE\00"
@str.6 = [15 x i8] c"\09 BLOCK_USBHID\00"
@str.7 = [12 x i8] c"\09 ALLOW_ALL\00"
@str.8 = [12 x i8] c"\09 BLOCK_ALL\00"
define void @read_perms(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (...) @get_permissoins()
br label %5
5: ; preds = %3, %1
%6 = phi i32 [ %4, %3 ], [ %0, %1 ]
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = and i32 %6, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = and i32 %6, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.7, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = and i32 %6, 4
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = and i32 %6, 8
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
ret void
}