#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*/ FILE;

/* Variables and functions */
int check_configuration_permissions(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *, char const *);
int do_test_configuration_permissions(const char *path) {
  FILE *f = fopen(path, "r");
  if (f == NULL) {
    printf("FAIL: couldn't open path: %s\n", path);
    return 0;
  }
  int ret = check_configuration_permissions(f);
  fclose(f);
  return ret;
}


x86 assembly (clang, -O0):
<do_test_configuration_permissions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1187 <do_test_configuration_permissions+0x47>
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <do_test_configuration_permissions+0x62>
mov    -0x18(%rbp),%rdi
call   1030 <check_configuration_permissions@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test_configuration_permissions>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1171 <do_test_configuration_permissions+0x31>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <check_configuration_permissions@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
jmp    1182 <do_test_configuration_permissions+0x42>
lea    0xe8a(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [30 x i8] c"FAIL: couldn't open path: %s\0A\00"
define i32 @do_test_configuration_permissions(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %2
br label %19
13: ; preds = %1
%14 = load i32*, i32** %4
%15 = call i32 @check_configuration_permissions(i32* %14)
store i32 %15, i32* %5
%16 = load i32*, i32** %4
%17 = call i32 @fclose(i32* %16)
%18 = load i32, i32* %5
store i32 %18, i32* %2
br label %19
19: ; preds = %13, %10
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [30 x i8] c"FAIL: couldn't open path: %s\0A\00"
define i32 @do_test_configuration_permissions(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %9
6: ; preds = %1
%7 = tail call i32 @check_configuration_permissions(i32* %2)
%8 = tail call i32 @fclose(i32* %2)
br label %9
9: ; preds = %6, %4
%10 = phi i32 [ 0, %4 ], [ %7, %6 ]
ret i32 %10
}