#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 *, char const *);
int core_command_has_argument(int argc, char **argv, const char *argument) {
  int i;
  char *actual_argument;
  for (i = 0; i < argc; i++) {
    actual_argument = argv[i];
    if (strcmp(actual_argument, argument) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<core_command_has_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    117c <core_command_has_argument+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1169 <core_command_has_argument+0x59>
movl   $0x1,-0x4(%rbp)
jmp    1183 <core_command_has_argument+0x73>
jmp    116e <core_command_has_argument+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <core_command_has_argument+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core_command_has_argument>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    114a <core_command_has_argument+0x3a>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114e <core_command_has_argument+0x3e>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <core_command_has_argument+0x20>
xor    %eax,%eax
jmp    1153 <core_command_has_argument+0x43>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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