#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);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *ingregarNombre() {
  char *nombre;
  char buffer[50];
  int largo;
  printf(" \n Ingrese el nombre \n ");
  scanf("%s", buffer);
  largo = strlen(buffer);
  nombre = (char *)malloc(largo * sizeof(char));
  strcpy(nombre, buffer);
  return nombre;
}


x86 assembly (clang, -O0):
<ingregarNombre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ingregarNombre>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c" \0A Ingrese el nombre \0A \00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @ingregarNombre() {
%1 = alloca i8*
%2 = alloca [50 x i8]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %1
%15 = load i8*, i8** %1
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %1
ret i8* %18
}

LLVM IR (-O2):
@.str = [24 x i8] c" \0A Ingrese el nombre \0A \00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @ingregarNombre() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = call i32 @strcpy(i8* %7, i8* %2)
ret i8* %7
}