#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 strlen(char const *);
int THPipeFile_mode(const char *mode, int *isReadable, int *isWritable) {
  *isReadable = 0;
  *isWritable = 0;
  if (strlen(mode) == 1) {
    if (*mode == 'r') {
      *isReadable = 1;
      return 1;
    } else if (*mode == 'w') {
      *isWritable = 1;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<THPipeFile_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    11a0 <THPipeFile_mode+0x90>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
jne    1170 <THPipeFile_mode+0x60>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a7 <THPipeFile_mode+0x97>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x77,%eax
jne    1196 <THPipeFile_mode+0x86>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a7 <THPipeFile_mode+0x97>
jmp    119b <THPipeFile_mode+0x8b>
jmp    11a0 <THPipeFile_mode+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<THPipeFile_mode>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1153 <THPipeFile_mode+0x43>
mov    (%rbx),%cl
cmp    $0x72,%cl
je     1147 <THPipeFile_mode+0x37>
cmp    $0x77,%cl
jne    1153 <THPipeFile_mode+0x43>
mov    %r14,%r15
movl   $0x1,(%r15)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @THPipeFile_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** %6
store i32 0, i32* %8
%9 = load i32*, i32** %7
store i32 0, i32* %9
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %29
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 114
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32*, i32** %6
store i32 1, i32* %19
store i32 1, i32* %4
br label %30
20: ; preds = %13
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 119
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i32*, i32** %7
store i32 1, i32* %26
store i32 1, i32* %4
br label %30
27: ; preds = %20
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28, %3
store i32 0, i32* %4
br label %30
30: ; preds = %29, %25, %18
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @THPipeFile_mode(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
store i32 0, i32* %1
store i32 0, i32* %2
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = load i8, i8* %0
switch i8 %7, label %11 [
i8 114, label %9
i8 119, label %8
]
8: ; preds = %6
br label %9
9: ; preds = %6, %8
%10 = phi i32* [ %2, %8 ], [ %1, %6 ]
store i32 1, i32* %10
br label %11
11: ; preds = %9, %3, %6
%12 = phi i32 [ 0, %6 ], [ 0, %3 ], [ 1, %9 ]
ret i32 %12
}