#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 *, ...);
int strlen(char *);
int validplay(char play[], char hand[]) {
  if (1)
    printf("enters validplay\n");
  int h = 0, i, j, flag, flagcount = 0;
  for (i = 0; i < strlen(play); i++) {
    flag = 0;
    for (j = 0; j < strlen(hand); j++) {
      if ((play[i] == hand[j]) && flag == 0) {
        hand[j] = '!';
        flag++;
      } else if (i < strlen(play) - 1 && j == strlen(hand) - 1 && flag == 0) {
        if (1)
          printf("exits validplay false\n");
        return 0;
      }
      if (1)
        printf("%d%d%d play %c hand %c flag %d\n", h, i, j, play[i], hand[j],
               flag);
    }
  }
  if (1)
    printf("exits validplay true\n");
  return 1;
}


x86 assembly (clang, -O0):
<validplay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    129c <validplay+0x17c>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1289 <validplay+0x169>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11dd <validplay+0xbd>
cmpl   $0x0,-0x28(%rbp)
jne    11dd <validplay+0xbd>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x21,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1244 <validplay+0x124>
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    123f <validplay+0x11f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    123f <validplay+0x11f>
cmpl   $0x0,-0x28(%rbp)
jne    123f <validplay+0x11f>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b1 <validplay+0x191>
jmp    1244 <validplay+0x124>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rdi
movsbl (%rax,%rdi,1),%r8d
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rdi
movsbl (%rax,%rdi,1),%r9d
mov    -0x28(%rbp),%eax
lea    0xdb8(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117d <validplay+0x5d>
jmp    128e <validplay+0x16e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1153 <validplay+0x33>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validplay>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r13
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    $0x1,%ebp
lea    0xed0(%rip),%rdi
test   %eax,%eax
jle    122f <validplay+0xff>
lea    0xe90(%rip),%r12
xor    %ebp,%ebp
jmp    1197 <validplay+0x67>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1245 <validplay+0x115>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1180 <validplay+0x50>
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11ee <validplay+0xbe>
nopl   0x0(%rax,%rax,1)
movb   $0x21,(%rbx,%r15,1)
mov    $0x1,%r14d
movsbl 0x0(%r13,%rbp,1),%r8d
movsbl (%rbx,%r15,1),%r9d
mov    %r14d,(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r15
jge    1180 <validplay+0x50>
test   %r14d,%r14d
jne    11ff <validplay+0xcf>
movzbl (%rbx,%r15,1),%eax
cmp    %al,0x0(%r13,%rbp,1)
je     11b0 <validplay+0x80>
mov    %r13,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbp
jge    11bb <validplay+0x8b>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %r14d,%r14d
jne    11bb <validplay+0x8b>
add    $0xffffffff,%eax
cmp    %rax,%r15
jne    11bb <validplay+0x8b>
xor    %ebp,%ebp
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde5(%rip),%rdi
mov    $0x1,%ebp
jmp    122f <validplay+0xff>

LLVM IR (-O0):
@.str = [18 x i8] c"enters validplay\0A\00"
@.str.1 = [23 x i8] c"exits validplay false\0A\00"
@.str.2 = [32 x i8] c"%d%d%d play %c hand %c flag %d\0A\00"
@.str.3 = [22 x i8] c"exits validplay true\0A\00"
define i32 @validplay(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %10
store i32 0, i32* %7
br label %12
12: ; preds = %87, %2
%13 = load i32, i32* %7
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %90
17: ; preds = %12
store i32 0, i32* %9
store i32 0, i32* %8
br label %18
18: ; preds = %83, %17
%19 = load i32, i32* %8
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %86
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i8*, i8** %5
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %29, %35
br i1 %36, label %37, label %47
37: ; preds = %23
%38 = load i32, i32* %9
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i8*, i8** %5
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 33, i8* %44
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %65
47: ; preds = %37, %23
%48 = load i32, i32* %7
%49 = load i8*, i8** %4
%50 = call i32 @strlen(i8* %49)
%51 = sub nsw i32 %50, 1
%52 = icmp slt i32 %48, %51
br i1 %52, label %53, label %64
53: ; preds = %47
%54 = load i32, i32* %8
%55 = load i8*, i8** %5
%56 = call i32 @strlen(i8* %55)
%57 = sub nsw i32 %56, 1
%58 = icmp eq i32 %54, %57
br i1 %58, label %59, label %64
59: ; preds = %53
%60 = load i32, i32* %9
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %92
64: ; preds = %59, %53, %47
br label %65
65: ; preds = %64, %40
%66 = load i32, i32* %6
%67 = load i32, i32* %7
%68 = load i32, i32* %8
%69 = load i8*, i8** %4
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = load i8*, i8** %5
%76 = load i32, i32* %8
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %75, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = load i32, i32* %9
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %66, i32 %67, i32 %68, i32 %74, i32 %80, i32 %81)
br label %83
83: ; preds = %65
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %18
86: ; preds = %18
br label %87
87: ; preds = %86
%88 = load i32, i32* %7
%89 = add nsw i32 %88, 1
store i32 %89, i32* %7
br label %12
90: ; preds = %12
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %92
92: ; preds = %90, %62
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str.2 = [32 x i8] c"%d%d%d play %c hand %c flag %d\0A\00"
@str = [17 x i8] c"enters validplay\00"
@str.4 = [21 x i8] c"exits validplay true\00"
@str.5 = [22 x i8] c"exits validplay false\00"
define i32 @validplay(i8* %0, i8* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %51
6: ; preds = %2, %46
%7 = phi i64 [ %47, %46 ], [ 0, %2 ]
%8 = tail call i32 @strlen(i8* %1)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %46
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %0, i64 %7
%12 = trunc i64 %7 to i32
br label %13
13: ; preds = %10, %34
%14 = phi i64 [ 0, %10 ], [ %42, %34 ]
%15 = phi i32 [ 0, %10 ], [ %35, %34 ]
%16 = load i8, i8* %11
%17 = getelementptr inbounds i8, i8* %1, i64 %14
%18 = load i8, i8* %17
%19 = icmp eq i8 %16, %18
%20 = icmp eq i32 %15, 0
%21 = and i1 %20, %19
br i1 %21, label %22, label %23
22: ; preds = %13
store i8 33, i8* %17
br label %34
23: ; preds = %13
%24 = tail call i32 @strlen(i8* %0)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %7, %26
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = tail call i32 @strlen(i8* %1)
%30 = add nsw i32 %29, -1
%31 = zext i32 %30 to i64
%32 = icmp eq i64 %14, %31
%33 = and i1 %20, %32
br i1 %33, label %51, label %34
34: ; preds = %23, %28, %22
%35 = phi i32 [ 1, %22 ], [ %15, %28 ], [ %15, %23 ]
%36 = load i8, i8* %11
%37 = sext i8 %36 to i32
%38 = load i8, i8* %17
%39 = sext i8 %38 to i32
%40 = trunc i64 %14 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %12, i32 %40, i32 %37, i32 %39, i32 %35)
%42 = add nuw nsw i64 %14, 1
%43 = tail call i32 @strlen(i8* %1)
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %13, label %46
46: ; preds = %34, %6
%47 = add nuw nsw i64 %7, 1
%48 = tail call i32 @strlen(i8* %0)
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %6, label %51
51: ; preds = %46, %28, %2
%52 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0), %2 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0), %28 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0), %46 ]
%53 = phi i32 [ 1, %2 ], [ 0, %28 ], [ 1, %46 ]
%54 = tail call i32 @puts(i8* dereferenceable(1) %52)
ret i32 %53
}