#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 {
  char *r_name;
  char **r_aliases;
};

/* Variables and functions */
int /*<<< orphan*/ endrpcent();
struct rpcent *getrpcent();
int /*<<< orphan*/ setrpcent(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char const *);
struct rpcent *getrpcbyname(const char *name) {
  struct rpcent *rpc;
  char **rp;
  setrpcent(0);
  while (rpc = getrpcent()) {
    if (strcmp(rpc->r_name, name) == 0)
      return (rpc);
    for (rp = rpc->r_aliases; *rp != NULL; rp++) {
      if (strcmp(*rp, name) == 0)
        return (rpc);
    }
  }
  endrpcent();
  return (NULL);
}


x86 assembly (clang, -O0):
<getrpcbyname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %edi,%edi
call   1050 <setrpcent@plt>
mov    $0x0,%al
call   1060 <getrpcent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11eb <getrpcbyname+0xab>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118f <getrpcbyname+0x4f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fa <getrpcbyname+0xba>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e6 <getrpcbyname+0xa6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d0 <getrpcbyname+0x90>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fa <getrpcbyname+0xba>
jmp    11d5 <getrpcbyname+0x95>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    119b <getrpcbyname+0x5b>
jmp    1153 <getrpcbyname+0x13>
mov    $0x0,%al
call   1030 <endrpcent@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrpcbyname>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %edi,%edi
call   1050 <setrpcent@plt>
xor    %eax,%eax
call   1060 <getrpcent@plt>
test   %rax,%rax
je     11ab <getrpcbyname+0x6b>
mov    %rax,%r14
jmp    116f <getrpcbyname+0x2f>
xor    %eax,%eax
call   1060 <getrpcent@plt>
mov    %rax,%r14
test   %rax,%rax
je     11ab <getrpcbyname+0x6b>
mov    (%r14),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b5 <getrpcbyname+0x75>
mov    0x8(%r14),%rbx
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1160 <getrpcbyname+0x20>
add    $0x8,%rbx
nop
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b5 <getrpcbyname+0x75>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1190 <getrpcbyname+0x50>
jmp    1160 <getrpcbyname+0x20>
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <endrpcent@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rpcent = type { i8*, i8** }
define %struct.rpcent* @getrpcbyname(i8* %0) {
%2 = alloca %struct.rpcent*
%3 = alloca i8*
%4 = alloca %struct.rpcent*
%5 = alloca i8**
store i8* %0, i8** %3
%6 = call i32 @setrpcent(i32 0)
br label %7
7: ; preds = %39, %1
%8 = call %struct.rpcent* (...) @getrpcent()
store %struct.rpcent* %8, %struct.rpcent** %4
%9 = icmp ne %struct.rpcent* %8, null
br i1 %9, label %10, label %40
10: ; preds = %7
%11 = load %struct.rpcent*, %struct.rpcent** %4
%12 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %11, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = load %struct.rpcent*, %struct.rpcent** %4
store %struct.rpcent* %18, %struct.rpcent** %2
br label %42
19: ; preds = %10
%20 = load %struct.rpcent*, %struct.rpcent** %4
%21 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %20, i32 0, i32 1
%22 = load i8**, i8*** %21
store i8** %22, i8*** %5
br label %23
23: ; preds = %36, %19
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = load i8**, i8*** %5
%29 = load i8*, i8** %28
%30 = load i8*, i8** %3
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = load %struct.rpcent*, %struct.rpcent** %4
store %struct.rpcent* %34, %struct.rpcent** %2
br label %42
35: ; preds = %27
br label %36
36: ; preds = %35
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i32 1
store i8** %38, i8*** %5
br label %23
39: ; preds = %23
br label %7
40: ; preds = %7
%41 = call i32 (...) @endrpcent()
store %struct.rpcent* null, %struct.rpcent** %2
br label %42
42: ; preds = %40, %33, %17
%43 = load %struct.rpcent*, %struct.rpcent** %2
ret %struct.rpcent* %43
}

LLVM IR (-O2):
%struct.rpcent = type { i8*, i8** }
define %struct.rpcent* @getrpcbyname(i8* %0) {
%2 = tail call i32 @setrpcent(i32 0)
%3 = tail call %struct.rpcent* (...) @getrpcent()
%4 = icmp eq %struct.rpcent* %3, null
br i1 %4, label %28, label %8
5: ; preds = %19, %14
%6 = tail call %struct.rpcent* (...) @getrpcent()
%7 = icmp eq %struct.rpcent* %6, null
br i1 %7, label %28, label %8
8: ; preds = %1, %5
%9 = phi %struct.rpcent* [ %6, %5 ], [ %3, %1 ]
%10 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %9, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %8
%15 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %9, i64 0, i32 1
%16 = load i8**, i8*** %15
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %5, label %22
19: ; preds = %22
%20 = load i8*, i8** %27
%21 = icmp eq i8* %20, null
br i1 %21, label %5, label %22
22: ; preds = %14, %19
%23 = phi i8* [ %20, %19 ], [ %17, %14 ]
%24 = phi i8** [ %27, %19 ], [ %16, %14 ]
%25 = tail call i64 @strcmp(i8* %23, i8* %0)
%26 = icmp eq i64 %25, 0
%27 = getelementptr inbounds i8*, i8** %24, i64 1
br i1 %26, label %30, label %19
28: ; preds = %5, %1
%29 = tail call i32 (...) @endrpcent()
br label %30
30: ; preds = %8, %22, %28
%31 = phi %struct.rpcent* [ null, %28 ], [ %9, %22 ], [ %9, %8 ]
ret %struct.rpcent* %31
}