#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 GLuint;
typedef int GLubyte;
typedef double GLfloat;
typedef int /*<<< orphan*/ GLdouble;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
GLdouble extractFloat(int isSwap, const void *item) {
  GLfloat ffloat;
  if (isSwap) {
    ffloat = (GLuint)(((GLuint)((const GLubyte *)(item))[3]) << 24 |
                      ((GLuint)((const GLubyte *)(item))[2]) << 16 |
                      ((GLuint)((const GLubyte *)(item))[1]) << 8 |
                      ((const GLubyte *)(item))[0]);
  } else {
    ffloat = *(const GLfloat *)item;
  }
  assert(ffloat <= 1.0);
  return (GLdouble)ffloat;
}


x86 assembly (clang, -O0):
<extractFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     115f <extractFloat+0x4f>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
shl    $0x18,%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
or     (%rcx),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    116c <extractFloat+0x5c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8c(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cvttsd2si -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractFloat>:
push   %rax
test   %edi,%edi
je     1133 <extractFloat+0x23>
mov    0xc(%rsi),%eax
shl    $0x18,%eax
mov    0x4(%rsi),%ecx
mov    0x8(%rsi),%edx
shl    $0x10,%edx
or     %eax,%edx
shl    $0x8,%ecx
or     %edx,%ecx
or     (%rsi),%ecx
cvtsi2sd %ecx,%xmm1
jmp    1137 <extractFloat+0x27>
movsd  (%rsi),%xmm1
movsd  %xmm1,(%rsp)
movsd  0xebc(%rip),%xmm0
xor    %edi,%edi
ucomisd %xmm1,%xmm0
setae  %dil
call   1030 <assert@plt>
cvttsd2si (%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @extractFloat(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %32
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
%11 = getelementptr inbounds i32, i32* %10, i64 3
%12 = load i32, i32* %11
%13 = shl i32 %12, 24
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to i32*
%16 = getelementptr inbounds i32, i32* %15, i64 2
%17 = load i32, i32* %16
%18 = shl i32 %17, 16
%19 = or i32 %13, %18
%20 = load i8*, i8** %4
%21 = bitcast i8* %20 to i32*
%22 = getelementptr inbounds i32, i32* %21, i64 1
%23 = load i32, i32* %22
%24 = shl i32 %23, 8
%25 = or i32 %19, %24
%26 = load i8*, i8** %4
%27 = bitcast i8* %26 to i32*
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
%30 = or i32 %25, %29
%31 = sitofp i32 %30 to double
store double %31, double* %5
br label %36
32: ; preds = %2
%33 = load i8*, i8** %4
%34 = bitcast i8* %33 to double*
%35 = load double, double* %34
store double %35, double* %5
br label %36
36: ; preds = %32, %8
%37 = load double, double* %5
%38 = fcmp ole double %37, 1.000000e+00
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load double, double* %5
%42 = fptosi double %41 to i32
ret i32 %42
}

LLVM IR (-O2):
define i32 @extractFloat(i32 %0, i8* nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = bitcast i8* %1 to i32*
%6 = getelementptr inbounds i8, i8* %1, i64 12
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
%9 = shl i32 %8, 24
%10 = getelementptr inbounds i8, i8* %1, i64 8
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = shl i32 %12, 16
%14 = or i32 %13, %9
%15 = getelementptr inbounds i8, i8* %1, i64 4
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = shl i32 %17, 8
%19 = or i32 %14, %18
%20 = load i32, i32* %5
%21 = or i32 %19, %20
%22 = sitofp i32 %21 to double
br label %26
23: ; preds = %2
%24 = bitcast i8* %1 to double*
%25 = load double, double* %24
br label %26
26: ; preds = %23, %4
%27 = phi double [ %22, %4 ], [ %25, %23 ]
%28 = fcmp ole double %27, 1.000000e+00
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = fptosi double %27 to i32
ret i32 %31
}