#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 uint32_t;

/* Variables and functions */
int htonf(float);
float ntohf(int);
int /*<<< orphan*/ printf(char *, float);
int main(void) {
  float f = 3.1415926, f2;
  uint32_t netf;
  netf = htonf(f);
  f2 = ntohf(netf);
  printf("Original: %f\n", f);
  printf(" Network: 0x%08X\n", netf);
  printf("Unpacked: %f\n", f2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xeb9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <htonf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <ntohf@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movss  0xec3(%rip),%xmm0
call   1040 <htonf@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <ntohf@plt>
movss  %xmm0,0xc(%rsp)
lea    0xeac(%rip),%rdi
movss  0xea0(%rip),%xmm0
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Original: %f\0A\00"
@.str.1 = [18 x i8] c" Network: 0x%08X\0A\00"
@.str.2 = [14 x i8] c"Unpacked: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store i32 0, i32* %1
store float 0x400921FB40000000, float* %2
%5 = load float, float* %2
%6 = call i32 @htonf(float %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = call float @ntohf(i32 %7)
store float %8, float* %3
%9 = load float, float* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %9)
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to float
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), float %12)
%14 = load float, float* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), float %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Original: %f\0A\00"
@.str.1 = [18 x i8] c" Network: 0x%08X\0A\00"
@.str.2 = [14 x i8] c"Unpacked: %f\0A\00"
define i32 @main() {
%1 = tail call i32 @htonf(float 0x400921FB40000000)
%2 = tail call float @ntohf(i32 %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float 0x400921FB40000000)
%4 = sitofp i32 %1 to float
%5 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), float %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), float %2)
ret i32 0
}