#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 FASYNC;
int O_APPEND;
int O_CREAT;
int O_EXCL;
int O_NDELAY;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDONLY;
int O_RDWR;
int O_SYNC;
int O_TRUNC;
int O_WRONLY;
int fuserl_open_flags_decanonicalize(int canonical) {
  int flags = 0;
  if ((canonical & 00000003) == 00000000) {
    flags |= O_RDONLY;
  }
  if ((canonical & 00000003) == 00000001) {
    flags |= O_WRONLY;
  }
  if ((canonical & 00000003) == 00000002) {
    flags |= O_RDWR;
  }
  if ((canonical & 00000100) == 00000100) {
    flags |= O_CREAT;
  }
  if ((canonical & 00000200) == 00000200) {
    flags |= O_EXCL;
  }
  if ((canonical & 00000400) == 00000400) {
    flags |= O_NOCTTY;
  }
  if ((canonical & 00001000) == 00001000) {
    flags |= O_TRUNC;
  }
  if ((canonical & 00002000) == 00002000) {
    flags |= O_APPEND;
  }
  if ((canonical & 00004000) == 00004000) {
    flags |= O_NONBLOCK;
  }
  if ((canonical & 00004000) == 00004000) {
    flags |= O_NDELAY;
  }
  if ((canonical & 00010000) == 00010000) {
    flags |= O_SYNC;
  }
  if ((canonical & 00020000) == 00020000) {
    flags |= FASYNC;
  }
  return flags;
}


