#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*/ memcpy(char *, char *, char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char, char);
char strlen(char *);
void check_password_1(char *input, char *local_pass, int index,
                      int *outer_ret) {
  char buf[0x20];
  int ret = 0;
  char j = index;
  memset(buf, 0, sizeof buf);
  if (input[j] == local_pass[j]) {
    if (strlen(local_pass) < j) {
      ret = 1;
    } else {
      check_password_1(input, local_pass, j + 1, &ret);
      memcpy(buf, input, strlen(input));
    }
  } else {
    printf("FAIL! %c != %c\n", input[j], local_pass[j]);
  }
  *outer_ret = ret;
}


x86 assembly (clang, -O0):
<check_password_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x45(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
movsbq -0x45(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movsbq -0x45(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1210 <check_password_1+0xc0>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
movsbl %al,%eax
movsbl -0x45(%rbp),%ecx
cmp    %ecx,%eax
jge    11ca <check_password_1+0x7a>
movl   $0x1,-0x44(%rbp)
jmp    120b <check_password_1+0xbb>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x45(%rbp),%edx
add    $0x1,%edx
lea    -0x44(%rbp),%rcx
call   1070 <check_password_1@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
movsbl %al,%edx
call   1060 <memcpy@plt>
jmp    1238 <check_password_1+0xe8>
mov    -0x8(%rbp),%rax
movsbq -0x45(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movsbq -0x45(%rbp),%rcx
lea    0xdd4(%rip),%rdi
movsbl %dl,%esi
movsbl (%rax,%rcx,1),%edx
call   1040 <printf@plt>
mov    -0x44(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_password_1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rcx,%r14
mov    %edx,%ebx
mov    %rsi,%r12
mov    %rdi,%r15
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
movsbq %bl,%rcx
mov    (%r15,%rcx,1),%al
mov    (%r12,%rcx,1),%cl
cmp    %cl,%al
jne    11da <check_password_1+0x8a>
mov    %r12,%rdi
call   1030 <strlen@plt>
movsbl %al,%eax
movsbl %bl,%edx
mov    $0x1,%ebp
cmp    %eax,%edx
jg     11ec <check_password_1+0x9c>
add    $0x1,%edx
lea    0xc(%rsp),%rcx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <check_password_1@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
movsbl %al,%edx
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
mov    0xc(%rsp),%ebp
jmp    11ec <check_password_1+0x9c>
movsbl %al,%esi
movsbl %cl,%edx
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
mov    %ebp,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"FAIL! %c != %c\0A\00"
define void @check_password_1(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [32 x i8]
%10 = alloca i32
%11 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 0, i32* %10
%12 = load i32, i32* %7
%13 = trunc i32 %12 to i8
store i8 %13, i8* %11
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 32)
%16 = load i8*, i8** %5
%17 = load i8, i8* %11
%18 = sext i8 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8*, i8** %6
%23 = load i8, i8* %11
%24 = sext i8 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %21, %27
br i1 %28, label %29, label %49
29: ; preds = %4
%30 = load i8*, i8** %6
%31 = call signext i8 @strlen(i8* %30)
%32 = sext i8 %31 to i32
%33 = load i8, i8* %11
%34 = sext i8 %33 to i32
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %29
store i32 1, i32* %10
br label %48
37: ; preds = %29
%38 = load i8*, i8** %5
%39 = load i8*, i8** %6
%40 = load i8, i8* %11
%41 = sext i8 %40 to i32
%42 = add nsw i32 %41, 1
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%44 = load i8*, i8** %5
%45 = load i8*, i8** %5
%46 = call signext i8 @strlen(i8* %45)
%47 = call i32 @memcpy(i8* %43, i8* %44, i8 signext %46)
br label %48
48: ; preds = %37, %36
br label %61
49: ; preds = %4
%50 = load i8*, i8** %5
%51 = load i8, i8* %11
%52 = sext i8 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = load i8*, i8** %6
%56 = load i8, i8* %11
%57 = sext i8 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %54, i8 signext %59)
br label %61
61: ; preds = %49, %48
%62 = load i32, i32* %10
%63 = load i32*, i32** %8
store i32 %62, i32* %63
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"FAIL! %c != %c\0A\00"
define void @check_password_1(i8* %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca [32 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = zext i32 %2 to i64
%10 = call i32 @memset(i8* %7, i32 0, i32 32)
%11 = shl i64 %9, 56
%12 = ashr exact i64 %11, 56
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %14, %16
br i1 %17, label %18, label %29
18: ; preds = %4
%19 = call signext i8 @strlen(i8* %1)
%20 = sext i8 %19 to i32
%21 = shl i32 %2, 24
%22 = ashr exact i32 %21, 24
%23 = icmp sgt i32 %22, %20
br i1 %23, label %31, label %24
24: ; preds = %18
%25 = add nsw i32 %22, 1
%26 = call signext i8 @strlen(i8* %0)
%27 = call i32 @memcpy(i8* %7, i8* %0, i8 signext %26)
%28 = load i32, i32* %6
br label %31
29: ; preds = %4
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %14, i8 signext %16)
br label %31
31: ; preds = %18, %24, %29
%32 = phi i32 [ %28, %24 ], [ 0, %29 ], [ 1, %18 ]
store i32 %32, i32* %3
ret void
}