#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*/ printf(char *, char *);
char *strtok(char *, char *);
main(void) {
  char cadena[] = "Esta cadena, está formada por varias palabras";
  char *elemento;
  elemento = strtok(cadena, " ,");
  while (elemento != NULL) {
    printf("%s\n", elemento);
    elemento = strtok(NULL, " ,");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x2f,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xed0(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     119c <main+0x6c>
mov    -0x48(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xea1(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
jmp    1168 <main+0x38>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movups 0xef1(%rip),%xmm0
movups %xmm0,0x1f(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xede(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     118a <main+0x6a>
lea    0xecd(%rip),%r14
lea    0xec3(%rip),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.cadena = [47 x i8] c"Esta cadena, est\C3\A1 formada por varias palabras\00"
@.str = [3 x i8] c" ,\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [47 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [47 x i8]* %2 to i8*
%5 = getelementptr inbounds [47 x i8], [47 x i8]* %2, i64 0, i64 0
%6 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
br label %7
7: ; preds = %10, %0
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %3
br label %7
14: ; preds = %7
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@__const.main.cadena = [47 x i8] c"Esta cadena, est\C3\A1 formada por varias palabras\00"
@.str = [3 x i8] c" ,\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [47 x i8]
%2 = getelementptr inbounds [47 x i8], [47 x i8]* %1, i64 0, i64 0
%3 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %0, %5
%6 = phi i8* [ %8, %5 ], [ %3, %0 ]
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %5
10: ; preds = %5, %0
ret i32 0
}