#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 */

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
int checkserv(const char *serv, char **p) {
  for (; *p != NULL; ++p)
    if (*serv == **p && strcmp(serv, *p) == 0)
      return (1);
  return (0);
}


x86 assembly (clang, -O0):
<checkserv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1183 <checkserv+0x73>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    116d <checkserv+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116d <checkserv+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    118a <checkserv+0x7a>
jmp    1172 <checkserv+0x62>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <checkserv+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkserv>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rsi
xor    %r14d,%r14d
test   %rsi,%rsi
je     1157 <checkserv+0x47>
mov    %rdi,%rbp
add    $0x8,%rbx
jmp    113c <checkserv+0x2c>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
je     1157 <checkserv+0x47>
movzbl 0x0(%rbp),%eax
cmp    (%rsi),%al
jne    1130 <checkserv+0x20>
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1130 <checkserv+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkserv(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
br label %6
6: ; preds = %27, %2
%7 = load i8**, i8*** %5
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %30
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %13, %17
br i1 %18, label %19, label %26
19: ; preds = %10
%20 = load i8*, i8** %4
%21 = load i8**, i8*** %5
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %20, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %3
br label %31
26: ; preds = %19, %10
br label %27
27: ; preds = %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %5
br label %6
30: ; preds = %6
store i32 0, i32* %3
br label %31
31: ; preds = %30, %25
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @checkserv(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2, %14
%6 = phi i8* [ %16, %14 ], [ %3, %2 ]
%7 = phi i8** [ %15, %14 ], [ %1, %2 ]
%8 = load i8, i8* %0
%9 = load i8, i8* %6
%10 = icmp eq i8 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = tail call i64 @strcmp(i8* %0, i8* %6)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %5, %11
%15 = getelementptr inbounds i8*, i8** %7, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %5
18: ; preds = %11, %14, %2
%19 = phi i32 [ 0, %2 ], [ 0, %14 ], [ 1, %11 ]
ret i32 %19
}