#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*/ strcmp(char *, char *);
short verify_cheat(char *cheat, char key) {
  cheat[6 - 1] = key;
  for (int i = 0; i != 6 - 1; i++)
    cheat[i] = cheat[i + 1];
  cheat[6 - 1] = '\0';
  if (!strcmp(cheat, "adkda"))
    return 1;
  if (!strcmp(cheat, "akdda") || !strcmp(cheat, "dkaad"))
    return 2;
  return 0;
}


x86 assembly (clang, -O0):
<verify_cheat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
je     1166 <verify_cheat+0x56>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <verify_cheat+0x23>
mov    -0x10(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1192 <verify_cheat+0x82>
movw   $0x1,-0x2(%rbp)
jmp    11d5 <verify_cheat+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11c4 <verify_cheat+0xb4>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11cf <verify_cheat+0xbf>
movw   $0x2,-0x2(%rbp)
jmp    11d5 <verify_cheat+0xc5>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_cheat>:
push   %rbx
mov    %rdi,%rbx
mov    0x1(%rdi),%eax
mov    %eax,(%rdi)
mov    %sil,0x4(%rdi)
movb   $0x0,0x5(%rdi)
lea    0xed8(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1160 <verify_cheat+0x50>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1166 <verify_cheat+0x56>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    %eax,%eax
pop    %rbx
ret
mov    $0x1,%ax
pop    %rbx
ret
mov    $0x2,%ax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"adkda\00"
@.str.1 = [6 x i8] c"akdda\00"
@.str.2 = [6 x i8] c"dkaad\00"
define signext i16 @verify_cheat(i8* %0, i8 signext %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
%7 = load i8, i8* %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 5
store i8 %7, i8* %9
store i32 0, i32* %6
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 5
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = load i8*, i8** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %10
27: ; preds = %10
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 5
store i8 0, i8* %29
%30 = load i8*, i8** %4
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %27
store i16 1, i16* %3
br label %44
34: ; preds = %27
%35 = load i8*, i8** %4
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i8*, i8** %4
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %38, %34
store i16 2, i16* %3
br label %44
43: ; preds = %38
store i16 0, i16* %3
br label %44
44: ; preds = %43, %42, %33
%45 = load i16, i16* %3
ret i16 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"adkda\00"
@.str.1 = [6 x i8] c"akdda\00"
@.str.2 = [6 x i8] c"dkaad\00"
define signext i16 @verify_cheat(i8* nocapture %0, i8 signext %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %1, i8* %3
%4 = getelementptr i8, i8* %0, i64 1
store i8 0, i8* %3
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i16 2, i16 0
br label %14
14: ; preds = %10, %7, %2
%15 = phi i16 [ 1, %2 ], [ 2, %7 ], [ %13, %10 ]
ret i16 %15
}