#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 protoent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dump_proto(struct protoent *);
struct protoent *getprotobyname(char const *);
int /*<<< orphan*/ printf(char *, char const *);
void test_proto2(char const *protoname) {
  struct protoent *h = getprotobyname(protoname);
  if (h) {
    printf("find protocol by name: %s\n", protoname);
    dump_proto(h);
  } else
    printf("no protocol found by name: %s\n", protoname);
}


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

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

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

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