#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 NI_DGRAM;
int NI_NAMEREQD;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int convert_getnameinfo_flags(int flags) {
  int glibc_flags = 0;
  if (flags & 0x00000001)
    glibc_flags |= 0x00000001;
  if (flags & 0x00000002)
    glibc_flags |= NI_NUMERICHOST;
  if (flags & 0x00000004)
    glibc_flags |= NI_NAMEREQD;
  if (flags & 0x00000008)
    glibc_flags |= NI_NUMERICSERV;
  if (flags & 0x00000010)
    glibc_flags |= NI_DGRAM;
  return glibc_flags;
}


x86 assembly (clang, -O0):
<convert_getnameinfo_flags>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1126 <convert_getnameinfo_flags+0x26>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1144 <convert_getnameinfo_flags+0x44>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1162 <convert_getnameinfo_flags+0x62>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1180 <convert_getnameinfo_flags+0x80>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     119e <convert_getnameinfo_flags+0x9e>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_getnameinfo_flags>:
mov    %edi,%eax
mov    %edi,%ecx
shl    $0x1e,%ecx
sar    $0x1f,%ecx
mov    0x2ebf(%rip),%rdx
and    (%rdx),%ecx
and    $0x1,%eax
or     %eax,%ecx
mov    %edi,%edx
shl    $0x1d,%edx
sar    $0x1f,%edx
mov    0x2ec9(%rip),%rax
and    (%rax),%edx
mov    %edi,%eax
shl    $0x1c,%eax
sar    $0x1f,%eax
mov    0x2ea8(%rip),%rsi
and    (%rsi),%eax
or     %edx,%eax
or     %ecx,%eax
shl    $0x1b,%edi
sar    $0x1f,%edi
mov    0x2e75(%rip),%rcx
and    (%rcx),%edi
or     %edi,%eax
ret

LLVM IR (-O0):
@NI_NUMERICHOST = global i32 0
@NI_NAMEREQD = global i32 0
@NI_NUMERICSERV = global i32 0
@NI_DGRAM = global i32 0
define i32 @convert_getnameinfo_flags(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, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = or i32 %8, 1
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = and i32 %11, 2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @NI_NUMERICHOST
%16 = load i32, i32* %3
%17 = or i32 %16, %15
store i32 %17, i32* %3
br label %18
18: ; preds = %14, %10
%19 = load i32, i32* %2
%20 = and i32 %19, 4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* @NI_NAMEREQD
%24 = load i32, i32* %3
%25 = or i32 %24, %23
store i32 %25, i32* %3
br label %26
26: ; preds = %22, %18
%27 = load i32, i32* %2
%28 = and i32 %27, 8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* @NI_NUMERICSERV
%32 = load i32, i32* %3
%33 = or i32 %32, %31
store i32 %33, i32* %3
br label %34
34: ; preds = %30, %26
%35 = load i32, i32* %2
%36 = and i32 %35, 16
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* @NI_DGRAM
%40 = load i32, i32* %3
%41 = or i32 %40, %39
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %34
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@NI_NUMERICHOST = global i32 0
@NI_NAMEREQD = global i32 0
@NI_NUMERICSERV = global i32 0
@NI_DGRAM = global i32 0
define i32 @convert_getnameinfo_flags(i32 %0) {
%2 = and i32 %0, 1
%3 = and i32 %0, 2
%4 = icmp eq i32 %3, 0
%5 = load i32, i32* @NI_NUMERICHOST
%6 = select i1 %4, i32 0, i32 %5
%7 = or i32 %6, %2
%8 = and i32 %0, 4
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @NI_NAMEREQD
%11 = select i1 %9, i32 0, i32 %10
%12 = or i32 %7, %11
%13 = and i32 %0, 8
%14 = icmp eq i32 %13, 0
%15 = load i32, i32* @NI_NUMERICSERV
%16 = select i1 %14, i32 0, i32 %15
%17 = or i32 %12, %16
%18 = and i32 %0, 16
%19 = icmp eq i32 %18, 0
%20 = load i32, i32* @NI_DGRAM
%21 = select i1 %19, i32 0, i32 %20
%22 = or i32 %17, %21
ret i32 %22
}