#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 */
typedef int /*<<< orphan*/ ret;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int get_permissoins() {
  FILE *fp;
  int ret;
  if ((fp = fopen("/tmp/udev_paranoia_protection", "r")) == NULL)
    return 1 << 0;
  if (fread(&ret, sizeof(ret), 1, fp) != 1) {
    ret = 1 << 0;
  }
  fclose(fp);
  return ret;
}


x86 assembly (clang, -O0):
<get_permissoins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1165 <get_permissoins+0x35>
movl   $0x1,-0x4(%rbp)
jmp    119b <get_permissoins+0x6b>
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     118c <get_permissoins+0x5c>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_permissoins>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xedd(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     117d <get_permissoins+0x4d>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1173 <get_permissoins+0x43>
mov    0x4(%rsp),%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1182 <get_permissoins+0x52>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"/tmp/udev_paranoia_protection\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @get_permissoins() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 1, i32* %1
br label %16
7: ; preds = %0
%8 = load i32*, i32** %2
%9 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %8)
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 1, i32* %3
br label %12
12: ; preds = %11, %7
%13 = load i32*, i32** %2
%14 = call i32 @fclose(i32* %13)
%15 = load i32, i32* %3
store i32 %15, i32* %1
br label %16
16: ; preds = %12, %6
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [30 x i8] c"/tmp/udev_paranoia_protection\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @get_permissoins() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %0
%6 = call i32 @fread(i32* %1, i32 4, i32 1, i32* %3)
%7 = icmp eq i32 %6, 1
%8 = load i32, i32* %1
%9 = select i1 %7, i32 %8, i32 1
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %0, %5
%12 = phi i32 [ %9, %5 ], [ 1, %0 ]
ret i32 %12
}