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


x86 assembly (clang, -O0):
<ft_sort_wordtab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11b8 <ft_sort_wordtab+0x98>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <ft_strcmp@plt>
cmp    $0x0,%rax
jle    11aa <ft_sort_wordtab+0x8a>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <ft_swap@plt>
movl   $0x0,-0xc(%rbp)
jmp    11b3 <ft_sort_wordtab+0x93>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
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    0x8(%rdi),%rsi
test   %rsi,%rsi
je     117b <ft_sort_wordtab+0x5b>
mov    %rdi,%r14
lea    0x8(%rdi),%r15
xor    %eax,%eax
mov    $0x1,%ebp
jmp    115a <ft_sort_wordtab+0x3a>
mov    %ebp,%eax
lea    0x1(%rax),%ebp
movslq %eax,%rcx
lea    (%r14,%rcx,8),%r15
add    $0x8,%r15
mov    0x8(%r14,%rcx,8),%rsi
test   %rsi,%rsi
je     117b <ft_sort_wordtab+0x5b>
movslq %eax,%rbx
mov    (%r14,%rbx,8),%rdi
call   1040 <ft_strcmp@plt>
test   %rax,%rax
jle    1140 <ft_sort_wordtab+0x20>
lea    (%r14,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <ft_swap@plt>
xor    %ebp,%ebp
jmp    1140 <ft_sort_wordtab+0x20>
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
store i8** %0, i8*** %2
store i32 0, i32* %3
br label %4
4: ; preds = %40, %1
%5 = load i8**, i8*** %2
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 1
%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 %41
12: ; preds = %4
%13 = load i8**, i8*** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %2
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @ft_strcmp(i8* %17, i8* %23)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %12
%27 = load i8**, i8*** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8**, i8*** %2
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
%36 = call i32 @ft_swap(i8** %30, i8** %35)
store i32 0, i32* %3
br label %40
37: ; preds = %12
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %26
br label %4
41: ; preds = %4
ret void
}

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