#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ malloc(int);
int snprintf(char *, int, char *, float);
int /*<<< orphan*/ sprintf(char *, char *, float);
char *realToStr(uint32_t *env) {
  char dummy[1];
  float n = (float)*(float *)(env + 1);
  int siz = snprintf(dummy, sizeof dummy, "%f", n);
  char *s = (char *)malloc(siz * sizeof(char));
  sprintf(s, "%f", n);
  return s;
}


x86 assembly (clang, -O0):
<realToStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x9(%rbp),%rdi
movss  -0x10(%rbp),%xmm0
mov    $0x1,%esi
lea    0xea1(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
movss  -0x10(%rbp),%xmm0
lea    0xe76(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realToStr>:
push   %r14
push   %rbx
push   %rax
movss  0x4(%rdi),%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xeba(%rip),%r14
lea    0x3(%rsp),%rdi
mov    $0x1,%esi
mov    %r14,%rdx
call   1030 <snprintf@plt>
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
movss  0x4(%rsp),%xmm0
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
define i8* @realToStr(i32* %0) {
%2 = alloca i32*
%3 = alloca [1 x i8]
%4 = alloca float
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %2
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = bitcast i32* %8 to float*
%10 = load float, float* %9
store float %10, float* %4
%11 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%12 = load float, float* %4
%13 = call i32 @snprintf(i8* %11, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = load float, float* %4
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %21)
%23 = load i8*, i8** %6
ret i8* %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define i8* @realToStr(i32* nocapture %0) {
%2 = alloca [1 x i8]
%3 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = bitcast i32* %4 to float*
%6 = load float, float* %5
%7 = call i32 @snprintf(i8* %3, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %6)
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %6)
ret i8* %9
}