#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 *ft_algorithm(int **, int, int, int *);
int **ft_ch_to_int(char **, int, int, char);
int /*<<< orphan*/ ft_draw_square(char **, int *, int, char);
int /*<<< orphan*/ ft_put_ch_arr(char **);
int /*<<< orphan*/ ft_putchar(char);
void ft_find_bsq(char *key, char **d_arr, int *x_y) {
  int **int_arr;
  int length;
  int height;
  length = x_y[0];
  height = x_y[1];
  x_y[0] = -1;
  x_y[1] = -1;
  if (length == 1 && height == 1) {
    if (d_arr[0][0] == key[0])
      ft_putchar(key[2]);
    else
      ft_putchar(key[1]);
    ft_putchar('\n');
    return;
  }
  int_arr = ft_ch_to_int(d_arr, height, length, key[0]);
  x_y = ft_algorithm(int_arr, height, length, x_y);
  if (x_y[0] != -1 && x_y[1] != -1)
    ft_draw_square(d_arr, x_y, int_arr[x_y[0]][x_y[1]] - 1, key[2]);
  ft_put_ch_arr(d_arr);
}


x86 assembly (clang, -O0):
<ft_find_bsq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
cmpl   $0x1,-0x24(%rbp)
jne    11e7 <ft_find_bsq+0x97>
cmpl   $0x1,-0x28(%rbp)
jne    11e7 <ft_find_bsq+0x97>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11cb <ft_find_bsq+0x7b>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <ft_putchar@plt>
jmp    11d8 <ft_find_bsq+0x88>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <ft_putchar@plt>
mov    $0xa,%edi
call   1040 <ft_putchar@plt>
jmp    126e <ft_find_bsq+0x11e>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
call   1030 <ft_ch_to_int@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1070 <ft_algorithm@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
je     1265 <ft_find_bsq+0x115>
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,0x4(%rax)
je     1265 <ft_find_bsq+0x115>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x18(%rbp),%rcx
movslq 0x4(%rcx),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%ecx
call   1060 <ft_draw_square@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ft_put_ch_arr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_find_bsq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdx),%ebp
mov    0x4(%rdx),%r12d
movq   $0xffffffffffffffff,(%rdx)
cmp    $0x1,%ebp
jne    11ac <ft_find_bsq+0x5c>
cmp    $0x1,%r12d
jne    11ac <ft_find_bsq+0x5c>
mov    (%r14),%rax
mov    (%rax),%al
xor    %ecx,%ecx
cmp    (%r15),%al
sete   %cl
movsbl 0x1(%rcx,%r15,1),%edi
call   1040 <ft_putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ft_putchar@plt>
movsbl (%r15),%ecx
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
call   1030 <ft_ch_to_int@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1070 <ft_algorithm@plt>
movslq (%rax),%rcx
cmp    $0xffffffffffffffff,%rcx
je     11fe <ft_find_bsq+0xae>
movslq 0x4(%rax),%rdx
cmp    $0xffffffffffffffff,%rdx
je     11fe <ft_find_bsq+0xae>
mov    0x0(%r13,%rcx,8),%rcx
mov    (%rcx,%rdx,4),%edx
add    $0xffffffff,%edx
movsbl 0x2(%r15),%ecx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <ft_draw_square@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <ft_put_ch_arr@plt>

