#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 protoent {
  char *p_name;
  int p_proto;
  char **p_aliases;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void pserv(const struct protoent *prp) {
  char **pp;
  printf("name=%s, proto=%d, aliases=", prp->p_name, prp->p_proto);
  for (pp = prp->p_aliases; *pp; pp++)
    printf("%s ", *pp);
  printf("\n");
}


x86 assembly (clang, -O0):
<pserv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1178 <pserv+0x68>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <pserv+0x34>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pserv>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rsi
mov    0x8(%rdi),%edx
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1176 <pserv+0x56>
add    $0x8,%rbx
lea    0xeca(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1160 <pserv+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.protoent = type { i8*, i32, i8** }
@.str = [28 x i8] c"name=%s, proto=%d, aliases=\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @pserv(%struct.protoent* %0) {
%2 = alloca %struct.protoent*
%3 = alloca i8**
store %struct.protoent* %0, %struct.protoent** %2
%4 = load %struct.protoent*, %struct.protoent** %2
%5 = getelementptr inbounds %struct.protoent, %struct.protoent* %4, i32 0, i32 0
%6 = load i8*, i8** %5
%7 = load %struct.protoent*, %struct.protoent** %2
%8 = getelementptr inbounds %struct.protoent, %struct.protoent* %7, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %9)
%11 = load %struct.protoent*, %struct.protoent** %2
%12 = getelementptr inbounds %struct.protoent, %struct.protoent* %11, i32 0, i32 2
%13 = load i8**, i8*** %12
store i8** %13, i8*** %3
br label %14
14: ; preds = %22, %1
%15 = load i8**, i8*** %3
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18
%23 = load i8**, i8*** %3
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %3
br label %14
25: ; preds = %14
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.protoent = type { i8*, i32, i8** }
@.str = [28 x i8] c"name=%s, proto=%d, aliases=\00"
@.str.1 = [4 x i8] c"%s \00"
define void @pserv(%struct.protoent* nocapture %0) {
%2 = getelementptr inbounds %struct.protoent, %struct.protoent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = getelementptr inbounds %struct.protoent, %struct.protoent* %0, i64 0, i32 1
%5 = load i32, i32* %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %5)
%7 = getelementptr inbounds %struct.protoent, %struct.protoent* %0, i64 0, i32 2
%8 = load i8**, i8*** %7
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %1, %11
%12 = phi i8* [ %16, %11 ], [ %9, %1 ]
%13 = phi i8** [ %15, %11 ], [ %8, %1 ]
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%15 = getelementptr inbounds i8*, i8** %13, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %11
18: ; preds = %11, %1
%19 = tail call i32 @putchar(i32 10)
ret void
}