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

/* Variables and functions */
struct servent *getservbyname(char *, char *);
struct servent *getservbyport(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ print_servent(struct servent *);
int main(int argc, char *argv[]) {
  struct servent *sptr;
  sptr = getservbyname("domain", "udp");
  print_servent(sptr);
  sptr = getservbyname("ftp", "tcp");
  print_servent(sptr);
  sptr = getservbyname("ftps", "udp");
  print_servent(sptr);
  sptr = getservbyport(htons(21), "udp");
  print_servent(sptr);
  sptr = getservbyport(htons(22), "tcp");
  print_servent(sptr);
  sptr = getservbyport(htons(23), "tcp");
  print_servent(sptr);
  sptr = getservbyport(htons(53), "tcp");
  print_servent(sptr);
  sptr = getservbyport(htons(514), "tcp");
  print_servent(sptr);
  sptr = getservbyport(htons(514), "udp");
  print_servent(sptr);
  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)
lea    0xea3(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1040 <getservbyname@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
lea    0xe8e(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <getservbyname@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
lea    0xe76(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1040 <getservbyname@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x15,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xe3e(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x16,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xe21(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x17,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xdfc(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x35,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xdd7(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x202,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xdb2(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
mov    $0x202,%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xd85(%rip),%rsi
call   1060 <getservbyport@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <print_servent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xeb5(%rip),%r14
mov    %r14,%rsi
call   1040 <getservbyname@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
lea    0xea2(%rip),%rdi
lea    0xe9f(%rip),%rbx
mov    %rbx,%rsi
call   1040 <getservbyname@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
lea    0xe8c(%rip),%rdi
mov    %r14,%rsi
call   1040 <getservbyname@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x15,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x16,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x17,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x35,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x202,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
mov    $0x202,%edi
call   1030 <htons@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1060 <getservbyport@plt>
mov    %rax,%rdi
call   1050 <print_servent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.servent = type { i32 }
@.str = [7 x i8] c"domain\00"
@.str.1 = [4 x i8] c"udp\00"
@.str.2 = [4 x i8] c"ftp\00"
@.str.3 = [4 x i8] c"tcp\00"
@.str.4 = [5 x i8] c"ftps\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.servent*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.servent* @getservbyname(i8* getelementptr inbounds ([7 x i8], [7 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* %7, %struct.servent** %6
%8 = load %struct.servent*, %struct.servent** %6
%9 = call i32 @print_servent(%struct.servent* %8)
%10 = call %struct.servent* @getservbyname(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store %struct.servent* %10, %struct.servent** %6
%11 = load %struct.servent*, %struct.servent** %6
%12 = call i32 @print_servent(%struct.servent* %11)
%13 = call %struct.servent* @getservbyname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %13, %struct.servent** %6
%14 = load %struct.servent*, %struct.servent** %6
%15 = call i32 @print_servent(%struct.servent* %14)
%16 = call i32 @htons(i32 21)
%17 = call %struct.servent* @getservbyport(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %17, %struct.servent** %6
%18 = load %struct.servent*, %struct.servent** %6
%19 = call i32 @print_servent(%struct.servent* %18)
%20 = call i32 @htons(i32 22)
%21 = call %struct.servent* @getservbyport(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store %struct.servent* %21, %struct.servent** %6
%22 = load %struct.servent*, %struct.servent** %6
%23 = call i32 @print_servent(%struct.servent* %22)
%24 = call i32 @htons(i32 23)
%25 = call %struct.servent* @getservbyport(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store %struct.servent* %25, %struct.servent** %6
%26 = load %struct.servent*, %struct.servent** %6
%27 = call i32 @print_servent(%struct.servent* %26)
%28 = call i32 @htons(i32 53)
%29 = call %struct.servent* @getservbyport(i32 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store %struct.servent* %29, %struct.servent** %6
%30 = load %struct.servent*, %struct.servent** %6
%31 = call i32 @print_servent(%struct.servent* %30)
%32 = call i32 @htons(i32 514)
%33 = call %struct.servent* @getservbyport(i32 %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store %struct.servent* %33, %struct.servent** %6
%34 = load %struct.servent*, %struct.servent** %6
%35 = call i32 @print_servent(%struct.servent* %34)
%36 = call i32 @htons(i32 514)
%37 = call %struct.servent* @getservbyport(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %37, %struct.servent** %6
%38 = load %struct.servent*, %struct.servent** %6
%39 = call i32 @print_servent(%struct.servent* %38)
ret i32 0
}

LLVM IR (-O2):
%struct.servent = type { i32 }
@.str = [7 x i8] c"domain\00"
@.str.1 = [4 x i8] c"udp\00"
@.str.2 = [4 x i8] c"ftp\00"
@.str.3 = [4 x i8] c"tcp\00"
@.str.4 = [5 x i8] c"ftps\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.servent* @getservbyname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @print_servent(%struct.servent* %3)
%5 = tail call %struct.servent* @getservbyname(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @print_servent(%struct.servent* %5)
%7 = tail call %struct.servent* @getservbyname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @print_servent(%struct.servent* %7)
%9 = tail call i32 @htons(i32 21)
%10 = tail call %struct.servent* @getservbyport(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @print_servent(%struct.servent* %10)
%12 = tail call i32 @htons(i32 22)
%13 = tail call %struct.servent* @getservbyport(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @print_servent(%struct.servent* %13)
%15 = tail call i32 @htons(i32 23)
%16 = tail call %struct.servent* @getservbyport(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @print_servent(%struct.servent* %16)
%18 = tail call i32 @htons(i32 53)
%19 = tail call %struct.servent* @getservbyport(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @print_servent(%struct.servent* %19)
%21 = tail call i32 @htons(i32 514)
%22 = tail call %struct.servent* @getservbyport(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @print_servent(%struct.servent* %22)
%24 = tail call i32 @htons(i32 514)
%25 = tail call %struct.servent* @getservbyport(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @print_servent(%struct.servent* %25)
ret i32 0
}