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

/* Variables and functions */
struct rpcent *getrpcbyname(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("Usage: test-rpc <name>\n");
    return -1;
  }
  char *name = argv[1];
  struct rpcent *rpc = getrpcbyname(name);
  if (rpc == NULL) {
    printf("RPC %s not found.\n", name);
    return -1;
  }
  printf("Name   : %s\n", rpc->r_name);
  char **alias = rpc->r_aliases;
  while (alias != NULL && (*alias) != NULL) {
    printf("Alias  : %s\n", (*alias));
    alias++;
  }
  printf("Number : %d\n", rpc->r_number);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     115a <main+0x3a>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <getrpcbyname@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119c <main+0x7c>
mov    -0x18(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <main+0x11b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x29(%rbp)
je     11db <main+0xbb>
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11eb <main+0xcb>
jmp    1211 <main+0xf1>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    11bd <main+0x9d>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11c4 <main+0x84>
mov    0x8(%rsi),%rbp
mov    %rbp,%rdi
call   1060 <getrpcbyname@plt>
test   %rax,%rax
je     11d2 <main+0x92>
mov    %rax,%r15
mov    (%rax),%rsi
lea    0xea9(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r15),%rbx
test   %rbx,%rbx
je     11a6 <main+0x66>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11a6 <main+0x66>
add    $0x8,%rbx
lea    0xe90(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1190 <main+0x50>
mov    0x10(%r15),%esi
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11e9 <main+0xa9>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
jmp    11e3 <main+0xa3>
lea    0xe27(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rpcent = type { i8*, i8**, i32 }
@.str = [24 x i8] c"Usage: test-rpc <name>\0A\00"
@.str.1 = [19 x i8] c"RPC %s not found.\0A\00"
@.str.2 = [13 x i8] c"Name : %s\0A\00"
@.str.3 = [13 x i8] c"Alias : %s\0A\00"
@.str.4 = [13 x i8] c"Number : %d\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.rpcent*
%8 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %53
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call %struct.rpcent* @getrpcbyname(i8* %17)
store %struct.rpcent* %18, %struct.rpcent** %7
%19 = load %struct.rpcent*, %struct.rpcent** %7
%20 = icmp eq %struct.rpcent* %19, null
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %53
24: ; preds = %13
%25 = load %struct.rpcent*, %struct.rpcent** %7
%26 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load %struct.rpcent*, %struct.rpcent** %7
%30 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %29, i32 0, i32 1
%31 = load i8**, i8*** %30
store i8** %31, i8*** %8
br label %32
32: ; preds = %41, %24
%33 = load i8**, i8*** %8
%34 = icmp ne i8** %33, null
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8**, i8*** %8
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br label %39
39: ; preds = %35, %32
%40 = phi i1 [ false, %32 ], [ %38, %35 ]
br i1 %40, label %41, label %47
41: ; preds = %39
%42 = load i8**, i8*** %8
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = load i8**, i8*** %8
%46 = getelementptr inbounds i8*, i8** %45, i32 1
store i8** %46, i8*** %8
br label %32
47: ; preds = %39
%48 = load %struct.rpcent*, %struct.rpcent** %7
%49 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %48, i32 0, i32 2
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %53
53: ; preds = %47, %21, %11
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
%struct.rpcent = type { i8*, i8**, i32 }
@.str.1 = [19 x i8] c"RPC %s not found.\0A\00"
@.str.2 = [13 x i8] c"Name : %s\0A\00"
@.str.3 = [13 x i8] c"Alias : %s\0A\00"
@.str.4 = [13 x i8] c"Number : %d\0A\00"
@str = [23 x i8] c"Usage: test-rpc <name>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %35
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call %struct.rpcent* @getrpcbyname(i8* %8)
%10 = icmp eq %struct.rpcent* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %35
13: ; preds = %6
%14 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %9, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %9, i64 0, i32 1
%18 = load i8**, i8*** %17
%19 = icmp eq i8** %18, null
br i1 %19, label %30, label %20
20: ; preds = %13
%21 = load i8*, i8** %18
%22 = icmp eq i8* %21, null
br i1 %22, label %30, label %23
23: ; preds = %20, %23
%24 = phi i8* [ %28, %23 ], [ %21, %20 ]
%25 = phi i8** [ %27, %23 ], [ %18, %20 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%27 = getelementptr inbounds i8*, i8** %25, i64 1
%28 = load i8*, i8** %27
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %23
30: ; preds = %23, %20, %13
%31 = getelementptr inbounds %struct.rpcent, %struct.rpcent* %9, i64 0, i32 2
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = tail call i32 @putchar(i32 10)
br label %35
35: ; preds = %11, %30, %4
%36 = phi i32 [ -1, %4 ], [ -1, %11 ], [ 0, %30 ]
ret i32 %36
}