#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*/ bubble(int, char **);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
char *strtok(char *, char *);
main() {
  int asize = 10;
  int i;
  int acount;
  char *array[asize];
  char string[] = "this is the ten token sentence that should be sorted";
  char *tokenptr;
  tokenptr = strtok(string, " ");
  acount = 0;
  while (tokenptr != NULL) {
    array[acount] = tokenptr;
    tokenptr = strtok(NULL, " ");
    acount++;
  }
  for (i = 1; i < 11; i++)
    printf("%s\n", array[i]);
  bubble(asize, array);
  printf("\nsorted list\n");
  for (i = 1; i < 10; i++)
    printf("%10s   length is %d \n", array[i], strlen(array[i]));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x35,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     11fd <main+0xad>
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rdx
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4f(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c0 <main+0x70>
movl   $0x1,-0xc(%rbp)
cmpl   $0xb,-0xc(%rbp)
jge    1236 <main+0xe6>
mov    -0x70(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1204 <main+0xb4>
mov    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <bubble@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    12a0 <main+0x150>
mov    -0x70(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    %rcx,-0x78(%rbp)
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1257 <main+0x107>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movabs $0x646574726f7320,%rax
mov    %rax,0x7d(%rsp)
lea    0xea1(%rip),%r14
lea    0x50(%rsp),%rdi
mov    %r14,%rsi
call   1070 <strtok@plt>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1070 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11b0 <main+0x60>
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rdi
call   1030 <puts@plt>
mov    0x18(%rsp),%rdi
call   1030 <puts@plt>
mov    0x20(%rsp),%rdi
call   1030 <puts@plt>
mov    0x28(%rsp),%rdi
call   1030 <puts@plt>
mov    0x30(%rsp),%rdi
call   1030 <puts@plt>
mov    0x38(%rsp),%rdi
call   1030 <puts@plt>
mov    0x40(%rsp),%rdi
call   1030 <puts@plt>
mov    0x48(%rsp),%rdi
call   1030 <puts@plt>
mov    0x50(%rsp),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    $0xa,%edi
call   1040 <bubble@plt>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xde0(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x38(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x48(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string = [53 x i8] c"this is the ten token sentence that should be sorted\00"
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [14 x i8] c"\0Asorted list\0A\00"
@.str.3 = [22 x i8] c"%10s length is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [53 x i8]
%8 = alloca i8*
store i32 0, i32* %1
store i32 10, i32* %2
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8*, i64 %10
store i64 %10, i64* %6
%13 = bitcast [53 x i8]* %7 to i8*
%14 = getelementptr inbounds [53 x i8], [53 x i8]* %7, i64 0, i64 0
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %8
store i32 0, i32* %4
br label %16
16: ; preds = %19, %0
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i8*, i8** %8
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %12, i64 %22
store i8* %20, i8** %23
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %16
27: ; preds = %16
store i32 1, i32* %3
br label %28
28: ; preds = %37, %27
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 11
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %12, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %28
40: ; preds = %28
%41 = load i32, i32* %2
%42 = call i32 @bubble(i32 %41, i8** %12)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %44
44: ; preds = %58, %40
%45 = load i32, i32* %3
%46 = icmp slt i32 %45, 10
br i1 %46, label %47, label %61
47: ; preds = %44
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %12, i64 %49
%51 = load i8*, i8** %50
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %12, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @strlen(i8* %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %51, i32 %56)
br label %58
58: ; preds = %47
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 1
store i32 %60, i32* %3
br label %44
61: ; preds = %44
%62 = load i8*, i8** %5
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@__const.main.string = [53 x i8] c"this is the ten token sentence that should be sorted\00"
@.str = [2 x i8] c" \00"
@.str.3 = [22 x i8] c"%10s length is %d \0A\00"
@str = [13 x i8] c"\0Asorted list\00"
define i32 @main() {
%1 = alloca [53 x i8]
%2 = alloca [10 x i8*]
%3 = getelementptr inbounds [53 x i8], [53 x i8]* %1, i64 0, i64 0
%4 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i8* %4, null
br label %68
6: ; preds = %68
%7 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 1
%11 = call i32 @puts(i8* dereferenceable(1) %8)
%12 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @puts(i8* dereferenceable(1) %13)
%15 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 3
%16 = load i8*, i8** %15
%17 = call i32 @puts(i8* dereferenceable(1) %16)
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 4
%19 = load i8*, i8** %18
%20 = call i32 @puts(i8* dereferenceable(1) %19)
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 5
%22 = load i8*, i8** %21
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 6
%25 = load i8*, i8** %24
%26 = call i32 @puts(i8* dereferenceable(1) %25)
%27 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 7
%28 = load i8*, i8** %27
%29 = call i32 @puts(i8* dereferenceable(1) %28)
%30 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 8
%31 = load i8*, i8** %30
%32 = call i32 @puts(i8* dereferenceable(1) %31)
%33 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 9
%34 = load i8*, i8** %33
%35 = call i32 @puts(i8* dereferenceable(1) %34)
%36 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 10
%37 = load i8*, i8** %36
%38 = call i32 @puts(i8* dereferenceable(1) %37)
%39 = call i32 @bubble(i32 10, i8** %9)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%41 = load i8*, i8** %10
%42 = call i32 @strlen(i8* %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %41, i32 %42)
%44 = load i8*, i8** %12
%45 = call i32 @strlen(i8* %44)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %44, i32 %45)
%47 = load i8*, i8** %15
%48 = call i32 @strlen(i8* %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %47, i32 %48)
%50 = load i8*, i8** %18
%51 = call i32 @strlen(i8* %50)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %50, i32 %51)
%53 = load i8*, i8** %21
%54 = call i32 @strlen(i8* %53)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %53, i32 %54)
%56 = load i8*, i8** %24
%57 = call i32 @strlen(i8* %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %56, i32 %57)
%59 = load i8*, i8** %27
%60 = call i32 @strlen(i8* %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %59, i32 %60)
%62 = load i8*, i8** %30
%63 = call i32 @strlen(i8* %62)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %62, i32 %63)
%65 = load i8*, i8** %33
%66 = call i32 @strlen(i8* %65)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %65, i32 %66)
ret i32 0
68: ; preds = %0, %68
%69 = phi i64 [ %73, %68 ], [ 0, %0 ]
%70 = phi i8* [ %72, %68 ], [ %4, %0 ]
%71 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %69
store i8* %70, i8** %71
%72 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%73 = add nuw i64 %69, 1
%74 = icmp eq i8* %72, null
br i1 %74, label %6, label %68
}