#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float);
int /*<<< orphan*/ fwrite(long *, int, int, int /*<<< orphan*/ *);
long htonl(long);
int fputnf(FILE *file, int count, float *v, int binary) {
  register int i;
  long w;
  if (binary) {
    for (i = 0; i < count; i++) {
      w = htonl(*(long *)&v[i]);
      fwrite(&w, sizeof(float), 1, file);
    }
    return count;
  }
  fprintf(file, "%g", v[0]);
  for (i = 1; i < count; i++)
    fprintf(file, " %g", v[i]);
  return count;
}


x86 assembly (clang, -O0):
<fputnf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11a8 <fputnf+0x78>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119d <fputnf+0x6d>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%rdi
call   1030 <htonl@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1157 <fputnf+0x27>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1204 <fputnf+0xd4>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
lea    0xe46(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fe <fputnf+0xce>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe15(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c7 <fputnf+0x97>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputnf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdi,%r13
test   %ecx,%ecx
je     118d <fputnf+0x5d>
test   %r14d,%r14d
jle    11da <fputnf+0xaa>
mov    %r14d,%ebx
xor    %ebp,%ebp
mov    %rsp,%r15
nopl   0x0(%rax)
mov    (%r12,%rbp,4),%rdi
call   1030 <htonl@plt>
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fwrite@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <fputnf+0x30>
jmp    11da <fputnf+0xaa>
movss  (%r12),%xmm0
lea    0xe67(%rip),%rsi
mov    %r13,%rdi
call   1040 <fprintf@plt>
cmp    $0x2,%r14d
jl     11da <fputnf+0xaa>
mov    %r14d,%ebx
mov    $0x1,%ebp
lea    0xe49(%rip),%r15
nopw   0x0(%rax,%rax,1)
movss  (%r12,%rbp,4),%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11c0 <fputnf+0x90>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%g\00"
@.str.1 = [4 x i8] c" %g\00"
define i32 @fputnf(i32* %0, i32 %1, float* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i32* %0, i32** %6
store i32 %1, i32* %7
store float* %2, float** %8
store i32 %3, i32* %9
%12 = load i32, i32* %9
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %4
store i32 0, i32* %10
br label %15
15: ; preds = %29, %14
%16 = load i32, i32* %10
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load float*, float** %8
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
%24 = bitcast float* %23 to i64*
%25 = load i64, i64* %24
%26 = call i64 @htonl(i64 %25)
store i64 %26, i64* %11
%27 = load i32*, i32** %6
%28 = call i32 @fwrite(i64* %11, i32 4, i32 1, i32* %27)
br label %29
29: ; preds = %19
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %15
32: ; preds = %15
%33 = load i32, i32* %7
store i32 %33, i32* %5
br label %57
34: ; preds = %4
%35 = load i32*, i32** %6
%36 = load float*, float** %8
%37 = getelementptr inbounds float, float* %36, i64 0
%38 = load float, float* %37
%39 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %38)
store i32 1, i32* %10
br label %40
40: ; preds = %52, %34
%41 = load i32, i32* %10
%42 = load i32, i32* %7
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %55
44: ; preds = %40
%45 = load i32*, i32** %6
%46 = load float*, float** %8
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
%50 = load float, float* %49
%51 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %50)
br label %52
52: ; preds = %44
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %40
55: ; preds = %40
%56 = load i32, i32* %7
store i32 %56, i32* %5
br label %57
57: ; preds = %55, %32
%58 = load i32, i32* %5
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"%g\00"
@.str.1 = [4 x i8] c" %g\00"
define i32 @fputnf(i32* nocapture %0, i32 returned %1, float* nocapture %2, i32 %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = icmp eq i32 %3, 0
br i1 %7, label %21, label %8
8: ; preds = %4
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %34
10: ; preds = %8
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %19, %12 ]
%14 = getelementptr inbounds float, float* %2, i64 %13
%15 = bitcast float* %14 to i64*
%16 = load i64, i64* %15
%17 = tail call i64 @htonl(i64 %16)
store i64 %17, i64* %5
%18 = call i32 @fwrite(i64* %5, i32 4, i32 1, i32* %0)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %34, label %12
21: ; preds = %4
%22 = load float, float* %2
%23 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %22)
%24 = icmp sgt i32 %1, 1
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = zext i32 %1 to i64
br label %27
27: ; preds = %25, %27
%28 = phi i64 [ 1, %25 ], [ %32, %27 ]
%29 = getelementptr inbounds float, float* %2, i64 %28
%30 = load float, float* %29
%31 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %30)
%32 = add nuw nsw i64 %28, 1
%33 = icmp eq i64 %32, %26
br i1 %33, label %34, label %27
34: ; preds = %12, %27, %8, %21
ret i32 %1
}