int main(int argc, char **argv) {
  int length, i, j;
  char *str;
  for (i = 0; argv[i] != '\0'; i++) {
  }
  str = malloc(i);
  for (j = 1; j < i; j++) {
    strcat(str, argv[j]);
    strcat(str, " ");
  }
  length = lastWordLenght(str);
  printf("El tamaño de la ultima palabra es %d\n", length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1183 <main+0x43>
jmp    1175 <main+0x35>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115d <main+0x1d>
movslq -0x18(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d6 <main+0x96>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1197 <main+0x57>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1050 <lastWordLenght@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0x0,0x8(%r14,%rbx,8)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x20>
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
test   $0xfffffffe,%ebx
je     11c4 <main+0x74>
mov    %ebx,%r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r12,%rdi
call   1070 <strcat@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%r12,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <main+0x50>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <lastWordLenght@plt>
lea    0xe2b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [39 x i8] c"El tama\C3\B1o de la ultima palabra es %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %10
10: ; preds = %18, %2
%11 = load i8**, i8*** %5
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %10
br label %18
18: ; preds = %17
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %10
21: ; preds = %10
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = call i8* @malloc(i64 %23)
store i8* %24, i8** %9
store i32 1, i32* %8
br label %25
25: ; preds = %39, %21
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load i8*, i8** %9
%31 = load i8**, i8*** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i8* @strcat(i8* %30, i8* %35)
%37 = load i8*, i8** %9
%38 = call i8* @strcat(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %29
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %25
42: ; preds = %25
%43 = load i8*, i8** %9
%44 = call i32 (i8*, ...) bitcast (i32 (...)* @lastWordLenght to i32 (i8*, ...)*)(i8* %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"El tama\C3\B1o de la ultima palabra es %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %8, %3 ], [ 0, %2 ]
%5 = getelementptr inbounds i8*, i8** %1, i64 %4
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
%8 = add nuw i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = and i64 %4, 4294967295
%11 = tail call i8* @malloc(i64 %10)
%12 = and i64 %4, 4294967294
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %9, %14
%15 = phi i64 [ %22, %14 ], [ 1, %9 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i8* @strcat(i8* dereferenceable(1) %11, i8* dereferenceable(1) %17)
%19 = tail call i64 @strlen(i8* dereferenceable(1) %11)
%20 = getelementptr i8, i8* %11, i64 %19
%21 = bitcast i8* %20 to i16*
store i16 32, i16* %21
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %14
24: ; preds = %14, %9
%25 = tail call i32 (i8*, ...) bitcast (i32 (...)* @lastWordLenght to i32 (i8*, ...)*)(i8* %11)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret i32 0
}