#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*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
char *fn_ret_char_ptr(int i, double f, char c, char *s) {
  printf("%d\n", i);
  printf("%lf\n", f);
  printf("%c\n", c);
  printf("%s\n", s);
  char *ret = (char *)malloc(10 * sizeof(char));
  memset(ret, 'a', 10);
  ret[10] = '\0';
  return ret;
}


x86 assembly (clang, -O0):
<fn_ret_char_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsbl -0x11(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x61,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,0xa(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn_ret_char_ptr>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
movsd  %xmm0,(%rsp)
mov    %edi,%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x61,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
movb   $0x0,0xa(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
@.str.2 = [4 x i8] c"%c\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i8* @fn_ret_char_ptr(i32 %0, double %1, i8 signext %2, i8* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %5
store double %1, double* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%10 = load i32, i32* %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load double, double* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = load i8, i8* %7
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i64 @malloc(i32 10)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = call i32 @memset(i8* %21, i8 signext 97, i32 10)
%23 = load i8*, i8** %9
%24 = getelementptr inbounds i8, i8* %23, i64 10
store i8 0, i8* %24
%25 = load i8*, i8** %9
ret i8* %25
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
@.str.2 = [4 x i8] c"%c\0A\00"
define i8* @fn_ret_char_ptr(i32 %0, double %1, i8 signext %2, i8* nocapture %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %1)
%7 = sext i8 %2 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) %3)
%10 = tail call i64 @malloc(i32 10)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @memset(i8* %11, i8 signext 97, i32 10)
%13 = getelementptr inbounds i8, i8* %11, i64 10
store i8 0, i8* %13
ret i8* %11
}