#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*/ assert(int);
float real2float(char *);
float unpack_float(const char *target, int swap_endian, int format_code) {
  const char *decode;
  char buffer[4];
  float data;
  int i;
  assert(format_code == 1 || format_code == 5);
  if (swap_endian) {
    for (i = 0; i < 4; i++)
      buffer[i] = target[3 - i];
    decode = buffer;
  } else {
    decode = target;
  }
  if (format_code == 1) {
    data = real2float(buffer);
  } else {
    data = *(float *)(buffer);
  }
  return data;
}


x86 assembly (clang, -O0):
<unpack_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x25(%rbp)
je     114b <unpack_float+0x2b>
cmpl   $0x5,-0x10(%rbp)
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a8 <unpack_float+0x88>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    119b <unpack_float+0x7b>
mov    -0x8(%rbp),%rax
mov    $0x3,%ecx
sub    -0x24(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x1c(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1169 <unpack_float+0x49>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <unpack_float+0x90>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11cd <unpack_float+0xad>
lea    -0x1c(%rbp),%rdi
call   1030 <real2float@plt>
movss  %xmm0,-0x20(%rbp)
jmp    11d7 <unpack_float+0xb7>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack_float>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%eax
and    $0xfffffffb,%eax
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
test   %r14d,%r14d
je     1163 <unpack_float+0x43>
mov    0x3(%rbx),%al
mov    %al,0xc(%rsp)
mov    0x2(%rbx),%al
mov    %al,0xd(%rsp)
mov    0x1(%rbx),%al
mov    %al,0xe(%rsp)
mov    (%rbx),%al
mov    %al,0xf(%rsp)
cmp    $0x1,%ebp
jne    1174 <unpack_float+0x54>
lea    0xc(%rsp),%rdi
call   1030 <real2float@plt>
jmp    117a <unpack_float+0x5a>
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define float @unpack_float(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca float
%5 = bitcast float* %4 to [4 x i8]*
%6 = bitcast float* %4 to i8*
%7 = icmp eq i32 %2, 1
%8 = and i32 %2, -5
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp eq i32 %1, 0
br i1 %12, label %25, label %13
13: ; preds = %3
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = bitcast float* %4 to i8*
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 1
%21 = load i8, i8* %20
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %21, i8* %22
%23 = load i8, i8* %0
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %23, i8* %24
br label %25
25: ; preds = %13, %3
br i1 %7, label %26, label %28
26: ; preds = %25
%27 = call float @real2float(i8* %6)
br label %30
28: ; preds = %25
%29 = load float, float* %4
br label %30
30: ; preds = %28, %26
%31 = phi float [ %27, %26 ], [ %29, %28 ]
ret float %31
}