#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_CANONNAME;
int AI_NUMERICHOST;
int AI_PASSIVE;
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");
  }
}


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    11b7 <print_flags+0xa7>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e95(%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    0x2e61(%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    0x2e45(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11b2 <print_flags+0xa2>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    11b7 <print_flags+0xa7>
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     1170 <print_flags+0x60>
mov    0x2ebb(%rip),%rcx
test   %eax,(%rcx)
je     113f <print_flags+0x2f>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e92(%rip),%rcx
test   %eax,(%rcx)
je     1158 <print_flags+0x48>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    0x2e81(%rip),%rcx
test   %eax,(%rcx)
je     117d <print_flags+0x6d>
lea    0xeaf(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>
lea    0xe8f(%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"
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 %38
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
br label %38
38: ; preds = %37, %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"
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 %26, 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, %1
%27 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %21 ]
%28 = tail call i32 @printf(i8* dereferenceable(1) %27)
br label %29
29: ; preds = %26, %21
ret void
}