#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*/ strcmp(char *, char *);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ usage();
int opt(int argc, char **argv) {
  int arg, index = 0;
  if (argc > 3) {
    usage();
  }
  argc--;
  while (index <= argc) {
    if (strstr(argv[index], "rtmpserver")) {
      arg = 0;
    } else if (!strcmp(argv[index], "stop")) {
      arg = 1;
    } else if (!strcmp(argv[index], "nodaemon")) {
      arg = 2;
    } else {
      arg = -1;
      break;
    }
    index++;
  }
  return arg;
}


x86 assembly (clang, -O0):
<opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x4(%rbp)
jle    1157 <opt+0x27>
mov    $0x0,%al
call   1040 <usage@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1218 <opt+0xe8>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     119a <opt+0x6a>
movl   $0x0,-0x14(%rbp)
jmp    120a <opt+0xda>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <opt+0x97>
movl   $0x1,-0x14(%rbp)
jmp    1205 <opt+0xd5>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe36(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f4 <opt+0xc4>
movl   $0x2,-0x14(%rbp)
jmp    1200 <opt+0xd0>
movl   $0xffffffff,-0x14(%rbp)
jmp    1218 <opt+0xe8>
jmp    1205 <opt+0xd5>
jmp    120a <opt+0xda>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1160 <opt+0x30>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x4,%edi
jl     114e <opt+0x1e>
xor    %eax,%eax
call   1040 <usage@plt>
jmp    1152 <opt+0x22>
test   %ebp,%ebp
jle    11c6 <opt+0x96>
mov    %ebp,%r13d
xor    %r12d,%r12d
lea    0xea1(%rip),%r14
lea    0xea5(%rip),%r15
jmp    1179 <opt+0x49>
mov    $0x1,%eax
nopl   (%rax)
add    $0x1,%r12
cmp    %r12,%r13
je     11c6 <opt+0x96>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
mov    $0x0,%eax
test   %rcx,%rcx
jne    1170 <opt+0x40>
mov    (%rbx,%r12,8),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1168 <opt+0x38>
mov    %rbp,%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcmp@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
je     1170 <opt+0x40>
mov    $0xffffffff,%eax
jmp    11c6 <opt+0x96>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"rtmpserver\00"
@.str.1 = [5 x i8] c"stop\00"
@.str.2 = [9 x i8] c"nodaemon\00"
define i32 @opt(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
br label %14
14: ; preds = %48, %11
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %51
18: ; preds = %14
%19 = load i8**, i8*** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 0, i32* %5
br label %48
27: ; preds = %18
%28 = load i8**, i8*** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %27
store i32 1, i32* %5
br label %47
36: ; preds = %27
%37 = load i8**, i8*** %4
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %36
store i32 2, i32* %5
br label %46
45: ; preds = %36
store i32 -1, i32* %5
br label %51
46: ; preds = %44
br label %47
47: ; preds = %46, %35
br label %48
48: ; preds = %47, %26
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %14
51: ; preds = %45, %14
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
@.str = [11 x i8] c"rtmpserver\00"
@.str.1 = [5 x i8] c"stop\00"
@.str.2 = [9 x i8] c"nodaemon\00"
define i32 @opt(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %8
6: ; preds = %2
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %27
8: ; preds = %4, %6
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %23
%11 = phi i64 [ 0, %8 ], [ %25, %23 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strstr(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i8*, i8** %12
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20, %16, %10
%24 = phi i32 [ 0, %10 ], [ 1, %16 ], [ 2, %20 ]
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %10
27: ; preds = %23, %20, %6
%28 = phi i32 [ undef, %6 ], [ -1, %20 ], [ %24, %23 ]
ret i32 %28
}