#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__ arghelp_wanted(int, char **);
int basic_index_of_arg(char const *, int, char **);
int /*<<< orphan*/ printf(char *, char const *, char *, char *, char *);
int index_of_arg(const char *opt_string, int argc, char *argv[]) {
  int result = basic_index_of_arg(opt_string, argc, argv);
  if (arghelp_wanted(argc, argv))
    printf("ARGV %21s %8s         %8s %s on commandline\n", opt_string, "", "",
           (result >= 0) ? "   " : "not");
  return (result);
}


x86 assembly (clang, -O0):
<index_of_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <basic_index_of_arg@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <arghelp_wanted@plt>
cmp    $0x0,%rax
je     119e <index_of_arg+0x6e>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
lea    0xeb7(%rip),%r8
lea    0xeac(%rip),%rax
cmp    $0x0,%ecx
cmovge %rax,%r8
lea    0xe71(%rip),%rdi
lea    0xe96(%rip),%rcx
mov    %rcx,%rdx
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_of_arg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <basic_index_of_arg@plt>
mov    %eax,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <arghelp_wanted@plt>
test   %rax,%rax
je     1184 <index_of_arg+0x54>
test   %r15d,%r15d
lea    0xecd(%rip),%rax
lea    0xeca(%rip),%r8
cmovns %rax,%r8
lea    0xe8e(%rip),%rdi
lea    0xeb3(%rip),%rcx
mov    %r14,%rsi
mov    %rcx,%rdx
call   1030 <printf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"ARGV %21s %8s %8s %s on commandline\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c" \00"
@.str.3 = [4 x i8] c"not\00"
define i32 @index_of_arg(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = load i8**, i8*** %6
%11 = call i32 @basic_index_of_arg(i8* %8, i32 %9, i8** %10)
store i32 %11, i32* %7
%12 = load i32, i32* %5
%13 = load i8**, i8*** %6
%14 = call i64 @arghelp_wanted(i32 %12, i8** %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = icmp sge i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %16, %3
%24 = load i32, i32* %7
ret i32 %24
}

LLVM IR (-O2):
@.str = [45 x i8] c"ARGV %21s %8s %8s %s on commandline\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c" \00"
@.str.3 = [4 x i8] c"not\00"
define i32 @index_of_arg(i8* %0, i32 %1, i8** %2) {
%4 = tail call i32 @basic_index_of_arg(i8* %0, i32 %1, i8** %2)
%5 = tail call i64 @arghelp_wanted(i32 %1, i8** %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = icmp sgt i32 %4, -1
%9 = select i1 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %7, %3
ret i32 %4
}