#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*/ free(char **);
scalar_t__ malloc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ separaCadena(char *, char **);
int /*<<< orphan*/ strlen(char *);
int main() {
  int i = 0;
  char cadena[] = "Hola\nHoy es viernes\nAl año que viene nos mudamos\nTe "
                  "quiero\nEstoy loca\nNo se que mas escribir\n";
  char **obtenida = NULL;
  obtenida = (char **)malloc(strlen(cadena));
  if (obtenida == NULL) {
    printf("Error de memoria\n");
  } else {
    separaCadena(cadena, obtenida);
    while (obtenida[i] != NULL) {
      printf("%s\n", obtenida[i]);
      i++;
    }
    free(obtenida);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x5f,%edx
call   1060 <memcpy@plt>
movq   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11c8 <main+0x68>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1219 <main+0xb9>
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1070 <separaCadena@plt>
mov    -0x78(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1210 <main+0xb0>
mov    -0x78(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d5 <main+0x75>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
movups 0xef1(%rip),%xmm0
movups %xmm0,0x4f(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe66(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     11eb <main+0x9b>
mov    %rax,%r14
mov    %rsp,%rdi
mov    %rax,%rsi
call   1060 <separaCadena@plt>
mov    (%r14),%rdi
test   %rdi,%rdi
je     11e1 <main+0x91>
mov    %r14,%rbx
add    $0x8,%rbx
nop
call   1040 <puts@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    11d0 <main+0x80>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    11f7 <main+0xa7>
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.cadena = [95 x i8] c"Hola\0AHoy es viernes\0AAl a\C3\B1o que viene nos mudamos\0ATe quiero\0AEstoy loca\0ANo se que mas escribir\0A\00"
@.str = [18 x i8] c"Error de memoria\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [95 x i8]
%4 = alloca i8**
store i32 0, i32* %1
store i32 0, i32* %2
%5 = bitcast [95 x i8]* %3 to i8*
store i8** null, i8*** %4
%6 = getelementptr inbounds [95 x i8], [95 x i8]* %3, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8**
store i8** %9, i8*** %4
%10 = load i8**, i8*** %4
%11 = icmp eq i8** %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %37
14: ; preds = %0
%15 = getelementptr inbounds [95 x i8], [95 x i8]* %3, i64 0, i64 0
%16 = load i8**, i8*** %4
%17 = call i32 @separaCadena(i8* %15, i8** %16)
br label %18
18: ; preds = %25, %14
%19 = load i8**, i8*** %4
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %34
25: ; preds = %18
%26 = load i8**, i8*** %4
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %18
34: ; preds = %18
%35 = load i8**, i8*** %4
%36 = call i32 @free(i8** %35)
br label %37
37: ; preds = %34, %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.cadena = [95 x i8] c"Hola\0AHoy es viernes\0AAl a\C3\B1o que viene nos mudamos\0ATe quiero\0AEstoy loca\0ANo se que mas escribir\0A\00"
@str = [17 x i8] c"Error de memoria\00"
define i32 @main() {
%1 = alloca [95 x i8]
%2 = getelementptr inbounds [95 x i8], [95 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i8**
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %23
9: ; preds = %0
%10 = call i32 @separaCadena(i8* %2, i8** %5)
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %21, label %13
13: ; preds = %9, %13
%14 = phi i64 [ %17, %13 ], [ 0, %9 ]
%15 = phi i8* [ %19, %13 ], [ %11, %9 ]
%16 = call i32 @puts(i8* %15)
%17 = add nuw i64 %14, 1
%18 = getelementptr inbounds i8*, i8** %5, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %13
21: ; preds = %13, %9
%22 = call i32 @free(i8** %5)
br label %23
23: ; preds = %21, %7
ret i32 0
}