#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 *, ...);
int strlen(char *);
char *strtok(char *, char *);
int main(void) {
  char frutas[] = "banana,laranja,morango";
  int tamanho = strlen(frutas);
  char *token = strtok(frutas, ",");
  for (int i = 0; i < tamanho; i++) {
    printf(token[i] == 0 ? "\\0" : "%c", token[i]);
  }
  while (token != NULL) {
    printf("\n%s", token);
    token = strtok(NULL, ",");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeaf(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xea7(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e7 <main+0xb7>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xe64(%rip),%rdi
lea    0xe5a(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdi
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1199 <main+0x69>
jmp    11ec <main+0xbc>
cmpq   $0x0,-0x30(%rbp)
je     1222 <main+0xf2>
mov    -0x30(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe03(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
jmp    11ec <main+0xbc>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movaps 0xebd(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x6f676e61726f6d,%rax
mov    %rax,0xf(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11af <main+0x7f>
mov    %ebp,%r12d
lea    0xe96(%rip),%r14
lea    0xe92(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl (%rbx,%rbp,1),%esi
test   %esi,%esi
mov    %r15,%rdi
cmove  %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1190 <main+0x60>
jmp    11b4 <main+0x84>
test   %rbx,%rbx
je     11ef <main+0xbf>
lea    0xe64(%rip),%r14
lea    0xe55(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.frutas = [23 x i8] c"banana,laranja,morango\00"
@.str = [2 x i8] c",\00"
@.str.1 = [3 x i8] c"\\0\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [23 x i8]* %2 to i8*
%7 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%10 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %4
store i32 0, i32* %5
br label %11
11: ; preds = %32, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%25 = load i8*, i8** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* %24, i32 %30)
br label %32
32: ; preds = %15
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %11
35: ; preds = %11
br label %36
36: ; preds = %39, %35
%37 = load i8*, i8** %4
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i8*, i8** %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %42, i8** %4
br label %36
43: ; preds = %36
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@__const.main.frutas = [23 x i8] c"banana,laranja,morango\00"
@.str = [2 x i8] c",\00"
@.str.1 = [3 x i8] c"\\0\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = zext i32 %3 to i64
br label %10
8: ; preds = %0
%9 = icmp eq i8* %4, null
br i1 %9, label %26, label %20
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %18, %10 ]
%12 = getelementptr inbounds i8, i8* %4, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i8 %13, 0
%16 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %16, i32 %14)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %10
20: ; preds = %10, %8
br label %21
21: ; preds = %20, %21
%22 = phi i8* [ %24, %21 ], [ %4, %20 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %21
26: ; preds = %21, %8
ret i32 0
}