#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 *);
bool tryPlay(char letter, char *playingWord, char *correctWord) {
  bool success = 0;
  for (int i = 0; i < strlen(correctWord); i++) {
    if (correctWord[i] == letter) {
      playingWord[(i * 2) + 1] = letter;
      success = 1;
    }
  }
  return (success);
}


x86 assembly (clang, -O0):
<tryPlay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    1198 <tryPlay+0x88>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    1185 <tryPlay+0x75>
mov    -0x1(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movl   $0x1,-0x1c(%rbp)
jmp    118a <tryPlay+0x7a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1134 <tryPlay+0x24>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tryPlay>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r12d
mov    %rdx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1166 <tryPlay+0x56>
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    1153 <tryPlay+0x43>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1169 <tryPlay+0x59>
cmp    %r12b,(%rbx,%rbp,1)
jne    1140 <tryPlay+0x30>
mov    %r12b,0x1(%r14,%rbp,2)
mov    $0x1,%r15d
jmp    1140 <tryPlay+0x30>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tryPlay(i8 signext %0, i8* %1, i8* %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8 %0, i8* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %33, %3
%10 = load i32, i32* %8
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %36
14: ; preds = %9
%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
%20 = sext i8 %19 to i32
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %32
24: ; preds = %14
%25 = load i8, i8* %4
%26 = load i8*, i8** %5
%27 = load i32, i32* %8
%28 = mul nsw i32 %27, 2
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
store i8 %25, i8* %31
store i32 1, i32* %7
br label %32
32: ; preds = %24, %14
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %9
36: ; preds = %9
%37 = load i32, i32* %7
ret i32 %37
}

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