#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_swap(char **, char **);
void ft_advanced_sort_wordtab(char **tab, int (*cmp)(char *, char *)) {
  int i;
  i = 0;
  while (tab[i + 1]) {
    if (cmp(tab[i], tab[i + 1]) > 0) {
      ft_swap(&tab[i], &tab[i + 1]);
      i = 0;
    } else
      i++;
  }
}


x86 assembly (clang, -O0):
<ft_advanced_sort_wordtab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ac <ft_advanced_sort_wordtab+0x9c>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,8),%rsi
call   *%rax
cmp    $0x0,%eax
jle    119e <ft_advanced_sort_wordtab+0x8e>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <ft_swap@plt>
movl   $0x0,-0x14(%rbp)
jmp    11a7 <ft_advanced_sort_wordtab+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <ft_advanced_sort_wordtab+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_advanced_sort_wordtab>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    0x8(%rdi),%rsi
test   %rsi,%rsi
je     1178 <ft_advanced_sort_wordtab+0x68>
mov    %rdi,%r15
lea    0x8(%rdi),%r12
xor    %eax,%eax
mov    $0x1,%ebp
jmp    115a <ft_advanced_sort_wordtab+0x4a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
lea    0x1(%rax),%ebp
movslq %eax,%rcx
lea    (%r15,%rcx,8),%r12
add    $0x8,%r12
mov    0x8(%r15,%rcx,8),%rsi
test   %rsi,%rsi
je     1178 <ft_advanced_sort_wordtab+0x68>
movslq %eax,%rbx
mov    (%r15,%rbx,8),%rdi
call   *%r14
test   %eax,%eax
jle    1140 <ft_advanced_sort_wordtab+0x30>
lea    (%r15,%rbx,8),%rdi
mov    %r12,%rsi
call   1030 <ft_swap@plt>
xor    %ebp,%ebp
jmp    1140 <ft_advanced_sort_wordtab+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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