#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 */
scalar_t__ strstr(char const *, char *);
void interpret_mode(const char *mode, int *in, int *out, int *close_on_exec) {
  *in = 0;
  *out = 0;
  *close_on_exec = 0;
  if (strstr(mode, "r"))
    *in = 1;
  if (strstr(mode, "w"))
    *out = 1;
  if (strstr(mode, "+")) {
    *in = 1;
    *out = 1;
  }
  if (strstr(mode, "e")) {
    *close_on_exec = 1;
  }
}


x86 assembly (clang, -O0):
<interpret_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     116a <interpret_mode+0x5a>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     118e <interpret_mode+0x7e>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11bc <interpret_mode+0xac>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11e0 <interpret_mode+0xd0>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpret_mode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
movl   $0x0,(%rcx)
lea    0xec3(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     114f <interpret_mode+0x3f>
movl   $0x1,(%r12)
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     116a <interpret_mode+0x5a>
movl   $0x1,(%r15)
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     118d <interpret_mode+0x7d>
movl   $0x1,(%r12)
movl   $0x1,(%r15)
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11a8 <interpret_mode+0x98>
movl   $0x1,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"e\00"
define void @interpret_mode(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i32*, i32** %6
store i32 0, i32* %9
%10 = load i32*, i32** %7
store i32 0, i32* %10
%11 = load i32*, i32** %8
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = load i32*, i32** %6
store i32 1, i32* %16
br label %17
17: ; preds = %15, %4
%18 = load i8*, i8** %5
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32*, i32** %7
store i32 1, i32* %22
br label %23
23: ; preds = %21, %17
%24 = load i8*, i8** %5
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32*, i32** %6
store i32 1, i32* %28
%29 = load i32*, i32** %7
store i32 1, i32* %29
br label %30
30: ; preds = %27, %23
%31 = load i8*, i8** %5
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32*, i32** %8
store i32 1, i32* %35
br label %36
36: ; preds = %34, %30
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"e\00"
define void @interpret_mode(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %4
store i32 1, i32* %1
br label %8
8: ; preds = %7, %4
%9 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8
store i32 1, i32* %2
br label %12
12: ; preds = %11, %8
%13 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %12
store i32 1, i32* %1
store i32 1, i32* %2
br label %16
16: ; preds = %15, %12
%17 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
store i32 1, i32* %3
br label %20
20: ; preds = %19, %16
ret void
}