LLVM IR (-O0):
define void @ft_find_bsq(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32**
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
store i32 %12, i32* %8
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
store i32 %15, i32* %9
%16 = load i32*, i32** %6
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 -1, i32* %17
%18 = load i32*, i32** %6
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 -1, i32* %19
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %49
22: ; preds = %3
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %49
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %31, %35
br i1 %36, label %37, label %42
37: ; preds = %25
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 2
%40 = load i8, i8* %39
%41 = call i32 @ft_putchar(i8 signext %40)
br label %47
42: ; preds = %25
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = call i32 @ft_putchar(i8 signext %45)
br label %47
47: ; preds = %42, %37
%48 = call i32 @ft_putchar(i8 signext 10)
br label %95
49: ; preds = %22, %3
%50 = load i8**, i8*** %5
%51 = load i32, i32* %9
%52 = load i32, i32* %8
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = call i32** @ft_ch_to_int(i8** %50, i32 %51, i32 %52, i8 signext %55)
store i32** %56, i32*** %7
%57 = load i32**, i32*** %7
%58 = load i32, i32* %9
%59 = load i32, i32* %8
%60 = load i32*, i32** %6
%61 = call i32* @ft_algorithm(i32** %57, i32 %58, i32 %59, i32* %60)
store i32* %61, i32** %6
%62 = load i32*, i32** %6
%63 = getelementptr inbounds i32, i32* %62, i64 0
%64 = load i32, i32* %63
%65 = icmp ne i32 %64, -1
br i1 %65, label %66, label %92
66: ; preds = %49
%67 = load i32*, i32** %6
%68 = getelementptr inbounds i32, i32* %67, i64 1
%69 = load i32, i32* %68
%70 = icmp ne i32 %69, -1
br i1 %70, label %71, label %92
71: ; preds = %66
%72 = load i8**, i8*** %5
%73 = load i32*, i32** %6
%74 = load i32**, i32*** %7
%75 = load i32*, i32** %6
%76 = getelementptr inbounds i32, i32* %75, i64 0
%77 = load i32, i32* %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32*, i32** %74, i64 %78
%80 = load i32*, i32** %79
%81 = load i32*, i32** %6
%82 = getelementptr inbounds i32, i32* %81, i64 1
%83 = load i32, i32* %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %80, i64 %84
%86 = load i32, i32* %85
%87 = sub nsw i32 %86, 1
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i64 2
%90 = load i8, i8* %89
%91 = call i32 @ft_draw_square(i8** %72, i32* %73, i32 %87, i8 signext %90)
br label %92
92: ; preds = %71, %66, %49
%93 = load i8**, i8*** %5
%94 = call i32 @ft_put_ch_arr(i8** %93)
br label %95
95: ; preds = %92, %47
ret void
}

LLVM IR (-O2):
define void @ft_find_bsq(i8* nocapture %0, i8** %1, i32* %2) {
%4 = load i32, i32* %2
%5 = getelementptr inbounds i32, i32* %2, i64 1
%6 = load i32, i32* %5
store i32 -1, i32* %2
store i32 -1, i32* %5
%7 = icmp eq i32 %4, 1
%8 = icmp eq i32 %6, 1
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %20
10: ; preds = %3
%11 = load i8*, i8** %1
%12 = load i8, i8* %11
%13 = load i8, i8* %0
%14 = icmp eq i8 %12, %13
%15 = select i1 %14, i64 2, i64 1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @ft_putchar(i8 signext %17)
%19 = tail call i32 @ft_putchar(i8 signext 10)
br label %43
20: ; preds = %3
%21 = load i8, i8* %0
%22 = tail call i32** @ft_ch_to_int(i8** %1, i32 %6, i32 %4, i8 signext %21)
%23 = tail call i32* @ft_algorithm(i32** %22, i32 %6, i32 %4, i32* %2)
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, -1
br i1 %25, label %41, label %26
26: ; preds = %20
%27 = getelementptr inbounds i32, i32* %23, i64 1
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, -1
br i1 %29, label %41, label %30
30: ; preds = %26
%31 = sext i32 %24 to i64
%32 = getelementptr inbounds i32*, i32** %22, i64 %31
%33 = load i32*, i32** %32
%34 = sext i32 %28 to i64
%35 = getelementptr inbounds i32, i32* %33, i64 %34
%36 = load i32, i32* %35
%37 = add nsw i32 %36, -1
%38 = getelementptr inbounds i8, i8* %0, i64 2
%39 = load i8, i8* %38
%40 = tail call i32 @ft_draw_square(i8** %1, i32* %23, i32 %37, i8 signext %39)
br label %41
41: ; preds = %30, %26, %20
%42 = tail call i32 @ft_put_ch_arr(i8** %1)
br label %43
43: ; preds = %41, %10
ret void
}