#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*/ cgi_error(char *, char const *);
int cgi_check_mode(char const *filename, int file_mode, int mode_wanted) {
  if (mode_wanted == 0 && file_mode == 1) {
    cgi_error("File %s not open for reading", filename);
    return 1;
  }
  if (mode_wanted == 1 && file_mode == 0) {
    cgi_error("File %s not open for writing", filename);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cgi_check_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1152 <cgi_check_mode+0x42>
cmpl   $0x1,-0x14(%rbp)
jne    1152 <cgi_check_mode+0x42>
mov    -0x10(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1030 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    1189 <cgi_check_mode+0x79>
cmpl   $0x1,-0x18(%rbp)
jne    1182 <cgi_check_mode+0x72>
cmpl   $0x0,-0x14(%rbp)
jne    1182 <cgi_check_mode+0x72>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    1189 <cgi_check_mode+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_check_mode>:
mov    %rdi,%rcx
cmp    $0x1,%esi
jne    1125 <cgi_check_mode+0x15>
test   %edx,%edx
jne    1125 <cgi_check_mode+0x15>
lea    0xedd(%rip),%rdi
jmp    1137 <cgi_check_mode+0x27>
xor    %eax,%eax
test   %esi,%esi
jne    1149 <cgi_check_mode+0x39>
cmp    $0x1,%edx
jne    1149 <cgi_check_mode+0x39>
lea    0xee6(%rip),%rdi
push   %rax
mov    %rcx,%rsi
call   1030 <cgi_error@plt>
mov    $0x1,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"File %s not open for reading\00"
@.str.1 = [29 x i8] c"File %s not open for writing\00"
define i32 @cgi_check_mode(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = call i32 @cgi_error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %4
br label %26
16: ; preds = %10, %3
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %5
%24 = call i32 @cgi_error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %4
br label %26
25: ; preds = %19, %16
store i32 0, i32* %4
br label %26
26: ; preds = %25, %22, %13
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [29 x i8] c"File %s not open for reading\00"
@.str.1 = [29 x i8] c"File %s not open for writing\00"
define i32 @cgi_check_mode(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = icmp eq i32 %1, 1
%6 = and i1 %5, %4
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = icmp eq i32 %2, 1
%9 = icmp eq i32 %1, 0
%10 = and i1 %9, %8
br i1 %10, label %11, label %14
11: ; preds = %7, %3
%12 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %7 ]
%13 = tail call i32 @cgi_error(i8* %12, i8* %0)
br label %14
14: ; preds = %11, %7
%15 = phi i32 [ 0, %7 ], [ 1, %11 ]
ret i32 %15
}