#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*/ __fpurge(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove_carriage_return_from_string(char *);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *reader(char *message) {
  char *str = NULL;
  char *str_t = NULL;
  char aux[256];
  printf("%s: ", message);
  __fpurge(stdin);
  fgets(aux, 256 + 1, stdin);
  remove_carriage_return_from_string(aux);
  size_t str_lenght = strlen(aux);
  str = malloc(sizeof(char) * str_lenght);
  strncpy(str, aux, str_lenght);
  return str;
}


x86 assembly (clang, -O0):
<reader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1040 <__fpurge@plt>
lea    -0x120(%rbp),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    $0x101,%esi
call   1070 <fgets@plt>
lea    -0x120(%rbp),%rdi
call   1080 <remove_carriage_return_from_string@plt>
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x128(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reader>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rsi
lea    0xe7a(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e56(%rip),%rbx
mov    (%rbx),%edi
call   1040 <__fpurge@plt>
mov    (%rbx),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x101,%esi
call   1070 <fgets@plt>
mov    %r14,%rdi
call   1080 <remove_carriage_return_from_string@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %r15d,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <strncpy@plt>
mov    %rbx,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define i8* @reader(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i64
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
%7 = load i8*, i8** %2
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @stdin
%10 = call i32 @__fpurge(i32 %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 257, i32 %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @remove_carriage_return_from_string(i8* %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
store i64 %17, i64* %6
%18 = load i64, i64* %6
%19 = mul i64 1, %18
%20 = trunc i64 %19 to i32
%21 = call i8* @malloc(i32 %20)
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%24 = load i64, i64* %6
%25 = call i32 @strncpy(i8* %22, i8* %23, i64 %24)
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define i8* @reader(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdin
%6 = tail call i32 @__fpurge(i32 %5)
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 257, i32 %7)
%9 = call i32 @remove_carriage_return_from_string(i8* %3)
%10 = call i64 @strlen(i8* %3)
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
%13 = call i32 @strncpy(i8* %12, i8* %3, i64 %10)
ret i8* %12
}