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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ flip4(unsigned int const *, unsigned int *, size_t);
int /*<<< orphan*/ stderr;
int write(int, float const *, int);
ssize_t write_float4_array(int f, const float *x, size_t n) {
  ssize_t nwritten;
  fflush(stderr);
  flip4((const unsigned int *)x, (unsigned int *)x, n);
  nwritten = write(f, x, 4 * n);
  flip4((const unsigned int *)x, (unsigned int *)x, n);
  if (nwritten <= 0)
    return 0;
  else
    return nwritten / 4;
}


x86 assembly (clang, -O0):
<write_float4_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <flip4@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <flip4@plt>
cmpl   $0x0,-0x1c(%rbp)
jg     11a2 <write_float4_array+0x72>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <write_float4_array+0x80>
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_float4_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <flip4@plt>
lea    0x0(,%r14,4),%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <write@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <flip4@plt>
test   %r15d,%r15d
jle    1193 <write_float4_array+0x63>
lea    0x3(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
sar    $0x2,%eax
jmp    1195 <write_float4_array+0x65>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
define i32 @write_float4_array(i32 %0, float* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %5
store float* %1, float** %6
store i64 %2, i64* %7
%9 = load i32, i32* @stderr
%10 = call i32 @fflush(i32 %9)
%11 = load float*, float** %6
%12 = bitcast float* %11 to i32*
%13 = load float*, float** %6
%14 = bitcast float* %13 to i32*
%15 = load i64, i64* %7
%16 = call i32 @flip4(i32* %12, i32* %14, i64 %15)
%17 = load i32, i32* %5
%18 = load float*, float** %6
%19 = load i64, i64* %7
%20 = mul i64 4, %19
%21 = trunc i64 %20 to i32
%22 = call i32 @write(i32 %17, float* %18, i32 %21)
store i32 %22, i32* %8
%23 = load float*, float** %6
%24 = bitcast float* %23 to i32*
%25 = load float*, float** %6
%26 = bitcast float* %25 to i32*
%27 = load i64, i64* %7
%28 = call i32 @flip4(i32* %24, i32* %26, i64 %27)
%29 = load i32, i32* %8
%30 = icmp sle i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %3
store i32 0, i32* %4
br label %35
32: ; preds = %3
%33 = load i32, i32* %8
%34 = sdiv i32 %33, 4
store i32 %34, i32* %4
br label %35
35: ; preds = %32, %31
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @write_float4_array(i32 %0, float* %1, i64 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 @fflush(i32 %4)
%6 = bitcast float* %1 to i32*
%7 = tail call i32 @flip4(i32* %6, i32* %6, i64 %2)
%8 = trunc i64 %2 to i32
%9 = shl i32 %8, 2
%10 = tail call i32 @write(i32 %0, float* %1, i32 %9)
%11 = tail call i32 @flip4(i32* %6, i32* %6, i64 %2)
%12 = sdiv i32 %10, 4
%13 = icmp sgt i32 %10, 0
%14 = select i1 %13, i32 %12, i32 0
ret i32 %14
}