#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 strlen(char const *);
int testGagne(int *table, const char *motSecret) {
  int i;
  int gagne = 1;
  for (i = 0; i < strlen(motSecret); i++) {
    if (table[i] == 0) {
      gagne = 0;
    }
  }
  return gagne;
}


x86 assembly (clang, -O0):
<testGagne>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1176 <testGagne+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1163 <testGagne+0x53>
movl   $0x0,-0x18(%rbp)
jmp    1168 <testGagne+0x58>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <testGagne+0x1e>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGagne>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ebp
test   %eax,%eax
jle    114c <testGagne+0x3c>
xor    %ebx,%ebx
mov    (%r14,%rbx,4),%eax
test   %eax,%eax
cmove  %eax,%ebp
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1130 <testGagne+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @testGagne(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 1, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %21, %2
%8 = load i32, i32* %5
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = load i32*, i32** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 0, i32* %6
br label %20
20: ; preds = %19, %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %7
24: ; preds = %7
%25 = load i32, i32* %6
ret i32 %25
}

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