#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*/ flip4(unsigned int const *, unsigned int *, int);
int read(int, float *, int);
ssize_t read_float4_array(int f, float *x, size_t n) {
  ssize_t nread = read(f, x, 4 * n);
  if (nread <= 0)
    return 0;
  flip4((const unsigned int *)x, (unsigned int *)x, nread / 4);
  return nread / 4;
}


x86 assembly (clang, -O0):
<read_float4_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1030 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1162 <read_float4_array+0x42>
movl   $0x0,-0x4(%rbp)
jmp    118a <read_float4_array+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1040 <flip4@plt>
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):
<read_float4_array>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
shl    $0x2,%edx
call   1030 <read@plt>
test   %eax,%eax
jle    1146 <read_float4_array+0x26>
mov    %eax,%ebp
shr    $0x2,%ebp
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <flip4@plt>
jmp    1148 <read_float4_array+0x28>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_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* %5
%10 = load float*, float** %6
%11 = load i64, i64* %7
%12 = mul i64 4, %11
%13 = trunc i64 %12 to i32
%14 = call i32 @read(i32 %9, float* %10, i32 %13)
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %28
18: ; preds = %3
%19 = load float*, float** %6
%20 = bitcast float* %19 to i32*
%21 = load float*, float** %6
%22 = bitcast float* %21 to i32*
%23 = load i32, i32* %8
%24 = sdiv i32 %23, 4
%25 = call i32 @flip4(i32* %20, i32* %22, i32 %24)
%26 = load i32, i32* %8
%27 = sdiv i32 %26, 4
store i32 %27, i32* %4
br label %28
28: ; preds = %18, %17
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @read_float4_array(i32 %0, float* %1, i64 %2) {
%4 = trunc i64 %2 to i32
%5 = shl i32 %4, 2
%6 = tail call i32 @read(i32 %0, float* %1, i32 %5)
%7 = icmp slt i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = bitcast float* %1 to i32*
%10 = lshr i32 %6, 2
%11 = tail call i32 @flip4(i32* %9, i32* %9, i32 %10)
br label %12
12: ; preds = %3, %8
%13 = phi i32 [ %10, %8 ], [ 0, %3 ]
ret i32 %13
}