#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 *file_read(char const *);
scalar_t__ file_size(char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int file_yorn(const char *fname) {
  char *s;
  char buff[10];
  if (!(file_size(fname) >= 0))
    return 0;
  s = file_read(fname);
  if (!s)
    return 0;
  snprintf(buff, 10, "%s", s);
  free(s);
  buff[9] = '\0';
  if (!strncmp(buff, "y", 1)) {
    return 1;
  }
  if (!strncmp(buff, "1", 1)) {
    return 1;
  }
  if (!strncmp(buff, "true", 4)) {
    return 1;
  }
  if (!strncmp(buff, "enabled", 7)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_yorn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <file_size@plt>
cmp    $0x0,%rax
jge    117b <file_yorn+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
mov    -0x10(%rbp),%rdi
call   1070 <file_read@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119f <file_yorn+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
lea    -0x22(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xa,%esi
lea    0xe4d(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movb   $0x0,-0x19(%rbp)
lea    -0x22(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11ef <file_yorn+0x9f>
movl   $0x1,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
lea    -0x22(%rbp),%rdi
lea    0xe0b(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1219 <file_yorn+0xc9>
movl   $0x1,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
lea    -0x22(%rbp),%rdi
lea    0xde3(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1243 <file_yorn+0xf3>
movl   $0x1,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
lea    -0x22(%rbp),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    126d <file_yorn+0x11d>
movl   $0x1,-0x4(%rbp)
jmp    1274 <file_yorn+0x124>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_yorn>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1060 <file_size@plt>
xor    %ebp,%ebp
test   %rax,%rax
js     121c <file_yorn+0xcc>
mov    %rbx,%rdi
call   1070 <file_read@plt>
test   %rax,%rax
je     121c <file_yorn+0xcc>
mov    %rax,%rbx
lea    0xe7a(%rip),%rdx
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movb   $0x0,0xf(%rsp)
lea    0xe54(%rip),%rsi
mov    $0x1,%ebp
mov    %r14,%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     121c <file_yorn+0xcc>
lea    0xe39(%rip),%rsi
lea    0x6(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     121c <file_yorn+0xcc>
lea    0xe1c(%rip),%rsi
lea    0x6(%rsp),%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     121c <file_yorn+0xcc>
lea    0xe07(%rip),%rsi
lea    0x6(%rsp),%rdi
mov    $0x7,%edx
call   1040 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [8 x i8] c"enabled\00"
define i32 @file_yorn(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [10 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @file_size(i8* %6)
%8 = icmp sge i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 0, i32* %2
br label %43
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @file_read(i8* %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %10
store i32 0, i32* %2
br label %43
16: ; preds = %10
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i32 @snprintf(i8* %17, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 9
store i8 0, i8* %22
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%24 = call i32 @strncmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %16
store i32 1, i32* %2
br label %43
27: ; preds = %16
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%29 = call i32 @strncmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27
store i32 1, i32* %2
br label %43
32: ; preds = %27
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%34 = call i32 @strncmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i32 1, i32* %2
br label %43
37: ; preds = %32
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%39 = call i32 @strncmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 7)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i32 1, i32* %2
br label %43
42: ; preds = %37
store i32 0, i32* %2
br label %43
43: ; preds = %42, %41, %36, %31, %26, %15, %9
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [8 x i8] c"enabled\00"
define i32 @file_yorn(i8* %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @file_size(i8* %0)
%5 = icmp sgt i64 %4, -1
br i1 %5, label %6, label %25
6: ; preds = %1
%7 = tail call i8* @file_read(i8* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = call i32 @snprintf(i8* %3, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%11 = call i32 @free(i8* %7)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
store i8 0, i8* %12
%13 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %9
%16 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 7)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %18, %15, %9, %6, %1
%26 = phi i32 [ 0, %1 ], [ 0, %6 ], [ 1, %9 ], [ 1, %15 ], [ 1, %18 ], [ %24, %21 ]
ret i32 %26
}