x86 assembly (clang, -O0):
<fuserl_open_flags_decanonicalize>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    112c <fuserl_open_flags_decanonicalize+0x2c>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
cmp    $0x1,%eax
jne    114a <fuserl_open_flags_decanonicalize+0x4a>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
cmp    $0x2,%eax
jne    1168 <fuserl_open_flags_decanonicalize+0x68>
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x40,%eax
cmp    $0x40,%eax
jne    1186 <fuserl_open_flags_decanonicalize+0x86>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x80,%eax
jne    11a8 <fuserl_open_flags_decanonicalize+0xa8>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    11ca <fuserl_open_flags_decanonicalize+0xca>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x200,%eax
cmp    $0x200,%eax
jne    11ec <fuserl_open_flags_decanonicalize+0xec>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x400,%eax
jne    120e <fuserl_open_flags_decanonicalize+0x10e>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x800,%eax
cmp    $0x800,%eax
jne    1230 <fuserl_open_flags_decanonicalize+0x130>
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x800,%eax
cmp    $0x800,%eax
jne    1252 <fuserl_open_flags_decanonicalize+0x152>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1000,%eax
cmp    $0x1000,%eax
jne    1274 <fuserl_open_flags_decanonicalize+0x174>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2000,%eax
cmp    $0x2000,%eax
jne    1296 <fuserl_open_flags_decanonicalize+0x196>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fuserl_open_flags_decanonicalize>:
xor    %r8d,%r8d
mov    %edi,%edx
mov    $0x0,%r9d
and    $0x3,%edx
jne    111a <fuserl_open_flags_decanonicalize+0x1a>
mov    0x2ea9(%rip),%rax
mov    (%rax),%r9d
mov    $0x0,%eax
cmp    $0x1,%edx
jne    112d <fuserl_open_flags_decanonicalize+0x2d>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    $0x0,%ecx
cmp    $0x2,%edx
jne    1140 <fuserl_open_flags_decanonicalize+0x40>
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%ecx
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xeaf(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xeb3(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%edx
mov    $0x0,%r10d
test   $0x80,%dl
jne    118a <fuserl_open_flags_decanonicalize+0x8a>
mov    0x2e71(%rip),%rsi
mov    (%rsi),%r10d
mov    $0x0,%edi
test   $0x40,%dl
jne    119d <fuserl_open_flags_decanonicalize+0x9d>
mov    0x2e05(%rip),%rsi
mov    (%rsi),%edi
or     %r9d,%eax
mov    $0x0,%esi
test   $0x20,%dl
jne    11b3 <fuserl_open_flags_decanonicalize+0xb3>
mov    0x2df7(%rip),%rsi
mov    (%rsi),%esi
or     %ecx,%eax
mov    $0x0,%ecx
test   $0x10,%dl
jne    11c8 <fuserl_open_flags_decanonicalize+0xc8>
mov    0x2e2a(%rip),%rcx
mov    (%rcx),%ecx
or     %r10d,%eax
or     %esi,%edi
mov    $0x0,%esi
test   $0x8,%dl
jne    11e0 <fuserl_open_flags_decanonicalize+0xe0>
mov    0x2da2(%rip),%rsi
mov    (%rsi),%esi
or     %esi,%ecx
or     %edi,%eax
mov    0x2ddd(%rip),%rsi
test   $0x4,%dl
mov    (%rsi),%edi
cmovne %r8d,%edi
mov    0x2d9d(%rip),%rsi
mov    (%rsi),%esi
cmovne %r8d,%esi
or     %ecx,%edi
mov    $0x0,%ecx
test   $0x2,%dl
jne    1216 <fuserl_open_flags_decanonicalize+0x116>
mov    0x2dbc(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,%esi
or     %edi,%eax
test   $0x1,%dl
jne    1229 <fuserl_open_flags_decanonicalize+0x129>
mov    0x2d92(%rip),%rcx
mov    (%rcx),%r8d
or     %r8d,%esi
or     %esi,%eax
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_NOCTTY = global i32 0
@O_TRUNC = global i32 0
@O_APPEND = global i32 0
@O_NONBLOCK = global i32 0
@O_NDELAY = global i32 0
@O_SYNC = global i32 0
@FASYNC = global i32 0
define i32 @fuserl_open_flags_decanonicalize(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @O_RDONLY
%9 = load i32, i32* %3
%10 = or i32 %9, %8
store i32 %10, i32* %3
br label %11
11: ; preds = %7, %1
%12 = load i32, i32* %2
%13 = and i32 %12, 3
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @O_WRONLY
%17 = load i32, i32* %3
%18 = or i32 %17, %16
store i32 %18, i32* %3
br label %19
19: ; preds = %15, %11
%20 = load i32, i32* %2
%21 = and i32 %20, 3
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32, i32* @O_RDWR
%25 = load i32, i32* %3
%26 = or i32 %25, %24
store i32 %26, i32* %3
br label %27
27: ; preds = %23, %19
%28 = load i32, i32* %2
%29 = and i32 %28, 64
%30 = icmp eq i32 %29, 64
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* @O_CREAT
%33 = load i32, i32* %3
%34 = or i32 %33, %32
store i32 %34, i32* %3
br label %35
35: ; preds = %31, %27
%36 = load i32, i32* %2
%37 = and i32 %36, 128
%38 = icmp eq i32 %37, 128
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* @O_EXCL
%41 = load i32, i32* %3
%42 = or i32 %41, %40
store i32 %42, i32* %3
br label %43
43: ; preds = %39, %35
%44 = load i32, i32* %2
%45 = and i32 %44, 256
%46 = icmp eq i32 %45, 256
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* @O_NOCTTY
%49 = load i32, i32* %3
%50 = or i32 %49, %48
store i32 %50, i32* %3
br label %51
51: ; preds = %47, %43
%52 = load i32, i32* %2
%53 = and i32 %52, 512
%54 = icmp eq i32 %53, 512
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* @O_TRUNC
%57 = load i32, i32* %3
%58 = or i32 %57, %56
store i32 %58, i32* %3
br label %59
59: ; preds = %55, %51
%60 = load i32, i32* %2
%61 = and i32 %60, 1024
%62 = icmp eq i32 %61, 1024
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i32, i32* @O_APPEND
%65 = load i32, i32* %3
%66 = or i32 %65, %64
store i32 %66, i32* %3
br label %67
67: ; preds = %63, %59
%68 = load i32, i32* %2
%69 = and i32 %68, 2048
%70 = icmp eq i32 %69, 2048
br i1 %70, label %71, label %75
71: ; preds = %67
%72 = load i32, i32* @O_NONBLOCK
%73 = load i32, i32* %3
%74 = or i32 %73, %72
store i32 %74, i32* %3
br label %75
75: ; preds = %71, %67
%76 = load i32, i32* %2
%77 = and i32 %76, 2048
%78 = icmp eq i32 %77, 2048
br i1 %78, label %79, label %83
79: ; preds = %75
%80 = load i32, i32* @O_NDELAY
%81 = load i32, i32* %3
%82 = or i32 %81, %80
store i32 %82, i32* %3
br label %83
83: ; preds = %79, %75
%84 = load i32, i32* %2
%85 = and i32 %84, 4096
%86 = icmp eq i32 %85, 4096
br i1 %86, label %87, label %91
87: ; preds = %83
%88 = load i32, i32* @O_SYNC
%89 = load i32, i32* %3
%90 = or i32 %89, %88
store i32 %90, i32* %3
br label %91
91: ; preds = %87, %83
%92 = load i32, i32* %2
%93 = and i32 %92, 8192
%94 = icmp eq i32 %93, 8192
br i1 %94, label %95, label %99
95: ; preds = %91
%96 = load i32, i32* @FASYNC
%97 = load i32, i32* %3
%98 = or i32 %97, %96
store i32 %98, i32* %3
br label %99
99: ; preds = %95, %91
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_NOCTTY = global i32 0
@O_TRUNC = global i32 0
@O_APPEND = global i32 0
@O_NONBLOCK = global i32 0
@O_NDELAY = global i32 0
@O_SYNC = global i32 0
@FASYNC = global i32 0
define i32 @fuserl_open_flags_decanonicalize(i32 %0) {
%2 = and i32 %0, 3
%3 = icmp eq i32 %2, 0
%4 = load i32, i32* @O_RDONLY
%5 = select i1 %3, i32 %4, i32 0
%6 = icmp eq i32 %2, 1
%7 = load i32, i32* @O_WRONLY
%8 = select i1 %6, i32 %7, i32 0
%9 = or i32 %8, %5
%10 = icmp eq i32 %2, 2
%11 = load i32, i32* @O_RDWR
%12 = select i1 %10, i32 %11, i32 0
%13 = or i32 %9, %12
%14 = load i32, i32* @O_CREAT
%15 = insertelement <8 x i32> poison, i32 %0, i64 0
%16 = shufflevector <8 x i32> %15, <8 x i32> poison, <8 x i32> zeroinitializer
%17 = and <8 x i32> %16, <i32 8192, i32 4096, i32 2048, i32 1024, i32 512, i32 256, i32 128, i32 64>
%18 = icmp eq <8 x i32> %17, zeroinitializer
%19 = extractelement <8 x i1> %18, i64 7
%20 = select i1 %19, i32 0, i32 %14
%21 = or i32 %13, %20
%22 = load i32, i32* @O_EXCL
%23 = extractelement <8 x i1> %18, i64 6
%24 = select i1 %23, i32 0, i32 %22
%25 = or i32 %21, %24
%26 = load i32, i32* @O_NOCTTY
%27 = extractelement <8 x i1> %18, i64 5
%28 = select i1 %27, i32 0, i32 %26
%29 = or i32 %25, %28
%30 = load i32, i32* @O_TRUNC
%31 = extractelement <8 x i1> %18, i64 4
%32 = select i1 %31, i32 0, i32 %30
%33 = or i32 %29, %32
%34 = load i32, i32* @O_APPEND
%35 = extractelement <8 x i1> %18, i64 3
%36 = select i1 %35, i32 0, i32 %34
%37 = or i32 %33, %36
%38 = load i32, i32* @O_NONBLOCK
%39 = extractelement <8 x i1> %18, i64 2
%40 = select i1 %39, i32 0, i32 %38
%41 = or i32 %37, %40
%42 = load i32, i32* @O_NDELAY
%43 = select i1 %39, i32 0, i32 %42
%44 = or i32 %41, %43
%45 = load i32, i32* @O_SYNC
%46 = extractelement <8 x i1> %18, i64 1
%47 = select i1 %46, i32 0, i32 %45
%48 = or i32 %44, %47
%49 = load i32, i32* @FASYNC
%50 = extractelement <8 x i1> %18, i64 0
%51 = select i1 %50, i32 0, i32 %49
%52 = or i32 %48, %51
ret i32 %52
}