#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 Cmd_Argc();
int /*<<< orphan*/ Cmd_Argv(int);
int /*<<< orphan*/ Sys_Error(char *);
int /*<<< orphan*/ strcasecmp(char *, int /*<<< orphan*/);
int Cmd_CheckParm(char *parm) {
  int i;
  if (!parm)
    Sys_Error("Cmd_CheckParm: NULL");
  for (i = 1; i < Cmd_Argc(); i++)
    if (!strcasecmp((parm), (Cmd_Argv(i))))
      return i;
  return 0;
}


x86 assembly (clang, -O0):
<Cmd_CheckParm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <Cmd_CheckParm+0x23>
lea    0xea2(%rip),%rdi
call   1040 <Sys_Error@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <Cmd_Argc@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11c6 <Cmd_CheckParm+0x86>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <Cmd_Argv@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11b3 <Cmd_CheckParm+0x73>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <Cmd_CheckParm+0x8d>
jmp    11b8 <Cmd_CheckParm+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <Cmd_CheckParm+0x2a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cmd_CheckParm>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
jne    1158 <Cmd_CheckParm+0x18>
lea    0xead(%rip),%rdi
call   1040 <Sys_Error@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <Cmd_Argc@plt>
cmp    $0x2,%eax
jl     1197 <Cmd_CheckParm+0x57>
mov    $0x1,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    %ebp,%edi
call   1060 <Cmd_Argv@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1195 <Cmd_CheckParm+0x55>
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <Cmd_Argc@plt>
cmp    %eax,%ebp
jl     1170 <Cmd_CheckParm+0x30>
jmp    1197 <Cmd_CheckParm+0x57>
mov    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Cmd_CheckParm: NULL\00"
define i32 @Cmd_CheckParm(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @Sys_Error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
store i32 1, i32* %4
br label %10
10: ; preds = %23, %9
%11 = load i32, i32* %4
%12 = call i32 (...) @Cmd_Argc()
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = call i32 @Cmd_Argv(i32 %16)
%18 = call i32 @strcasecmp(i8* %15, i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %27
22: ; preds = %14
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %10
26: ; preds = %10
store i32 0, i32* %2
br label %27
27: ; preds = %26, %20
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [20 x i8] c"Cmd_CheckParm: NULL\00"
define i32 @Cmd_CheckParm(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @Sys_Error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %1
%6 = tail call i32 (...) @Cmd_Argc()
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %17
8: ; preds = %5, %13
%9 = phi i32 [ %14, %13 ], [ 1, %5 ]
%10 = tail call i32 @Cmd_Argv(i32 %9)
%11 = tail call i32 @strcasecmp(i8* %0, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = add nuw nsw i32 %9, 1
%15 = tail call i32 (...) @Cmd_Argc()
%16 = icmp slt i32 %14, %15
br i1 %16, label %8, label %17
17: ; preds = %8, %13, %5
%18 = phi i32 [ 0, %5 ], [ 0, %13 ], [ %9, %8 ]
ret i32 %18
}