#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 */
typedef unsigned long long uint64_t;

/* Variables and functions */
uint64_t expand_overloaded_flags(uint64_t flags) {
  if (flags & (1ULL << 7)) {
    if (flags & (1ULL << 35))
      flags ^= (1ULL << 35) | (1ULL << 49);
    if (flags & (1ULL << 6))
      flags ^= (1ULL << 6) | (1ULL << 50);
    if (flags & (1ULL << 1))
      flags ^= (1ULL << 1) | (1ULL << 51);
  }
  if ((flags & ((1ULL << 9) | (1ULL << 8))) == (1ULL << 9))
    flags ^= (1ULL << 9) | (1ULL << 48);
  return flags;
}


x86 assembly (clang, -O0):
<expand_overloaded_flags>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x80,%rax
cmp    $0x0,%rax
je     1193 <expand_overloaded_flags+0x93>
movabs $0x800000000,%rax
and    -0x8(%rbp),%rax
cmp    $0x0,%rax
je     1146 <expand_overloaded_flags+0x46>
movabs $0x2000800000000,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x40,%rax
cmp    $0x0,%rax
je     116a <expand_overloaded_flags+0x6a>
movabs $0x4000000000040,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     118e <expand_overloaded_flags+0x8e>
movabs $0x8000000000002,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1193 <expand_overloaded_flags+0x93>
mov    -0x8(%rbp),%rax
and    $0x300,%rax
cmp    $0x200,%rax
jne    11bb <expand_overloaded_flags+0xbb>
movabs $0x1000000000200,%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand_overloaded_flags>:
test   $0x80,%dil
je     1143 <expand_overloaded_flags+0x43>
movabs $0x2000800000000,%rax
xor    %rdi,%rax
bt     $0x23,%rdi
cmovae %rdi,%rax
movabs $0x4000000000040,%rcx
xor    %rax,%rcx
test   $0x40,%al
cmove  %rax,%rcx
movabs $0x8000000000002,%rdi
xor    %rcx,%rdi
test   $0x2,%cl
cmove  %rcx,%rdi
mov    %edi,%ecx
and    $0x300,%ecx
movabs $0x1000000000200,%rax
xor    %rdi,%rax
cmp    $0x200,%ecx
cmovne %rdi,%rax
ret

LLVM IR (-O0):
define i64 @expand_overloaded_flags(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = and i64 %3, 128
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = load i64, i64* %2
%8 = and i64 %7, 34359738368
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i64, i64* %2
%12 = xor i64 %11, 562984313159680
store i64 %12, i64* %2
br label %13
13: ; preds = %10, %6
%14 = load i64, i64* %2
%15 = and i64 %14, 64
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i64, i64* %2
%19 = xor i64 %18, 1125899906842688
store i64 %19, i64* %2
br label %20
20: ; preds = %17, %13
%21 = load i64, i64* %2
%22 = and i64 %21, 2
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i64, i64* %2
%26 = xor i64 %25, 2251799813685250
store i64 %26, i64* %2
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %1
%29 = load i64, i64* %2
%30 = and i64 %29, 768
%31 = icmp eq i64 %30, 512
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i64, i64* %2
%34 = xor i64 %33, 281474976711168
store i64 %34, i64* %2
br label %35
35: ; preds = %32, %28
%36 = load i64, i64* %2
ret i64 %36
}

LLVM IR (-O2):
define i64 @expand_overloaded_flags(i64 %0) {
%2 = and i64 %0, 128
%3 = icmp eq i64 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = and i64 %0, 34359738368
%6 = icmp eq i64 %5, 0
%7 = xor i64 %0, 562984313159680
%8 = select i1 %6, i64 %0, i64 %7
%9 = and i64 %8, 64
%10 = icmp eq i64 %9, 0
%11 = xor i64 %8, 1125899906842688
%12 = select i1 %10, i64 %8, i64 %11
%13 = and i64 %12, 2
%14 = icmp eq i64 %13, 0
%15 = xor i64 %12, 2251799813685250
%16 = select i1 %14, i64 %12, i64 %15
br label %17
17: ; preds = %4, %1
%18 = phi i64 [ %0, %1 ], [ %16, %4 ]
%19 = and i64 %18, 768
%20 = icmp eq i64 %19, 512
%21 = xor i64 %18, 281474976711168
%22 = select i1 %20, i64 %21, i64 %18
ret i64 %22
}