#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 hostent {
  int /*<<< orphan*/ h_addr_list;
  int /*<<< orphan*/ h_name;
};

/* Variables and functions */
int /*<<< orphan*/ addr_list_fprint(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
struct hostent *hostent_fprint(struct hostent *host, int is_server) {
  char *format;
  if (is_server) {
    format = "Server:     ";
  } else {
    format = "Name:       ";
  }
  if (host) {
    printf("%s%s\n", format, host->h_name);
    addr_list_fprint(host->h_addr_list);
  } else {
    printf("*** Unknown host\n");
  }
  return host;
}


x86 assembly (clang, -O0):
<hostent_fprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1149 <hostent_fprint+0x29>
lea    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1154 <hostent_fprint+0x34>
lea    0xebd(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1188 <hostent_fprint+0x68>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <addr_list_fprint@plt>
jmp    1196 <hostent_fprint+0x76>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hostent_fprint>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1167 <hostent_fprint+0x37>
test   %esi,%esi
lea    0xecb(%rip),%rax
lea    0xeb7(%rip),%rsi
cmove  %rax,%rsi
mov    0x4(%rbx),%edx
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%edi
call   1040 <addr_list_fprint@plt>
jmp    1173 <hostent_fprint+0x43>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.hostent = type { i32, i32 }
@.str = [13 x i8] c"Server: \00"
@.str.1 = [13 x i8] c"Name: \00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
@.str.3 = [18 x i8] c"*** Unknown host\0A\00"
define %struct.hostent* @hostent_fprint(%struct.hostent* %0, i32 %1) {
%3 = alloca %struct.hostent*
%4 = alloca i32
%5 = alloca i8*
store %struct.hostent* %0, %struct.hostent** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %5
br label %10
9: ; preds = %2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %10
10: ; preds = %9, %8
%11 = load %struct.hostent*, %struct.hostent** %3
%12 = icmp ne %struct.hostent* %11, null
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = load %struct.hostent*, %struct.hostent** %3
%16 = getelementptr inbounds %struct.hostent, %struct.hostent* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %17)
%19 = load %struct.hostent*, %struct.hostent** %3
%20 = getelementptr inbounds %struct.hostent, %struct.hostent* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @addr_list_fprint(i32 %21)
br label %25
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %13
%26 = load %struct.hostent*, %struct.hostent** %3
ret %struct.hostent* %26
}

LLVM IR (-O2):
%struct.hostent = type { i32, i32 }
@.str = [13 x i8] c"Server: \00"
@.str.1 = [13 x i8] c"Name: \00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
@str = [17 x i8] c"*** Unknown host\00"
define %struct.hostent* @hostent_fprint(%struct.hostent* returned %0, i32 %1) {
%3 = icmp eq %struct.hostent* %0, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0)
%7 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32 %8)
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @addr_list_fprint(i32 %11)
br label %15
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
ret %struct.hostent* %0
}