#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*/ ConvertFromFloat(float, unsigned char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int i;
  float val;
  unsigned char buf[4];
  val = 0.3;
  ConvertFromFloat(val, buf);
  fprintf(stdout, "val=%g\n", val);
  fprintf(stdout, "buf=");
  for (i = 0; i < 4; i++)
    fprintf(stdout, "%.2x", buf[i]);
  fprintf(stdout, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
lea    -0x1c(%rbp),%rdi
call   1040 <ConvertFromFloat@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9a(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11c7 <main+0xa7>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rax
movzbl -0x1c(%rbp,%rax,1),%edx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x6f>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movss  0xed4(%rip),%xmm0
lea    0x4(%rsp),%rdi
call   1040 <ConvertFromFloat@plt>
mov    0x2ea3(%rip),%rbx
mov    (%rbx),%edi
lea    0xeca(%rip),%rsi
movsd  0xeba(%rip),%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeba(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x4(%rsp),%edx
lea    0xeaa(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x5(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x6(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x7(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe5d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [8 x i8] c"val=%g\0A\00"
@.str.1 = [5 x i8] c"buf=\00"
@.str.2 = [5 x i8] c"%.2x\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float
%8 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0x3FD3333340000000, float* %7
%9 = load float, float* %7
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%11 = call i32 @ConvertFromFloat(float %9, i8* %10)
%12 = load i32, i32* @stdout
%13 = load float, float* %7
%14 = fpext float %13 to double
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %14)
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %18
18: ; preds = %29, %2
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i32, i32* @stdout
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %18
32: ; preds = %18
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [8 x i8] c"val=%g\0A\00"
@.str.1 = [5 x i8] c"buf=\00"
@.str.2 = [5 x i8] c"%.2x\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = call i32 @ConvertFromFloat(float 0x3FD3333340000000, i8* %4)
%6 = load i32, i32* @stdout
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x3FD3333340000000)
%8 = load i32, i32* @stdout
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = load i8, i8* %4
%12 = zext i8 %11 to i32
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stdout
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @stdout
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}