#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__ malloc(int);
char *obtenNombreArchivo(char *texto) {
  char *nombre = (char *)malloc(sizeof(char) * 16384);
  int indiceSiguienteNombre = 0;
  int i = 4;
  while (texto[i] != ' ') {
    nombre[indiceSiguienteNombre] = texto[i];
    i++;
    indiceSiguienteNombre++;
  }
  nombre[indiceSiguienteNombre + 1] = '\0';
  return nombre;
}


x86 assembly (clang, -O0):
<obtenNombreArchivo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x4000,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     117a <obtenNombreArchivo+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <obtenNombreArchivo+0x28>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obtenNombreArchivo>:
push   %rbx
mov    %rdi,%rbx
mov    $0x4000,%edi
call   1030 <malloc@plt>
mov    0x4(%rbx),%dl
mov    $0x1,%ecx
cmp    $0x20,%dl
je     1144 <obtenNombreArchivo+0x34>
xor    %ecx,%ecx
nopl   (%rax)
mov    %dl,(%rax,%rcx,1)
movzbl 0x5(%rbx,%rcx,1),%edx
add    $0x1,%rcx
cmp    $0x20,%dl
jne    1130 <obtenNombreArchivo+0x20>
add    $0x1,%ecx
movb   $0x0,(%rax,%rcx,1)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @obtenNombreArchivo(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i64 @malloc(i32 16384)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
store i32 0, i32* %4
store i32 4, i32* %5
br label %8
8: ; preds = %16, %1
%9 = load i8*, i8** %2
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 32
br i1 %15, label %16, label %30
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %8
30: ; preds = %8
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 0, i8* %35
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @obtenNombreArchivo(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 16384)
%3 = inttoptr i64 %2 to i8*
%4 = getelementptr inbounds i8, i8* %0, i64 4
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 32
br i1 %6, label %20, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %13, %7 ], [ 0, %1 ]
%9 = phi i64 [ %12, %7 ], [ 4, %1 ]
%10 = phi i8 [ %15, %7 ], [ %5, %1 ]
%11 = getelementptr inbounds i8, i8* %3, i64 %8
store i8 %10, i8* %11
%12 = add nuw nsw i64 %9, 1
%13 = add nuw i64 %8, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 32
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = add i64 %8, 2
%19 = and i64 %18, 4294967295
br label %20
20: ; preds = %17, %1
%21 = phi i64 [ 1, %1 ], [ %19, %17 ]
%22 = getelementptr inbounds i8, i8* %3, i64 %21
store i8 0, i8* %22
ret i8* %3
}