#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*/ FileExists(char *);
int ReadDebugLevel(void) {
  int level = 3;
  if (!FileExists("debuglevel.dbg")) {
    level--;
    if (!FileExists("debuglevel.err")) {
      level--;
      if (!FileExists("debuglevel.std")) {
        level--;
      }
    }
  }
  return level;
}


x86 assembly (clang, -O0):
<ReadDebugLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <FileExists@plt>
cmp    $0x0,%eax
jne    1183 <ReadDebugLevel+0x73>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
lea    0xecb(%rip),%rdi
call   1030 <FileExists@plt>
cmp    $0x0,%eax
jne    117e <ReadDebugLevel+0x6e>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <FileExists@plt>
cmp    $0x0,%eax
jne    1179 <ReadDebugLevel+0x69>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    117e <ReadDebugLevel+0x6e>
jmp    1183 <ReadDebugLevel+0x73>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadDebugLevel>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <FileExists@plt>
mov    %eax,%ecx
mov    $0x3,%eax
test   %ecx,%ecx
je     112a <ReadDebugLevel+0x1a>
pop    %rcx
ret
lea    0xede(%rip),%rdi
call   1030 <FileExists@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    1128 <ReadDebugLevel+0x18>
lea    0xed6(%rip),%rdi
call   1030 <FileExists@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"debuglevel.dbg\00"
@.str.1 = [15 x i8] c"debuglevel.err\00"
@.str.2 = [15 x i8] c"debuglevel.std\00"
define i32 @ReadDebugLevel() {
%1 = alloca i32
store i32 3, i32* %1
%2 = call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i32 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %0
%5 = load i32, i32* %1
%6 = add nsw i32 %5, -1
store i32 %6, i32* %1
%7 = call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %4
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i32, i32* %1
%16 = add nsw i32 %15, -1
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %9
br label %18
18: ; preds = %17, %4
br label %19
19: ; preds = %18, %0
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [15 x i8] c"debuglevel.dbg\00"
@.str.1 = [15 x i8] c"debuglevel.err\00"
@.str.2 = [15 x i8] c"debuglevel.std\00"
define i32 @ReadDebugLevel() {
%1 = tail call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @FileExists(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %6, %3, %0
%11 = phi i32 [ 3, %0 ], [ 2, %3 ], [ %9, %6 ]
ret i32 %11
}