#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 */
struct addrinfo {
  int ai_flags;
};

/* Variables and functions */
int AI_ALL;
int AI_CANONNAME;
int AI_NUMERICHOST;
int AI_NUMERICSERV;
int AI_PASSIVE;
int AI_V4MAPPED;
int /*<<< orphan*/ printf(char *);
void print_flags(struct addrinfo *aip) {
  printf("flags");
  if (aip->ai_flags == 0) {
    printf(" 0");
  } else {
    if (aip->ai_flags & AI_PASSIVE)
      printf(" passive");
    if (aip->ai_flags & AI_CANONNAME)
      printf(" canon");
    if (aip->ai_flags & AI_NUMERICHOST)
      printf(" numhost");
    if (aip->ai_flags & AI_NUMERICSERV)
      printf(" numserv");
    if (aip->ai_flags & AI_V4MAPPED)
      printf(" v4mapped");
    if (aip->ai_flags & AI_ALL)
      printf(" all");
  }
}


x86 assembly (clang, -O0):
<print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1146 <print_flags+0x36>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
jmp    1223 <print_flags+0x113>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e85(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     116a <print_flags+0x5a>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e51(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     118e <print_flags+0x7e>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e35(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11b2 <print_flags+0xa2>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e39(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d6 <print_flags+0xc6>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2dfd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11fa <print_flags+0xea>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2db1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     121e <print_flags+0x10e>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
jmp    1223 <print_flags+0x113>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_flags>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
test   %eax,%eax
je     11bf <print_flags+0xaf>
mov    0x2ea7(%rip),%rcx
test   %eax,(%rcx)
je     1143 <print_flags+0x33>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e7e(%rip),%rcx
test   %eax,(%rcx)
je     115c <print_flags+0x4c>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e6d(%rip),%rcx
test   %eax,(%rcx)
je     1175 <print_flags+0x65>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e7c(%rip),%rcx
test   %eax,(%rcx)
je     118e <print_flags+0x7e>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e4b(%rip),%rcx
test   %eax,(%rcx)
je     11a7 <print_flags+0x97>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e0a(%rip),%rcx
test   %eax,(%rcx)
je     11cc <print_flags+0xbc>
lea    0xe7c(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>
lea    0xe40(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [6 x i8] c"flags\00"
@.str.1 = [3 x i8] c" 0\00"
@AI_PASSIVE = global i32 0
@.str.2 = [9 x i8] c" passive\00"
@AI_CANONNAME = global i32 0
@.str.3 = [7 x i8] c" canon\00"
@AI_NUMERICHOST = global i32 0
@.str.4 = [9 x i8] c" numhost\00"
@AI_NUMERICSERV = global i32 0
@.str.5 = [9 x i8] c" numserv\00"
@AI_V4MAPPED = global i32 0
@.str.6 = [10 x i8] c" v4mapped\00"
@AI_ALL = global i32 0
@.str.7 = [5 x i8] c" all\00"
define void @print_flags(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
store %struct.addrinfo* %0, %struct.addrinfo** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = load %struct.addrinfo*, %struct.addrinfo** %2
%5 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %65
10: ; preds = %1
%11 = load %struct.addrinfo*, %struct.addrinfo** %2
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @AI_PASSIVE
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %10
%20 = load %struct.addrinfo*, %struct.addrinfo** %2
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* @AI_CANONNAME
%24 = and i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %19
%29 = load %struct.addrinfo*, %struct.addrinfo** %2
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @AI_NUMERICHOST
%33 = and i32 %31, %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %28
%38 = load %struct.addrinfo*, %struct.addrinfo** %2
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = load i32, i32* @AI_NUMERICSERV
%42 = and i32 %40, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
%47 = load %struct.addrinfo*, %struct.addrinfo** %2
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = load i32, i32* @AI_V4MAPPED
%51 = and i32 %49, %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %46
%56 = load %struct.addrinfo*, %struct.addrinfo** %2
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = load i32, i32* @AI_ALL
%60 = and i32 %58, %59
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %55
%63 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %64
64: ; preds = %62, %55
br label %65
65: ; preds = %64, %8
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [6 x i8] c"flags\00"
@.str.1 = [3 x i8] c" 0\00"
@AI_PASSIVE = global i32 0
@.str.2 = [9 x i8] c" passive\00"
@AI_CANONNAME = global i32 0
@.str.3 = [7 x i8] c" canon\00"
@AI_NUMERICHOST = global i32 0
@.str.4 = [9 x i8] c" numhost\00"
@AI_NUMERICSERV = global i32 0
@.str.5 = [9 x i8] c" numserv\00"
@AI_V4MAPPED = global i32 0
@.str.6 = [10 x i8] c" v4mapped\00"
@AI_ALL = global i32 0
@.str.7 = [5 x i8] c" all\00"
define void @print_flags(%struct.addrinfo* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %50, label %6
6: ; preds = %1
%7 = load i32, i32* @AI_PASSIVE
%8 = and i32 %7, %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %3
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ %12, %10 ], [ %4, %6 ]
%15 = load i32, i32* @AI_CANONNAME
%16 = and i32 %15, %14
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* %3
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %20, %18 ], [ %14, %13 ]
%23 = load i32, i32* @AI_NUMERICHOST
%24 = and i32 %23, %22
%25 = icmp eq i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32, i32* %3
br label %29
29: ; preds = %26, %21
%30 = phi i32 [ %28, %26 ], [ %22, %21 ]
%31 = load i32, i32* @AI_NUMERICSERV
%32 = and i32 %31, %30
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %29
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* %3
br label %37
37: ; preds = %34, %29
%38 = phi i32 [ %36, %34 ], [ %30, %29 ]
%39 = load i32, i32* @AI_V4MAPPED
%40 = and i32 %39, %38
%41 = icmp eq i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* %3
br label %45
45: ; preds = %42, %37
%46 = phi i32 [ %44, %42 ], [ %38, %37 ]
%47 = load i32, i32* @AI_ALL
%48 = and i32 %47, %46
%49 = icmp eq i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %45, %1
%51 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %45 ]
%52 = tail call i32 @printf(i8* dereferenceable(1) %51)
br label %53
53: ; preds = %50, %45
ret void
}