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

/* Variables and functions */
int /*<<< orphan*/ endrpcent();
struct rpcent *getrpcbyname(char *);
struct rpcent *getrpcbynumber(int);
struct rpcent *getrpcent();
int /*<<< orphan*/ output_rpcent(char *, struct rpcent *);
int /*<<< orphan*/ setrpcent(int /*<<< orphan*/);
void test_rpc(void) {
  struct rpcent *rptr;
  rptr = getrpcbyname("portmap");
  output_rpcent("getrpcyname (\"portmap\")", rptr);
  rptr = getrpcbynumber(100000);
  output_rpcent("getrpcbynumber (100000)", rptr);
  setrpcent(0);
  do {
    rptr = getrpcent();
    output_rpcent("getrpcent ()", rptr);
  } while (rptr != NULL);
  endrpcent();
}


x86 assembly (clang, -O0):
<test_rpc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1080 <getrpcbyname@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1060 <output_rpcent@plt>
mov    $0x186a0,%edi
call   1040 <getrpcbynumber@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1060 <output_rpcent@plt>
xor    %edi,%edi
call   1050 <setrpcent@plt>
mov    $0x0,%al
call   1070 <getrpcent@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1060 <output_rpcent@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11ad <test_rpc+0x4d>
mov    $0x0,%al
call   1030 <endrpcent@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_rpc>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
call   1080 <getrpcbyname@plt>
lea    0xe91(%rip),%rdi
mov    %rax,%rsi
call   1060 <output_rpcent@plt>
mov    $0x186a0,%edi
call   1040 <getrpcbynumber@plt>
lea    0xe90(%rip),%rdi
mov    %rax,%rsi
call   1060 <output_rpcent@plt>
xor    %edi,%edi
call   1050 <setrpcent@plt>
lea    0xe92(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getrpcent@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <output_rpcent@plt>
test   %rbx,%rbx
jne    11b0 <test_rpc+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <endrpcent@plt>

LLVM IR (-O0):
%struct.rpcent = type { i32 }
@.str = [8 x i8] c"portmap\00"
@.str.1 = [24 x i8] c"getrpcyname (\22portmap\22)\00"
@.str.2 = [24 x i8] c"getrpcbynumber (100000)\00"
@.str.3 = [13 x i8] c"getrpcent ()\00"
define void @test_rpc() {
%1 = alloca %struct.rpcent*
%2 = call %struct.rpcent* @getrpcbyname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store %struct.rpcent* %2, %struct.rpcent** %1
%3 = load %struct.rpcent*, %struct.rpcent** %1
%4 = call i32 @output_rpcent(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %struct.rpcent* %3)
%5 = call %struct.rpcent* @getrpcbynumber(i32 100000)
store %struct.rpcent* %5, %struct.rpcent** %1
%6 = load %struct.rpcent*, %struct.rpcent** %1
%7 = call i32 @output_rpcent(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %struct.rpcent* %6)
%8 = call i32 @setrpcent(i32 0)
br label %9
9: ; preds = %13, %0
%10 = call %struct.rpcent* (...) @getrpcent()
store %struct.rpcent* %10, %struct.rpcent** %1
%11 = load %struct.rpcent*, %struct.rpcent** %1
%12 = call i32 @output_rpcent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %struct.rpcent* %11)
br label %13
13: ; preds = %9
%14 = load %struct.rpcent*, %struct.rpcent** %1
%15 = icmp ne %struct.rpcent* %14, null
br i1 %15, label %9, label %16
16: ; preds = %13
%17 = call i32 (...) @endrpcent()
ret void
}

LLVM IR (-O2):
%struct.rpcent = type { i32 }
@.str = [8 x i8] c"portmap\00"
@.str.1 = [24 x i8] c"getrpcyname (\22portmap\22)\00"
@.str.2 = [24 x i8] c"getrpcbynumber (100000)\00"
@.str.3 = [13 x i8] c"getrpcent ()\00"
define void @test_rpc() {
%1 = tail call %struct.rpcent* @getrpcbyname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @output_rpcent(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %struct.rpcent* %1)
%3 = tail call %struct.rpcent* @getrpcbynumber(i32 100000)
%4 = tail call i32 @output_rpcent(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %struct.rpcent* %3)
%5 = tail call i32 @setrpcent(i32 0)
br label %6
6: ; preds = %6, %0
%7 = tail call %struct.rpcent* (...) @getrpcent()
%8 = tail call i32 @output_rpcent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %struct.rpcent* %7)
%9 = icmp eq %struct.rpcent* %7, null
br i1 %9, label %10, label %6
10: ; preds = %6
%11 = tail call i32 (...) @endrpcent()
ret void
}