#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__ strcmp(char *, char *);
char *strtok(char *, char *);
unsigned int trocearCadena(char *cadena, char *trozos[], int maxTrozos) {
  int i = 1;
  if ((trozos[0] = strtok(cadena, " ,\t\n")) == NULL)
    return 0;
  while (i < maxTrozos - 2 && (trozos[i] = strtok(NULL, " ,\t\n")) != NULL) {
    if (strcmp(trozos[i], ".asciiz") == 0) {
      i++;
      trozos[i++] = strtok(NULL, "\"");
      break;
    }
    i++;
  }
  return i;
}


x86 assembly (clang, -O0):
<trocearCadena>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1040 <strtok@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1167 <trocearCadena+0x47>
movl   $0x0,-0x4(%rbp)
jmp    1225 <trocearCadena+0x105>
jmp    116c <trocearCadena+0x4c>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%edx
sub    $0x2,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x21(%rbp)
jge    11a8 <trocearCadena+0x88>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe73(%rip),%rsi
call   1040 <strtok@plt>
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b8 <trocearCadena+0x98>
jmp    121f <trocearCadena+0xff>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <trocearCadena+0xf1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe1f(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    121f <trocearCadena+0xff>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116c <trocearCadena+0x4c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trocearCadena>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r13
lea    0xec9(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     11b6 <trocearCadena+0x96>
mov    $0x1,%ebp
cmp    $0x4,%ebx
jl     11d1 <trocearCadena+0xb1>
add    $0xfffffffe,%ebx
mov    %ebx,0x4(%rsp)
mov    %ebx,%r14d
mov    $0x1,%ebx
mov    $0x3,%ebp
lea    0xe92(%rip),%r15
lea    0xe90(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,0x0(%r13,%rbx,8)
test   %rax,%rax
je     11ba <trocearCadena+0x9a>
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11be <trocearCadena+0x9e>
add    $0x1,%rbx
add    $0x1,%ebp
cmp    %rbx,%r14
jne    1180 <trocearCadena+0x60>
mov    0x4(%rsp),%ebp
jmp    11d1 <trocearCadena+0xb1>
xor    %ebp,%ebp
jmp    11d1 <trocearCadena+0xb1>
mov    %ebx,%ebp
jmp    11d1 <trocearCadena+0xb1>
lea    0xe48(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    %rax,0x8(%r13,%rbx,8)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" ,\09\0A\00"
@.str.1 = [8 x i8] c".asciiz\00"
@.str.2 = [2 x i8] c"\22\00"
define i32 @trocearCadena(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 1, i32* %8
%9 = load i8*, i8** %5
%10 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 0
store i8* %10, i8** %12
%13 = icmp eq i8* %10, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %52
15: ; preds = %3
br label %16
16: ; preds = %47, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = load i8**, i8*** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
store i8* %22, i8** %26
%27 = icmp ne i8* %22, null
br label %28
28: ; preds = %21, %16
%29 = phi i1 [ false, %16 ], [ %27, %21 ]
br i1 %29, label %30, label %50
30: ; preds = %28
%31 = load i8**, i8*** %6
%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 i64 @strcmp(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %30
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = load i8**, i8*** %6
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
store i8* %41, i8** %46
br label %50
47: ; preds = %30
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %16
50: ; preds = %38, %28
%51 = load i32, i32* %8
store i32 %51, i32* %4
br label %52
52: ; preds = %50, %14
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@.str = [5 x i8] c" ,\09\0A\00"
@.str.1 = [8 x i8] c".asciiz\00"
@.str.2 = [2 x i8] c"\22\00"
define i32 @trocearCadena(i8* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %31, label %6
6: ; preds = %3
%7 = add i32 %2, -2
%8 = icmp sgt i32 %2, 3
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %26
%12 = phi i64 [ 1, %9 ], [ %27, %26 ]
%13 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
store i8* %13, i8** %14
%15 = icmp eq i8* %13, null
br i1 %15, label %29, label %16
16: ; preds = %11
%17 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = trunc i64 %12 to i32
%21 = add nuw i64 %12, 1
%22 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = add nuw nsw i32 %20, 2
%24 = and i64 %21, 4294967295
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
store i8* %22, i8** %25
br label %31
26: ; preds = %16
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %31, label %11
29: ; preds = %11
%30 = trunc i64 %12 to i32
br label %31
31: ; preds = %26, %29, %6, %19, %3
%32 = phi i32 [ 0, %3 ], [ %23, %19 ], [ 1, %6 ], [ %30, %29 ], [ %7, %26 ]
ret i32 %32
}