#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 netent {
  char *n_name;
  char **n_aliases;
  int /*<<< orphan*/ n_net;
};
struct in_addr {
  int /*<<< orphan*/ s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ printf(char *, char const *, ...);
void output_netent(const char *call, struct netent *nptr) {
  char **pptr;
  if (nptr == NULL)
    printf("Call: %s returned NULL\n", call);
  else {
    struct in_addr ip;
    ip.s_addr = htonl(nptr->n_net);
    printf("Call: %s, returned: n_name: %s, network_number: %s\n", call,
           nptr->n_name, inet_ntoa(ip));
    for (pptr = nptr->n_aliases; *pptr != NULL; pptr++)
      printf("  alias: %s\n", *pptr);
  }
}


x86 assembly (clang, -O0):
<output_netent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1162 <output_netent+0x32>
mov    -0x8(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ea <output_netent+0xba>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e5 <output_netent+0xb5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    11b1 <output_netent+0x81>
jmp    11ea <output_netent+0xba>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_netent>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rsi,%rsi
je     119c <output_netent+0x6c>
mov    %rsi,%rbx
mov    0x10(%rsi),%edi
call   1050 <htonl@plt>
mov    (%rbx),%r15
mov    %eax,%edi
call   1030 <inet_ntoa@plt>
lea    0xebf(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1196 <output_netent+0x66>
add    $0x8,%rbx
lea    0xecc(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1180 <output_netent+0x50>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe5d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.netent = type { i8*, i8**, i32 }
%struct.in_addr = type { i32 }
@.str = [24 x i8] c"Call: %s returned NULL\0A\00"
@.str.1 = [52 x i8] c"Call: %s, returned: n_name: %s, network_number: %s\0A\00"
@.str.2 = [13 x i8] c" alias: %s\0A\00"
define void @output_netent(i8* %0, %struct.netent* %1) {
%3 = alloca i8*
%4 = alloca %struct.netent*
%5 = alloca i8**
%6 = alloca %struct.in_addr
store i8* %0, i8** %3
store %struct.netent* %1, %struct.netent** %4
%7 = load %struct.netent*, %struct.netent** %4
%8 = icmp eq %struct.netent* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %41
12: ; preds = %2
%13 = load %struct.netent*, %struct.netent** %4
%14 = getelementptr inbounds %struct.netent, %struct.netent* %13, i32 0, i32 2
%15 = load i32, i32* %14
%16 = call i32 @htonl(i32 %15)
%17 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
store i32 %16, i32* %17
%18 = load i8*, i8** %3
%19 = load %struct.netent*, %struct.netent** %4
%20 = getelementptr inbounds %struct.netent, %struct.netent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i8* @inet_ntoa(i32 %23)
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %21, i8* %24)
%26 = load %struct.netent*, %struct.netent** %4
%27 = getelementptr inbounds %struct.netent, %struct.netent* %26, i32 0, i32 1
%28 = load i8**, i8*** %27
store i8** %28, i8*** %5
br label %29
29: ; preds = %37, %12
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i8*, i8** %34
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i32 1
store i8** %39, i8*** %5
br label %29
40: ; preds = %29
br label %41
41: ; preds = %40, %9
ret void
}

LLVM IR (-O2):
%struct.netent = type { i8*, i8**, i32 }
@.str = [24 x i8] c"Call: %s returned NULL\0A\00"
@.str.1 = [52 x i8] c"Call: %s, returned: n_name: %s, network_number: %s\0A\00"
@.str.2 = [13 x i8] c" alias: %s\0A\00"
define void @output_netent(i8* %0, %struct.netent* %1) {
%3 = icmp eq %struct.netent* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %25
6: ; preds = %2
%7 = getelementptr inbounds %struct.netent, %struct.netent* %1, i64 0, i32 2
%8 = load i32, i32* %7
%9 = tail call i32 @htonl(i32 %8)
%10 = getelementptr inbounds %struct.netent, %struct.netent* %1, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i8* @inet_ntoa(i32 %9)
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %11, i8* %12)
%14 = getelementptr inbounds %struct.netent, %struct.netent* %1, i64 0, i32 1
%15 = load i8**, i8*** %14
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %25, label %18
18: ; preds = %6, %18
%19 = phi i8* [ %23, %18 ], [ %16, %6 ]
%20 = phi i8** [ %22, %18 ], [ %15, %6 ]
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%22 = getelementptr inbounds i8*, i8** %20, i64 1
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %18
25: ; preds = %18, %6, %4
ret void
}