#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;
  int r_number;
  scalar_t__ *r_aliases;
};

/* Variables and functions */
int /*<<< orphan*/ endrpcent();
struct rpcent *getrpcent();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct rpcent *ent;
  while ((ent = getrpcent()) != NULL) {
    printf("%s: %i", ent->r_name, ent->r_number);
    while (ent->r_aliases[0])
      printf(" %s", *ent->r_aliases++);
    printf("\n");
  }
  endrpcent();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getrpcent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c5 <main+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
cmpq   $0x0,(%rax)
je     11b2 <main+0x82>
mov    -0x18(%rbp),%rcx
mov    0x10(%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,0x10(%rcx)
mov    (%rax),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1177 <main+0x47>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1146 <main+0x16>
mov    $0x0,%al
call   1030 <endrpcent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <getrpcent@plt>
test   %rax,%rax
je     11c0 <main+0x80>
mov    %rax,%rbx
lea    0xea5(%rip),%r14
lea    0xea5(%rip),%r15
jmp    1189 <main+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getrpcent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c0 <main+0x80>
mov    (%rbx),%rsi
mov    0x8(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
mov    0x10(%rbx),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1170 <main+0x30>
add    $0x8,%rax
mov    %rax,0x10(%rbx)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
call   1040 <endrpcent@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rpcent = type { i8*, i32, i64* }
@.str = [7 x i8] c"%s: %i\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rpcent*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %32, %2
%8 = call %struct.rpcent* (...) @getrpcent()
store %struct.rpcent* %8, %struct.rpcent** %6
%9 = icmp ne %struct.rpcent* %8, null
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load %struct.rpcent*, %struct.rpcent** %6
%12 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %11, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = load %struct.rpcent*, %struct.rpcent** %6
%15 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %16)
br label %18
18: ; preds = %25, %10
%19 = load %struct.rpcent*, %struct.rpcent** %6
%20 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %19, i32 0, i32 2
%21 = load i64*, i64** %20
%22 = getelementptr inbounds i64, i64* %21, i64 0
%23 = load i64, i64* %22
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %18
%26 = load %struct.rpcent*, %struct.rpcent** %6
%27 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %26, i32 0, i32 2
%28 = load i64*, i64** %27
%29 = getelementptr inbounds i64, i64* %28, i32 1
store i64* %29, i64** %27
%30 = load i64, i64* %28
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %30)
br label %18
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %7
34: ; preds = %7
%35 = call i32 (...) @endrpcent()
ret i32 0
}

LLVM IR (-O2):
%struct.rpcent = type { i8*, i32, i64* }
@.str = [7 x i8] c"%s: %i\00"
@.str.1 = [4 x i8] c" %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.rpcent* (...) @getrpcent()
%4 = icmp eq %struct.rpcent* %3, null
br i1 %4, label %28, label %5
5: ; preds = %2, %24
%6 = phi %struct.rpcent* [ %26, %24 ], [ %3, %2 ]
%7 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %6, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %6, i64 0, i32 1
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %10)
%12 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %6, i64 0, i32 2
%13 = load i64*, i64** %12
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %5, %16
%17 = phi i64 [ %22, %16 ], [ %14, %5 ]
%18 = phi i64* [ %21, %16 ], [ %13, %5 ]
%19 = getelementptr inbounds i64, i64* %18, i64 1
store i64* %19, i64** %12
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%21 = load i64*, i64** %12
%22 = load i64, i64* %21
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %16
24: ; preds = %16, %5
%25 = tail call i32 @putchar(i32 10)
%26 = tail call %struct.rpcent* (...) @getrpcent()
%27 = icmp eq %struct.rpcent* %26, null
br i1 %27, label %28, label %5
28: ; preds = %24, %2
%29 = tail call i32 (...) @endrpcent()
ret i32 0
}