#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 */
int /*<<< orphan*/ _servid(char const *, char *);
int _servid_usage();
int getopt(int, char **, char *);
char *optarg;
int optind;
int main(int argc, char *argv[]) {
  char const *protocol = NULL;
  int o;
  int i;
  while ((o = getopt(argc, argv, "P:")) != -1)
    switch (o) {
    case 'P':
      protocol = optarg;
      break;
    default:
      return _servid_usage();
    }
  if (protocol == NULL || optind == argc)
    return _servid_usage();
  for (i = optind; i < argc; i++)
    _servid(protocol, argv[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)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea4(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11a5 <main+0x75>
mov    -0x1c(%rbp),%eax
sub    $0x50,%eax
jne    1191 <main+0x61>
jmp    117e <main+0x4e>
mov    0x2e73(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11a0 <main+0x70>
mov    $0x0,%al
call   1030 <_servid_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <main+0xe3>
jmp    114e <main+0x1e>
cmpq   $0x0,-0x18(%rbp)
je     11c2 <main+0x92>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11d1 <main+0xa1>
mov    $0x0,%al
call   1030 <_servid_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <main+0xe3>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120c <main+0xdc>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <_servid@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <main+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
xor    %r13d,%r13d
lea    0xeb6(%rip),%r15
mov    0x2ea7(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x50,%eax
jne    1178 <main+0x48>
mov    (%r12),%r13
jmp    1160 <main+0x30>
cmp    $0xffffffff,%eax
jne    11c6 <main+0x96>
test   %r13,%r13
je     11c6 <main+0x96>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
cmp    %ebp,%eax
je     11c6 <main+0x96>
jge    11b5 <main+0x85>
movslq %eax,%rbx
movslq %ebp,%rbp
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r13,%rdi
call   1040 <_servid@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_servid_usage@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"P:\00"
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %18 [
i32 80, label %16
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %6
br label %20
18: ; preds = %14
%19 = call i32 (...) @_servid_usage()
store i32 %19, i32* %3
br label %48
20: ; preds = %16
br label %9
21: ; preds = %9
%22 = load i8*, i8** %6
%23 = icmp eq i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i32, i32* @optind
%26 = load i32, i32* %4
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24, %21
%29 = call i32 (...) @_servid_usage()
store i32 %29, i32* %3
br label %48
30: ; preds = %24
%31 = load i32, i32* @optind
store i32 %31, i32* %8
br label %32
32: ; preds = %44, %30
%33 = load i32, i32* %8
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @_servid(i8* %37, i8* %42)
br label %44
44: ; preds = %36
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %32
47: ; preds = %32
store i32 0, i32* %3
br label %48
48: ; preds = %47, %28, %18
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"P:\00"
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ null, %2 ], [ %7, %6 ]
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %25 [
i32 -1, label %8
i32 80, label %6
]
6: ; preds = %3
%7 = load i8*, i8** @optarg
br label %3
8: ; preds = %3
%9 = icmp eq i8* %4, null
%10 = load i32, i32* @optind
%11 = icmp eq i32 %10, %0
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = icmp slt i32 %10, %0
br i1 %14, label %15, label %27
15: ; preds = %13
%16 = sext i32 %10 to i64
%17 = sext i32 %0 to i64
br label %18
18: ; preds = %15, %18
%19 = phi i64 [ %16, %15 ], [ %23, %18 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @_servid(i8* %4, i8* %21)
%23 = add nsw i64 %19, 1
%24 = icmp eq i64 %23, %17
br i1 %24, label %27, label %18
25: ; preds = %3, %8
%26 = tail call i32 (...) @_servid_usage()
br label %27
27: ; preds = %18, %25, %13
%28 = phi i32 [ 0, %13 ], [ %26, %25 ], [ 0, %18 ]
ret i32 %28
}