#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 r_number;
};
struct rpcdata {
  int dummy;
};

/* Variables and functions */
struct rpcdata *_rpcdata();
int /*<<< orphan*/ endrpcent();
struct rpcent *getrpcent();
int /*<<< orphan*/ setrpcent(int /*<<< orphan*/);
struct rpcent *getrpcbynumber(int number) {
  register struct rpcdata *d = _rpcdata();
  register struct rpcent *p;
  if (d == 0)
    return (0);
  setrpcent(0);
  while ((p = getrpcent())) {
    if (p->r_number == number)
      break;
  }
  endrpcent();
  return (p);
}


x86 assembly (clang, -O0):
<getrpcbynumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <_rpcdata@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116e <getrpcbynumber+0x2e>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <getrpcbynumber+0x72>
xor    %edi,%edi
call   1050 <setrpcent@plt>
mov    $0x0,%al
call   1060 <getrpcent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a3 <getrpcbynumber+0x63>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jne    119e <getrpcbynumber+0x5e>
jmp    11a3 <getrpcbynumber+0x63>
jmp    1175 <getrpcbynumber+0x35>
mov    $0x0,%al
call   1030 <endrpcent@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrpcbynumber>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <_rpcdata@plt>
test   %rax,%rax
je     117a <getrpcbynumber+0x3a>
xor    %edi,%edi
call   1050 <setrpcent@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getrpcent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1173 <getrpcbynumber+0x33>
cmp    %ebp,(%rbx)
jne    1160 <getrpcbynumber+0x20>
xor    %eax,%eax
call   1030 <endrpcent@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.rpcent = type { i32 }
%struct.rpcdata = type { i32 }
define %struct.rpcent* @getrpcbynumber(i32 %0) {
%2 = alloca %struct.rpcent*
%3 = alloca i32
%4 = alloca %struct.rpcdata*
%5 = alloca %struct.rpcent*
store i32 %0, i32* %3
%6 = call %struct.rpcdata* (...) @_rpcdata()
store %struct.rpcdata* %6, %struct.rpcdata** %4
%7 = load %struct.rpcdata*, %struct.rpcdata** %4
%8 = icmp eq %struct.rpcdata* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store %struct.rpcent* null, %struct.rpcent** %2
br label %26
10: ; preds = %1
%11 = call i32 @setrpcent(i32 0)
br label %12
12: ; preds = %22, %10
%13 = call %struct.rpcent* (...) @getrpcent()
store %struct.rpcent* %13, %struct.rpcent** %5
%14 = icmp ne %struct.rpcent* %13, null
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load %struct.rpcent*, %struct.rpcent** %5
%17 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32, i32* %3
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %15
br label %23
22: ; preds = %15
br label %12
23: ; preds = %21, %12
%24 = call i32 (...) @endrpcent()
%25 = load %struct.rpcent*, %struct.rpcent** %5
store %struct.rpcent* %25, %struct.rpcent** %2
br label %26
26: ; preds = %23, %9
%27 = load %struct.rpcent*, %struct.rpcent** %2
ret %struct.rpcent* %27
}

LLVM IR (-O2):
%struct.rpcent = type { i32 }
%struct.rpcdata = type { i32 }
define %struct.rpcent* @getrpcbynumber(i32 %0) {
%2 = tail call %struct.rpcdata* (...) @_rpcdata()
%3 = icmp eq %struct.rpcdata* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i32 @setrpcent(i32 0)
br label %6
6: ; preds = %9, %4
%7 = tail call %struct.rpcent* (...) @getrpcent()
%8 = icmp eq %struct.rpcent* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %7, i64 0, i32 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %6
13: ; preds = %9, %6
%14 = tail call i32 (...) @endrpcent()
br label %15
15: ; preds = %1, %13
%16 = phi %struct.rpcent* [ %7, %13 ], [ null, %1 ]
ret %struct.rpcent* %16
}