#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 dummy;
};
typedef int in_addr_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ dump_net(struct netent *);
struct netent *getnetbyaddr(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
void test_net3(in_addr_t addr) {
  struct netent *h = getnetbyaddr(addr, AF_INET);
  if (h) {
    printf("find net by addr: 0x%08x\n", addr);
    dump_net(h);
  } else
    printf("no net found by addr: 0x%08x\n", addr);
}


x86 assembly (clang, -O0):
<test_net3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
call   1050 <getnetbyaddr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1178 <test_net3+0x48>
mov    -0x4(%rbp),%esi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <dump_net@plt>
jmp    1187 <test_net3+0x57>
mov    -0x4(%rbp),%esi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_net3>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    0x2eac(%rip),%rax
mov    (%rax),%esi
call   1050 <getnetbyaddr@plt>
test   %rax,%rax
je     1167 <test_net3+0x37>
mov    %rax,%rbx
lea    0xeae(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <dump_net@plt>
lea    0xeac(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.netent = type { i32 }
@AF_INET = global i32 0
@.str = [26 x i8] c"find net by addr: 0x%08x\0A\00"
@.str.1 = [30 x i8] c"no net found by addr: 0x%08x\0A\00"
define void @test_net3(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.netent*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @AF_INET
%6 = call %struct.netent* @getnetbyaddr(i32 %4, i32 %5)
store %struct.netent* %6, %struct.netent** %3
%7 = load %struct.netent*, %struct.netent** %3
%8 = icmp ne %struct.netent* %7, null
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load %struct.netent*, %struct.netent** %3
%13 = call i32 @dump_net(%struct.netent* %12)
br label %17
14: ; preds = %1
%15 = load i32, i32* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
%struct.netent = type { i32 }
@AF_INET = global i32 0
@.str = [26 x i8] c"find net by addr: 0x%08x\0A\00"
@.str.1 = [30 x i8] c"no net found by addr: 0x%08x\0A\00"
define void @test_net3(i32 %0) {
%2 = load i32, i32* @AF_INET
%3 = tail call %struct.netent* @getnetbyaddr(i32 %0, i32 %2)
%4 = icmp eq %struct.netent* %3, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0)
%7 = tail call i32 @dump_net(%struct.netent* %3)
br label %10
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %8, %5
ret void
}