#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*/ printf(char *, char const *);
scalar_t__ strcmp(char *, char const *);
int contains(int argc, char *argv[], const char *key) {
  for (int i = 1; i < argc; i++) {
    if (0 == strcmp(argv[i], key)) {
      printf("contains %s\n", key);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1198 <contains+0x78>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1185 <contains+0x65>
mov    -0x18(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119f <contains+0x7f>
jmp    118a <contains+0x6a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <contains+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1176 <contains+0x56>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
mov    %rdx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117a <contains+0x5a>
mov    %ebp,%ebp
mov    $0x2,%ebx
nopl   0x0(%rax)
cmp    %rbx,%rbp
je     118d <contains+0x6d>
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <contains+0x30>
add    $0xffffffffffffffff,%rbx
cmp    %rbp,%rbx
setb   %bl
jmp    117c <contains+0x5c>
xor    %ebx,%ebx
jmp    1190 <contains+0x70>
mov    $0x1,%bl
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
jmp    1190 <contains+0x70>
seta   %bl
movzbl %bl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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