#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 servent {
  char *s_name;
  char *s_proto;
  char **s_aliases;
  int /*<<< orphan*/ s_port;
};

/* Variables and functions */
struct servent *getservbyname(char *, char *);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int main(int argc, char *argv[]) {
  struct servent *se;
  if ((se = getservbyname("pop", "tcp"))) {
    int i;
    printf("name %s\tport %d\tproto %s\n", se->s_name, ntohs(se->s_port),
           se->s_proto);
    for (i = 0; i < 16; ++i) {
      if (!se->s_aliases[i])
        break;
      printf("  alias %s\n", se->s_aliases[i]);
    }
  }
  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)
lea    0xeb3(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <getservbyname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f8 <main+0xc8>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edi
call   1050 <ntohs@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11f3 <main+0xc3>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11c7 <main+0x97>
jmp    11f3 <main+0xc3>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a1 <main+0x71>
jmp    11f8 <main+0xc8>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1040 <getservbyname@plt>
test   %rax,%rax
je     1350 <main+0x220>
mov    %rax,%r14
mov    (%rax),%rbx
mov    0x18(%rax),%edi
call   1050 <ntohs@plt>
mov    0x8(%r14),%rcx
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x8(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x10(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x18(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x20(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x28(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x30(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xddc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x38(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x40(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x48(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd7f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x50(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x58(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x60(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd2a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x68(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xd0f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x70(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xcf4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r14),%rax
mov    0x78(%rax),%rsi
test   %rsi,%rsi
je     1350 <main+0x220>
lea    0xcd9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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