#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 **);
scalar_t__ ft_tab_cmp(char *, char *);
void ft_sort_wordtab(char **tab) {
  int i;
  int k;
  k = 0;
  while (!k) {
    i = 0;
    k = 1;
    while (tab[++i])
      if (ft_tab_cmp(tab[i - 1], tab[i]) > 0) {
        ft_swap(tab + i - 1, tab + i);
        k = 0;
      }
  }
}


x86 assembly (clang, -O0):
<ft_sort_wordtab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1149 <ft_sort_wordtab+0x29>
jmp    11d6 <ft_sort_wordtab+0xb6>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%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     11d1 <ft_sort_wordtab+0xb1>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <ft_tab_cmp@plt>
cmp    $0x0,%rax
jle    11cc <ft_sort_wordtab+0xac>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0xfffffffffffffff8,%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1040 <ft_swap@plt>
movl   $0x0,-0x10(%rbp)
jmp    1157 <ft_sort_wordtab+0x37>
jmp    1133 <ft_sort_wordtab+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_sort_wordtab>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
jmp    1134 <ft_sort_wordtab+0x14>
nopl   0x0(%rax)
test   %ebp,%ebp
jne    117c <ft_sort_wordtab+0x5c>
mov    0x8(%r14),%rsi
test   %rsi,%rsi
je     117c <ft_sort_wordtab+0x5c>
mov    $0x1,%ebp
mov    %r14,%rbx
jmp    115c <ft_sort_wordtab+0x3c>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rbx),%rsi
mov    %r15,%rbx
test   %rsi,%rsi
je     1130 <ft_sort_wordtab+0x10>
lea    0x8(%rbx),%r15
mov    (%rbx),%rdi
call   1030 <ft_tab_cmp@plt>
test   %rax,%rax
jle    1150 <ft_sort_wordtab+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <ft_swap@plt>
xor    %ebp,%ebp
jmp    1150 <ft_sort_wordtab+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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