#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 */
struct protoent *getprotoent();
int /*<<< orphan*/ printf(char *, char *, ...);
int main(int argc, char *argv[]) {
  struct protoent *se;
  while ((se = getprotoent())) {
    int i;
    printf("name %s\tproto %d\n", se->p_name, se->p_proto);
    for (i = 0; i < 16; ++i) {
      if (!se->p_aliases[i])
        break;
      printf("  alias %s\n", se->p_aliases[i]);
    }
  }
  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   1040 <getprotoent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c5 <main+0xa5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11c0 <main+0xa0>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1194 <main+0x74>
jmp    11c0 <main+0xa0>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <main+0x4e>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getprotoent@plt>
test   %rax,%rax
je     1317 <main+0x1f7>
mov    %rax,%rbx
lea    0xec1(%rip),%r14
lea    0xecc(%rip),%r15
jmp    1163 <main+0x43>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getprotoent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1317 <main+0x1f7>
mov    (%rbx),%rsi
mov    0x8(%rbx),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x8(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x10(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x18(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x20(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x28(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x30(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x38(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x40(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x48(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x50(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x58(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x60(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x68(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x70(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x78(%rax),%rsi
test   %rsi,%rsi
je     1150 <main+0x30>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.protoent = type { i8*, i32, i8** }
@.str = [18 x i8] c"name %s\09proto %d\0A\00"
@.str.1 = [12 x i8] c" alias %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.protoent*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %44, %2
%9 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %9, %struct.protoent** %6
%10 = icmp ne %struct.protoent* %9, null
br i1 %10, label %11, label %45
11: ; preds = %8
%12 = load %struct.protoent*, %struct.protoent** %6
%13 = getelementptr inbounds %struct.protoent, %struct.protoent* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = load %struct.protoent*, %struct.protoent** %6
%16 = getelementptr inbounds %struct.protoent, %struct.protoent* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %17)
store i32 0, i32* %7
br label %19
19: ; preds = %41, %11
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 16
br i1 %21, label %22, label %44
22: ; preds = %19
%23 = load %struct.protoent*, %struct.protoent** %6
%24 = getelementptr inbounds %struct.protoent, %struct.protoent* %23, i32 0, i32 2
%25 = load i8**, i8*** %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %32, label %31
31: ; preds = %22
br label %44
32: ; preds = %22
%33 = load %struct.protoent*, %struct.protoent** %6
%34 = getelementptr inbounds %struct.protoent, %struct.protoent* %33, i32 0, i32 2
%35 = load i8**, i8*** %34
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %32
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %19
44: ; preds = %31, %19
br label %8
45: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.protoent = type { i8*, i32, i8** }
@.str = [18 x i8] c"name %s\09proto %d\0A\00"
@.str.1 = [12 x i8] c" alias %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.protoent* (...) @getprotoent()
%4 = icmp eq %struct.protoent* %3, null
br i1 %4, label %111, label %5
5: ; preds = %2, %108
%6 = phi %struct.protoent* [ %109, %108 ], [ %3, %2 ]
%7 = getelementptr inbounds %struct.protoent, %struct.protoent* %6, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.protoent, %struct.protoent* %6, i64 0, i32 1
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %10)
%12 = getelementptr inbounds %struct.protoent, %struct.protoent* %6, i64 0, i32 2
%13 = load i8**, i8*** %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %108, label %16
16: ; preds = %5
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%18 = load i8**, i8*** %12
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %108, label %22
22: ; preds = %16
%23 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%24 = load i8**, i8*** %12
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %108, label %28
28: ; preds = %22
%29 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%30 = load i8**, i8*** %12
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
br i1 %33, label %108, label %34
34: ; preds = %28
%35 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%36 = load i8**, i8*** %12
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = icmp eq i8* %38, null
br i1 %39, label %108, label %40
40: ; preds = %34
%41 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%42 = load i8**, i8*** %12
%43 = getelementptr inbounds i8*, i8** %42, i64 5
%44 = load i8*, i8** %43
%45 = icmp eq i8* %44, null
br i1 %45, label %108, label %46
46: ; preds = %40
%47 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%48 = load i8**, i8*** %12
%49 = getelementptr inbounds i8*, i8** %48, i64 6
%50 = load i8*, i8** %49
%51 = icmp eq i8* %50, null
br i1 %51, label %108, label %52
52: ; preds = %46
%53 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%54 = load i8**, i8*** %12
%55 = getelementptr inbounds i8*, i8** %54, i64 7
%56 = load i8*, i8** %55
%57 = icmp eq i8* %56, null
br i1 %57, label %108, label %58
58: ; preds = %52
%59 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %56)
%60 = load i8**, i8*** %12
%61 = getelementptr inbounds i8*, i8** %60, i64 8
%62 = load i8*, i8** %61
%63 = icmp eq i8* %62, null
br i1 %63, label %108, label %64
64: ; preds = %58
%65 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %62)
%66 = load i8**, i8*** %12
%67 = getelementptr inbounds i8*, i8** %66, i64 9
%68 = load i8*, i8** %67
%69 = icmp eq i8* %68, null
br i1 %69, label %108, label %70
70: ; preds = %64
%71 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %68)
%72 = load i8**, i8*** %12
%73 = getelementptr inbounds i8*, i8** %72, i64 10
%74 = load i8*, i8** %73
%75 = icmp eq i8* %74, null
br i1 %75, label %108, label %76
76: ; preds = %70
%77 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %74)
%78 = load i8**, i8*** %12
%79 = getelementptr inbounds i8*, i8** %78, i64 11
%80 = load i8*, i8** %79
%81 = icmp eq i8* %80, null
br i1 %81, label %108, label %82
82: ; preds = %76
%83 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %80)
%84 = load i8**, i8*** %12
%85 = getelementptr inbounds i8*, i8** %84, i64 12
%86 = load i8*, i8** %85
%87 = icmp eq i8* %86, null
br i1 %87, label %108, label %88
88: ; preds = %82
%89 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %86)
%90 = load i8**, i8*** %12
%91 = getelementptr inbounds i8*, i8** %90, i64 13
%92 = load i8*, i8** %91
%93 = icmp eq i8* %92, null
br i1 %93, label %108, label %94
94: ; preds = %88
%95 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %92)
%96 = load i8**, i8*** %12
%97 = getelementptr inbounds i8*, i8** %96, i64 14
%98 = load i8*, i8** %97
%99 = icmp eq i8* %98, null
br i1 %99, label %108, label %100
100: ; preds = %94
%101 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %98)
%102 = load i8**, i8*** %12
%103 = getelementptr inbounds i8*, i8** %102, i64 15
%104 = load i8*, i8** %103
%105 = icmp eq i8* %104, null
br i1 %105, label %108, label %106
106: ; preds = %100
%107 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %104)
br label %108
108: ; preds = %106, %100, %94, %88, %82, %76, %70, %64, %58, %52, %46, %40, %34, %28, %22, %16, %5
%109 = tail call %struct.protoent* (...) @getprotoent()
%110 = icmp eq %struct.protoent* %109, null
br i1 %110, label %111, label %5
111: ; preds = %108, %2
ret i32 0
}