#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void caracteres() {
  char texto1[40], texto2[40], texto3[40];
  printf("Introduce una frase: ");
  gets(texto1);
  strcpy(texto2, texto1);
  printf("Una copia de tu texto: %s\n", texto2);
  strncpy(texto3, texto1, 4);
  printf("Y sus 4 primeras letras son: %s\n", texto3);
}


x86 assembly (clang, -O0):
<caracteres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x60(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<caracteres>:
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x60(%rsp),%r14
mov    %r14,%rdi
call   1060 <gets@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe9a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Introduce una frase: \00"
@.str.1 = [27 x i8] c"Una copia de tu texto: %s\0A\00"
@.str.2 = [33 x i8] c"Y sus 4 primeras letras son: %s\0A\00"
define void @caracteres() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 4)
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Introduce una frase: \00"
@.str.1 = [27 x i8] c"Una copia de tu texto: %s\0A\00"
@.str.2 = [33 x i8] c"Y sus 4 primeras letras son: %s\0A\00"
define void @caracteres() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strcpy(i8* %5, i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = call i32 @strncpy(i8* %6, i8* %4, i32 4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %6)
ret void
}