#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 */
unsigned int O_APPEND;
unsigned int O_CREAT;
unsigned int O_RDONLY;
unsigned int O_RDWR;
unsigned int O_TRUNC;
unsigned int O_WRONLY;
scalar_t__ strcmp(char const *, char *);
unsigned int support_fmodes2flags(const char *mode) {
  if ((strcmp(mode, "r") == 0) || (strcmp(mode, "rb") == 0))
    return O_RDONLY;
  if ((strcmp(mode, "w") == 0) || (strcmp(mode, "wb") == 0))
    return O_WRONLY | O_CREAT | O_TRUNC;
  if ((strcmp(mode, "a") == 0) || (strcmp(mode, "ab") == 0))
    return O_WRONLY | O_CREAT | O_APPEND;
  if ((strcmp(mode, "r+") == 0) || (strcmp(mode, "rb+") == 0) ||
      (strcmp(mode, "r+b") == 0))
    return O_RDWR;
  if ((strcmp(mode, "w+") == 0) || (strcmp(mode, "wb+") == 0) ||
      (strcmp(mode, "w+b") == 0))
    return O_WRONLY | O_TRUNC | O_CREAT;
  if ((strcmp(mode, "a+") == 0) || (strcmp(mode, "ab+") == 0) ||
      (strcmp(mode, "a+b") == 0))
    return O_WRONLY | O_APPEND | O_CREAT;
  return 0;
}


