#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 */
scalar_t__ ft_canbemoved(char ***, int, int, int);
int /*<<< orphan*/ ft_move(char ***, int, int, int);
void ft_to_upleft(char **array[]) {
  int level;
  level = -1;
  while (array[++level]) {
    while (ft_canbemoved(array, level, 1, 0))
      ft_move(array, level, 1, 0);
    while (ft_canbemoved(array, level, 0, -1))
      ft_move(array, level, 0, -1);
  }
}


x86 assembly (clang, -O0):
<ft_to_upleft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c7 <ft_to_upleft+0xa7>
jmp    1153 <ft_to_upleft+0x33>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <ft_canbemoved@plt>
cmp    $0x0,%rax
je     1188 <ft_to_upleft+0x68>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <ft_move@plt>
jmp    1153 <ft_to_upleft+0x33>
jmp    118d <ft_to_upleft+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1040 <ft_canbemoved@plt>
cmp    $0x0,%rax
je     11c2 <ft_to_upleft+0xa2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1030 <ft_move@plt>
jmp    118d <ft_to_upleft+0x6d>
jmp    1133 <ft_to_upleft+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_to_upleft>:
push   %r14
push   %rbx
push   %rax
cmpq   $0x0,(%rdi)
je     1193 <ft_to_upleft+0x73>
mov    %rdi,%r14
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <ft_canbemoved@plt>
test   %rax,%rax
je     1171 <ft_to_upleft+0x51>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <ft_move@plt>
jmp    1130 <ft_to_upleft+0x10>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1030 <ft_move@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1040 <ft_canbemoved@plt>
test   %rax,%rax
jne    1160 <ft_to_upleft+0x40>
cmpq   $0x0,0x8(%r14,%rbx,8)
lea    0x1(%rbx),%rbx
jne    1130 <ft_to_upleft+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ft_to_upleft(i8*** %0) {
%2 = alloca i8***
%3 = alloca i32
store i8*** %0, i8**** %2
store i32 -1, i32* %3
br label %4
4: ; preds = %32, %1
%5 = load i8***, i8**** %2
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 1
store i32 %7, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8**, i8*** %5, i64 %8
%10 = load i8**, i8*** %9
%11 = icmp ne i8** %10, null
br i1 %11, label %12, label %33
12: ; preds = %4
br label %13
13: ; preds = %18, %12
%14 = load i8***, i8**** %2
%15 = load i32, i32* %3
%16 = call i64 @ft_canbemoved(i8*** %14, i32 %15, i32 1, i32 0)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i8***, i8**** %2
%20 = load i32, i32* %3
%21 = call i32 @ft_move(i8*** %19, i32 %20, i32 1, i32 0)
br label %13
22: ; preds = %13
br label %23
23: ; preds = %28, %22
%24 = load i8***, i8**** %2
%25 = load i32, i32* %3
%26 = call i64 @ft_canbemoved(i8*** %24, i32 %25, i32 0, i32 -1)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8***, i8**** %2
%30 = load i32, i32* %3
%31 = call i32 @ft_move(i8*** %29, i32 %30, i32 0, i32 -1)
br label %23
32: ; preds = %23
br label %4
33: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @ft_to_upleft(i8*** %0) {
%2 = load i8**, i8*** %0
%3 = icmp eq i8** %2, null
br i1 %3, label %25, label %9
4: ; preds = %21, %14
%5 = add nuw i64 %10, 1
%6 = getelementptr inbounds i8**, i8*** %0, i64 %5
%7 = load i8**, i8*** %6
%8 = icmp eq i8** %7, null
br i1 %8, label %25, label %9
9: ; preds = %1, %4
%10 = phi i64 [ %5, %4 ], [ 0, %1 ]
%11 = trunc i64 %10 to i32
%12 = tail call i64 @ft_canbemoved(i8*** %0, i32 %11, i32 1, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %17, %9
%15 = tail call i64 @ft_canbemoved(i8*** %0, i32 %11, i32 0, i32 -1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %4, label %21
17: ; preds = %9, %17
%18 = tail call i32 @ft_move(i8*** %0, i32 %11, i32 1, i32 0)
%19 = tail call i64 @ft_canbemoved(i8*** %0, i32 %11, i32 1, i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %14, label %17
21: ; preds = %14, %21
%22 = tail call i32 @ft_move(i8*** %0, i32 %11, i32 0, i32 -1)
%23 = tail call i64 @ft_canbemoved(i8*** %0, i32 %11, i32 0, i32 -1)
%24 = icmp eq i64 %23, 0
br i1 %24, label %4, label %21
25: ; preds = %4, %1
ret void
}