#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 {
  int /*<<< orphan*/ p_name;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
struct protoent *getprotoent();
int /*<<< orphan*/ setprotoent(int);
scalar_t__ strcmp(char *, int /*<<< orphan*/);
void checkEntryDatabase() {
  struct protoent *entry;
  entry = getprotoent();
  assert(entry != NULL);
  assert(strcmp("tcp", entry->p_name) == 0);
  entry = getprotoent();
  assert(entry != NULL);
  assert(strcmp("udp", entry->p_name) == 0);
  setprotoent(1);
  entry = getprotoent();
  assert(entry != NULL);
  assert(strcmp("tcp", entry->p_name) == 0);
  entry = getprotoent();
  assert(entry != NULL);
  assert(strcmp("udp", entry->p_name) == 0);
  entry = getprotoent();
  assert(entry == NULL);
}


x86 assembly (clang, -O0):
<checkEntryDatabase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getprotoent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1030 <getprotoent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe52(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x1,%edi
call   1040 <setprotoent@plt>
mov    $0x0,%al
call   1030 <getprotoent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe04(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1030 <getprotoent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xdc8(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1030 <getprotoent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkEntryDatabase>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <getprotoent@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    (%rbx),%esi
lea    0xe9a(%rip),%r14
mov    %r14,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1030 <getprotoent@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    (%rbx),%esi
lea    0xe67(%rip),%r15
mov    %r15,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x1,%edi
call   1040 <setprotoent@plt>
xor    %eax,%eax
call   1030 <getprotoent@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1030 <getprotoent@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    (%rbx),%esi
mov    %r15,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1030 <getprotoent@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <assert@plt>

LLVM IR (-O0):
%struct.protoent = type { i32 }
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
define void @checkEntryDatabase() {
%1 = alloca %struct.protoent*
%2 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %2, %struct.protoent** %1
%3 = load %struct.protoent*, %struct.protoent** %1
%4 = icmp ne %struct.protoent* %3, null
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load %struct.protoent*, %struct.protoent** %1
%8 = getelementptr inbounds %struct.protoent, %struct.protoent* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %14, %struct.protoent** %1
%15 = load %struct.protoent*, %struct.protoent** %1
%16 = icmp ne %struct.protoent* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load %struct.protoent*, %struct.protoent** %1
%20 = getelementptr inbounds %struct.protoent, %struct.protoent* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @setprotoent(i32 1)
%27 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %27, %struct.protoent** %1
%28 = load %struct.protoent*, %struct.protoent** %1
%29 = icmp ne %struct.protoent* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load %struct.protoent*, %struct.protoent** %1
%33 = getelementptr inbounds %struct.protoent, %struct.protoent* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %39, %struct.protoent** %1
%40 = load %struct.protoent*, %struct.protoent** %1
%41 = icmp ne %struct.protoent* %40, null
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = load %struct.protoent*, %struct.protoent** %1
%45 = getelementptr inbounds %struct.protoent, %struct.protoent* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = icmp eq i64 %47, 0
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call %struct.protoent* (...) @getprotoent()
store %struct.protoent* %51, %struct.protoent** %1
%52 = load %struct.protoent*, %struct.protoent** %1
%53 = icmp eq %struct.protoent* %52, null
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
ret void
}

LLVM IR (-O2):
%struct.protoent = type { i32 }
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
define void @checkEntryDatabase() {
%1 = tail call %struct.protoent* (...) @getprotoent()
%2 = icmp ne %struct.protoent* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = getelementptr inbounds %struct.protoent, %struct.protoent* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call %struct.protoent* (...) @getprotoent()
%12 = icmp ne %struct.protoent* %11, null
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = getelementptr inbounds %struct.protoent, %struct.protoent* %11, i64 0, i32 0
%16 = load i32, i32* %15
%17 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @setprotoent(i32 1)
%22 = tail call %struct.protoent* (...) @getprotoent()
%23 = icmp ne %struct.protoent* %22, null
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = getelementptr inbounds %struct.protoent, %struct.protoent* %22, i64 0, i32 0
%27 = load i32, i32* %26
%28 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = tail call %struct.protoent* (...) @getprotoent()
%33 = icmp ne %struct.protoent* %32, null
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = getelementptr inbounds %struct.protoent, %struct.protoent* %32, i64 0, i32 0
%37 = load i32, i32* %36
%38 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
%41 = tail call i32 @assert(i32 %40)
%42 = tail call %struct.protoent* (...) @getprotoent()
%43 = icmp eq %struct.protoent* %42, null
%44 = zext i1 %43 to i32
%45 = tail call i32 @assert(i32 %44)
ret void
}