#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*/ flip4(unsigned int const *, unsigned int *, int);
int write(int, float const *, int);
int write_float4_array(int f, const float *x, int n) {
  int nwritten;
  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    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <flip4@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
shl    $0x2,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <flip4@plt>
cmpl   $0x0,-0x18(%rbp)
jg     117d <write_float4_array+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    118b <write_float4_array+0x6b>
mov    -0x18(%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    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
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    %r14d,%edx
call   1040 <flip4@plt>
test   %r15d,%r15d
jle    116f <write_float4_array+0x4f>
lea    0x3(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
sar    $0x2,%eax
jmp    1171 <write_float4_array+0x51>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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