#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 */
struct string {
  int dummy;
};

/* Variables and functions */
struct string *create_string_copy(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int snprintf(char *, int, char *, float);
struct string *_prim_float_string(float p1) {
  char buffer[256];
  int len = snprintf(buffer, 256, "%.13g", p1);
  if (len >= 0 && len < 256) {
    return create_string_copy(buffer);
  } else {
    printf("_prim_float_string\n");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<_prim_float_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movss  %xmm0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
movss  -0x4(%rbp),%xmm0
mov    $0x100,%esi
lea    0xe98(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jl     11a5 <_prim_float_string+0x65>
cmpl   $0x100,-0x114(%rbp)
jge    11a5 <_prim_float_string+0x65>
lea    -0x110(%rbp),%rdi
call   1050 <create_string_copy@plt>
add    $0x120,%rsp
pop    %rbp
ret
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<_prim_float_string>:
sub    $0x108,%rsp
lea    0xeb2(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <snprintf@plt>
cmp    $0xff,%eax
ja     1172 <_prim_float_string+0x32>
mov    %rsp,%rdi
call   1050 <create_string_copy@plt>
add    $0x108,%rsp
ret
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.string = type { i32 }
@.str = [6 x i8] c"%.13g\00"
@.str.1 = [20 x i8] c"_prim_float_string\0A\00"
define %struct.string* @_prim_float_string(float %0) {
%2 = alloca float
%3 = alloca [256 x i8]
%4 = alloca i32
store float %0, float* %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = load float, float* %2
%7 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 256
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = call %struct.string* @create_string_copy(i8* %14)
ret %struct.string* %15
16: ; preds = %10, %1
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
%struct.string = type { i32 }
@.str = [6 x i8] c"%.13g\00"
@str = [19 x i8] c"_prim_float_string\00"
define %struct.string* @_prim_float_string(float %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float %0)
%5 = icmp ult i32 %4, 256
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call %struct.string* @create_string_copy(i8* %3)
ret %struct.string* %7
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
}