x86 assembly (clang, -O0):
<support_fmodes2flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1150 <support_fmodes2flags+0x40>
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1161 <support_fmodes2flags+0x51>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1195 <support_fmodes2flags+0x85>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <support_fmodes2flags+0xa8>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    0x2e53(%rip),%rcx
or     (%rcx),%eax
mov    0x2e42(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11ec <support_fmodes2flags+0xdc>
mov    -0x10(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120f <support_fmodes2flags+0xff>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    0x2dfc(%rip),%rcx
or     (%rcx),%eax
mov    0x2dab(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
mov    -0x10(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     125d <support_fmodes2flags+0x14d>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     125d <support_fmodes2flags+0x14d>
mov    -0x10(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    126e <support_fmodes2flags+0x15e>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
mov    -0x10(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     12bc <support_fmodes2flags+0x1ac>
mov    -0x10(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     12bc <support_fmodes2flags+0x1ac>
mov    -0x10(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12df <support_fmodes2flags+0x1cf>
mov    0x2cf5(%rip),%rax
mov    (%rax),%eax
mov    0x2d24(%rip),%rcx
or     (%rcx),%eax
mov    0x2d23(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
mov    -0x10(%rbp),%rdi
lea    0xd3b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     132d <support_fmodes2flags+0x21d>
mov    -0x10(%rbp),%rdi
lea    0xd24(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     132d <support_fmodes2flags+0x21d>
mov    -0x10(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1350 <support_fmodes2flags+0x240>
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    0x2c73(%rip),%rcx
or     (%rcx),%eax
mov    0x2cb2(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <support_fmodes2flags+0x247>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<support_fmodes2flags>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1282 <support_fmodes2flags+0x172>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1282 <support_fmodes2flags+0x172>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     128d <support_fmodes2flags+0x17d>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     128d <support_fmodes2flags+0x17d>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12a8 <support_fmodes2flags+0x198>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12a8 <support_fmodes2flags+0x198>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12c5 <support_fmodes2flags+0x1b5>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12c5 <support_fmodes2flags+0x1b5>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12c5 <support_fmodes2flags+0x1b5>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ce <support_fmodes2flags+0x1be>
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ce <support_fmodes2flags+0x1be>
lea    0xe01(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ce <support_fmodes2flags+0x1be>
lea    0xded(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1272 <support_fmodes2flags+0x162>
lea    0xddc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1272 <support_fmodes2flags+0x162>
lea    0xdcc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    12c3 <support_fmodes2flags+0x1b3>
mov    0x2d3f(%rip),%rcx
mov    0x2d30(%rip),%rax
jmp    12dc <support_fmodes2flags+0x1cc>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    0x2d24(%rip),%rcx
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2d4a(%rip),%rcx
jmp    12c1 <support_fmodes2flags+0x1b1>
mov    0x2d09(%rip),%rcx
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2cef(%rip),%rcx
or     (%rcx),%eax
pop    %rbx
ret
mov    0x2d0c(%rip),%rax
jmp    1289 <support_fmodes2flags+0x179>
mov    0x2ce3(%rip),%rcx
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2d11(%rip),%rcx
jmp    12c1 <support_fmodes2flags+0x1b1>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"rb\00"
@O_RDONLY = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"wb\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [2 x i8] c"a\00"
@.str.5 = [3 x i8] c"ab\00"
@O_APPEND = global i32 0
@.str.6 = [3 x i8] c"r+\00"
@.str.7 = [4 x i8] c"rb+\00"
@.str.8 = [4 x i8] c"r+b\00"
@O_RDWR = global i32 0
@.str.9 = [3 x i8] c"w+\00"
@.str.10 = [4 x i8] c"wb+\00"
@.str.11 = [4 x i8] c"w+b\00"
@.str.12 = [3 x i8] c"a+\00"
@.str.13 = [4 x i8] c"ab+\00"
@.str.14 = [4 x i8] c"a+b\00"
define i32 @support_fmodes2flags(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7, %1
%12 = load i32, i32* @O_RDONLY
store i32 %12, i32* %2
br label %92
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17, %13
%22 = load i32, i32* @O_WRONLY
%23 = load i32, i32* @O_CREAT
%24 = or i32 %22, %23
%25 = load i32, i32* @O_TRUNC
%26 = or i32 %24, %25
store i32 %26, i32* %2
br label %92
27: ; preds = %17
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %31, %27
%36 = load i32, i32* @O_WRONLY
%37 = load i32, i32* @O_CREAT
%38 = or i32 %36, %37
%39 = load i32, i32* @O_APPEND
%40 = or i32 %38, %39
store i32 %40, i32* %2
br label %92
41: ; preds = %31
%42 = load i8*, i8** %3
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %41
%46 = load i8*, i8** %3
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i8*, i8** %3
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49, %45, %41
%54 = load i32, i32* @O_RDWR
store i32 %54, i32* %2
br label %92
55: ; preds = %49
%56 = load i8*, i8** %3
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %67, label %59
59: ; preds = %55
%60 = load i8*, i8** %3
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = load i8*, i8** %3
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %73
67: ; preds = %63, %59, %55
%68 = load i32, i32* @O_WRONLY
%69 = load i32, i32* @O_TRUNC
%70 = or i32 %68, %69
%71 = load i32, i32* @O_CREAT
%72 = or i32 %70, %71
store i32 %72, i32* %2
br label %92
73: ; preds = %63
%74 = load i8*, i8** %3
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %85, label %77
77: ; preds = %73
%78 = load i8*, i8** %3
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %85, label %81
81: ; preds = %77
%82 = load i8*, i8** %3
%83 = call i64 @strcmp(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %91
85: ; preds = %81, %77, %73
%86 = load i32, i32* @O_WRONLY
%87 = load i32, i32* @O_APPEND
%88 = or i32 %86, %87
%89 = load i32, i32* @O_CREAT
%90 = or i32 %88, %89
store i32 %90, i32* %2
br label %92
91: ; preds = %81
store i32 0, i32* %2
br label %92
92: ; preds = %91, %85, %67, %53, %35, %21, %11
%93 = load i32, i32* %2
ret i32 %93
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"rb\00"
@O_RDONLY = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"wb\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [2 x i8] c"a\00"
@.str.5 = [3 x i8] c"ab\00"
@O_APPEND = global i32 0
@.str.6 = [3 x i8] c"r+\00"
@.str.7 = [4 x i8] c"rb+\00"
@.str.8 = [4 x i8] c"r+b\00"
@O_RDWR = global i32 0
@.str.9 = [3 x i8] c"w+\00"
@.str.10 = [4 x i8] c"wb+\00"
@.str.11 = [4 x i8] c"w+b\00"
@.str.12 = [3 x i8] c"a+\00"
@.str.13 = [4 x i8] c"ab+\00"
@.str.14 = [4 x i8] c"a+b\00"
define i32 @support_fmodes2flags(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4, %1
%8 = load i32, i32* @O_RDONLY
br label %74
9: ; preds = %4
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12, %9
%16 = load i32, i32* @O_WRONLY
%17 = load i32, i32* @O_CREAT
%18 = or i32 %17, %16
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %18, %19
br label %74
21: ; preds = %12
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24, %21
%28 = load i32, i32* @O_WRONLY
%29 = load i32, i32* @O_CREAT
%30 = or i32 %29, %28
%31 = load i32, i32* @O_APPEND
%32 = or i32 %30, %31
br label %74
33: ; preds = %24
%34 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39, %36, %33
%43 = load i32, i32* @O_RDWR
br label %74
44: ; preds = %39
%45 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %44
%48 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %50, %47, %44
%54 = load i32, i32* @O_WRONLY
%55 = load i32, i32* @O_TRUNC
%56 = or i32 %55, %54
%57 = load i32, i32* @O_CREAT
%58 = or i32 %56, %57
br label %74
59: ; preds = %50
%60 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %68, label %62
62: ; preds = %59
%63 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %62
%66 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %65, %62, %59
%69 = load i32, i32* @O_WRONLY
%70 = load i32, i32* @O_APPEND
%71 = or i32 %70, %69
%72 = load i32, i32* @O_CREAT
%73 = or i32 %71, %72
br label %74
74: ; preds = %65, %68, %53, %42, %27, %15, %7
%75 = phi i32 [ %8, %7 ], [ %20, %15 ], [ %32, %27 ], [ %43, %42 ], [ %58, %53 ], [ %73, %68 ], [ 0, %65 ]
ret i32 %75
}