#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;
};

/* Variables and functions */
int /*<<< orphan*/ dump_net(struct netent *);
struct netent *getnetbyname(char const *);
int /*<<< orphan*/ printf(char *, char const *);
void test_net2(char const *netname) {
  struct netent *h = getnetbyname(netname);
  if (h) {
    printf("find net by name: %s\n", netname);
    dump_net(h);
  } else
    printf("no net found by name: %s\n", netname);
}


x86 assembly (clang, -O0):
<test_net2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getnetbyname@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1172 <test_net2+0x42>
mov    -0x8(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <dump_net@plt>
jmp    1182 <test_net2+0x52>
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_net2>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getnetbyname@plt>
test   %rax,%rax
je     1162 <test_net2+0x32>
mov    %rax,%r14
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <dump_net@plt>
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

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

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