#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 {
  int /*<<< orphan*/ n_name;
  int /*<<< orphan*/ n_aliases;
  int /*<<< orphan*/ n_addrtype;
  int /*<<< orphan*/ n_net;
};
struct in_addr {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int INET6_ADDRSTRLEN;
struct in_addr inet_makeaddr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *inet_ntop(int /*<<< orphan*/, struct in_addr *, char *,
                              int);
int /*<<< orphan*/ printfmtstrings(int /*<<< orphan*/, char *, char *, char *,
                                   int /*<<< orphan*/, char *);
int /*<<< orphan*/ strlcpy(char *, char *, int);
void networksprint(const struct netent *ne) {
  char buf[INET6_ADDRSTRLEN];
  struct in_addr ianet;
  ianet = inet_makeaddr(ne->n_net, 0);
  if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL)
    (void)strlcpy(buf, "# unknown", sizeof(buf));
  printfmtstrings(ne->n_aliases, "  ", " ", "%-16s  %s", ne->n_name, buf);
}


x86 assembly (clang, -O0):
<networksprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x30(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
xor    %esi,%esi
call   1040 <inet_makeaddr@plt>
mov    -0x38(%rbp),%rdx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%edi
mov    %eax,%ecx
lea    -0x20(%rbp),%rsi
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    11cf <networksprint+0x8f>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xe36(%rip),%rsi
call   1060 <strlcpy@plt>
mov    -0x38(%rbp),%r9
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%r8d
lea    0xe22(%rip),%rsi
lea    0xe1c(%rip),%rdx
lea    0xe17(%rip),%rcx
call   1050 <printfmtstrings@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<networksprint>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e94(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0xc(%rdi),%edi
xor    %esi,%esi
call   1040 <inet_makeaddr@plt>
mov    %eax,-0x20(%rbp)
mov    0x8(%r14),%edi
lea    -0x20(%rbp),%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
jne    11a2 <networksprint+0x62>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1060 <strlcpy@plt>
mov    (%r14),%r8d
mov    0x4(%r14),%edi
lea    0xe5a(%rip),%rsi
lea    0xe54(%rip),%rdx
lea    0xe4f(%rip),%rcx
mov    %rbx,%r9
call   1050 <printfmtstrings@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.netent = type { i32, i32, i32, i32 }
%struct.in_addr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [10 x i8] c"# unknown\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [10 x i8] c"%-16s %s\00"
define void @networksprint(%struct.netent* %0) {
%2 = alloca %struct.netent*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca %struct.in_addr
%6 = alloca %struct.in_addr
store %struct.netent* %0, %struct.netent** %2
%7 = load i32, i32* @INET6_ADDRSTRLEN
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = load %struct.netent*, %struct.netent** %2
%12 = getelementptr inbounds %struct.netent, %struct.netent* %11, i32 0, i32 3
%13 = load i32, i32* %12
%14 = call i32 @inet_makeaddr(i32 %13, i32 0)
%15 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
store i32 %14, i32* %15
%16 = bitcast %struct.in_addr* %5 to i8*
%17 = bitcast %struct.in_addr* %6 to i8*
%18 = load %struct.netent*, %struct.netent** %2
%19 = getelementptr inbounds %struct.netent, %struct.netent* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = trunc i64 %8 to i32
%22 = call i32* @inet_ntop(i32 %20, %struct.in_addr* %5, i8* %10, i32 %21)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %1
%25 = trunc i64 %8 to i32
%26 = call i32 @strlcpy(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %1
%28 = load %struct.netent*, %struct.netent** %2
%29 = getelementptr inbounds %struct.netent, %struct.netent* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = load %struct.netent*, %struct.netent** %2
%32 = getelementptr inbounds %struct.netent, %struct.netent* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 @printfmtstrings(i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %33, i8* %10)
%35 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
%struct.netent = type { i32, i32, i32, i32 }
%struct.in_addr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [10 x i8] c"# unknown\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [10 x i8] c"%-16s %s\00"
define void @networksprint(%struct.netent* nocapture %0) {
%2 = alloca %struct.in_addr
%3 = load i32, i32* @INET6_ADDRSTRLEN
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = bitcast %struct.in_addr* %2 to i8*
%7 = getelementptr inbounds %struct.netent, %struct.netent* %0, i64 0, i32 3
%8 = load i32, i32* %7
%9 = tail call i32 @inet_makeaddr(i32 %8, i32 0)
%10 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i64 0, i32 0
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.netent, %struct.netent* %0, i64 0, i32 2
%12 = load i32, i32* %11
%13 = call i32* @inet_ntop(i32 %12, %struct.in_addr* %2, i8* %5, i32 %3)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @strlcpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %17
17: ; preds = %15, %1
%18 = getelementptr inbounds %struct.netent, %struct.netent* %0, i64 0, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.netent, %struct.netent* %0, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @printfmtstrings(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %21, i8* %5)
ret void
}