#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*/ ft_find_bsq(char *, char **, int *);
char **ft_get_arr(char *);
char *ft_get_key(char *);
int ft_height(char *);
int ft_key_len(char *);
int ft_length(char *);
int /*<<< orphan*/ ft_puterr(char *);
int /*<<< orphan*/ ft_valid_key(char *);
int /*<<< orphan*/ ft_validate_map(char **, char *, int);
scalar_t__ malloc(int);
void ft_handle_bsq(char *map) {
  char *key;
  char **d_arr;
  int *x_y;
  x_y = (int *)malloc(sizeof(int) * 2);
  x_y[0] = ft_length(map);
  x_y[1] = ft_height(map);
  key = ft_get_key(map);
  d_arr = ft_get_arr(map);
  if (!ft_valid_key(map) || !ft_validate_map(d_arr, key, x_y[0]) ||
      x_y[1] <= 0 || ft_key_len(map) != x_y[1] || ft_key_len(map) <= 0)
    ft_puterr("map error\n");
  else
    ft_find_bsq(key, d_arr, x_y);
}


x86 assembly (clang, -O0):
<ft_handle_bsq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <ft_length@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <ft_height@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rdi
call   1060 <ft_get_key@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <ft_get_arr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ft_valid_key@plt>
cmp    $0x0,%eax
je     125b <ft_handle_bsq+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1090 <ft_validate_map@plt>
cmp    $0x0,%eax
je     125b <ft_handle_bsq+0xbb>
mov    -0x20(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jle    125b <ft_handle_bsq+0xbb>
mov    -0x8(%rbp),%rdi
call   10a0 <ft_key_len@plt>
mov    -0x20(%rbp),%rcx
cmp    0x4(%rcx),%eax
jne    125b <ft_handle_bsq+0xbb>
mov    -0x8(%rbp),%rdi
call   10a0 <ft_key_len@plt>
cmp    $0x0,%eax
jg     126c <ft_handle_bsq+0xcc>
lea    0xd9e(%rip),%rdi
call   10c0 <ft_puterr@plt>
jmp    127d <ft_handle_bsq+0xdd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ft_find_bsq@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_handle_bsq>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <ft_length@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <ft_height@plt>
mov    %eax,0x4(%r14)
mov    %rbx,%rdi
call   1060 <ft_get_key@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   10b0 <ft_get_arr@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <ft_valid_key@plt>
test   %eax,%eax
je     123d <ft_handle_bsq+0x9d>
mov    (%r14),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <ft_validate_map@plt>
test   %eax,%eax
je     123d <ft_handle_bsq+0x9d>
cmpl   $0x0,0x4(%r14)
jle    123d <ft_handle_bsq+0x9d>
mov    %rbx,%rdi
call   10a0 <ft_key_len@plt>
cmp    0x4(%r14),%eax
jne    123d <ft_handle_bsq+0x9d>
mov    %rbx,%rdi
call   10a0 <ft_key_len@plt>
test   %eax,%eax
jle    123d <ft_handle_bsq+0x9d>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <ft_find_bsq@plt>
lea    0xdbc(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    10c0 <ft_puterr@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"map error\0A\00"
define void @ft_handle_bsq(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32*
store i8* %0, i8** %2
%6 = call i64 @malloc(i32 8)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %5
%8 = load i8*, i8** %2
%9 = call i32 @ft_length(i8* %8)
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 %9, i32* %11
%12 = load i8*, i8** %2
%13 = call i32 @ft_height(i8* %12)
%14 = load i32*, i32** %5
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 %13, i32* %15
%16 = load i8*, i8** %2
%17 = call i8* @ft_get_key(i8* %16)
store i8* %17, i8** %3
%18 = load i8*, i8** %2
%19 = call i8** @ft_get_arr(i8* %18)
store i8** %19, i8*** %4
%20 = load i8*, i8** %2
%21 = call i32 @ft_valid_key(i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %47
23: ; preds = %1
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %3
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = call i32 @ft_validate_map(i8** %24, i8* %25, i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %47
31: ; preds = %23
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 1
%34 = load i32, i32* %33
%35 = icmp sle i32 %34, 0
br i1 %35, label %47, label %36
36: ; preds = %31
%37 = load i8*, i8** %2
%38 = call i32 @ft_key_len(i8* %37)
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i64 1
%41 = load i32, i32* %40
%42 = icmp ne i32 %38, %41
br i1 %42, label %47, label %43
43: ; preds = %36
%44 = load i8*, i8** %2
%45 = call i32 @ft_key_len(i8* %44)
%46 = icmp sle i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43, %36, %31, %23, %1
%48 = call i32 @ft_puterr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %54
49: ; preds = %43
%50 = load i8*, i8** %3
%51 = load i8**, i8*** %4
%52 = load i32*, i32** %5
%53 = call i32 @ft_find_bsq(i8* %50, i8** %51, i32* %52)
br label %54
54: ; preds = %49, %47
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"map error\0A\00"
define void @ft_handle_bsq(i8* %0) {
%2 = tail call i64 @malloc(i32 8)
%3 = inttoptr i64 %2 to i32*
%4 = tail call i32 @ft_length(i8* %0)
store i32 %4, i32* %3
%5 = tail call i32 @ft_height(i8* %0)
%6 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %5, i32* %6
%7 = tail call i8* @ft_get_key(i8* %0)
%8 = tail call i8** @ft_get_arr(i8* %0)
%9 = tail call i32 @ft_valid_key(i8* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %1
%12 = load i32, i32* %3
%13 = tail call i32 @ft_validate_map(i8** %8, i8* %7, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 1
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = tail call i32 @ft_key_len(i8* %0)
%20 = load i32, i32* %6
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = tail call i32 @ft_key_len(i8* %0)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22, %18, %15, %11, %1
%26 = tail call i32 @ft_puterr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %22
%28 = tail call i32 @ft_find_bsq(i8* %7, i8** %8, i32* %3)
br label %29
29: ; preds = %27, %25
ret void
}