#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 absolute(int);
float packFloat(int exponent, int magnitude) {
  if (magnitude == 0)
    return 0;
  int res = ((magnitude < 0) ? 1 : 0) << 31;
  res |= ((exponent + 127) << 23) & 0x7F800000;
  res |= absolute(magnitude) & 0x007FFFFF;
  return *((float *)((void *)&res));
}


x86 assembly (clang, -O0):
<packFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1135 <packFloat+0x25>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    117c <packFloat+0x6c>
mov    -0xc(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
shl    $0x1f,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x7f,%eax
shl    $0x17,%eax
and    $0x7f800000,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <absolute@plt>
and    $0x7fffff,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<packFloat>:
test   %esi,%esi
je     1143 <packFloat+0x33>
push   %rbx
mov    %edi,%ebx
mov    %esi,%eax
and    $0x80000000,%eax
shl    $0x17,%ebx
add    $0x3f800000,%ebx
and    $0x7f800000,%ebx
or     %eax,%ebx
mov    %esi,%edi
call   1030 <absolute@plt>
and    $0x7fffff,%eax
or     %ebx,%eax
movd   %eax,%xmm0
pop    %rbx
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @packFloat(i32 %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store float 0.000000e+00, float* %3
br label %30
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 1, i32 0
%15 = shl i32 %14, 31
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 127
%18 = shl i32 %17, 23
%19 = and i32 %18, 2139095040
%20 = load i32, i32* %6
%21 = or i32 %20, %19
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = call i32 @absolute(i32 %22)
%24 = and i32 %23, 8388607
%25 = load i32, i32* %6
%26 = or i32 %25, %24
store i32 %26, i32* %6
%27 = bitcast i32* %6 to i8*
%28 = bitcast i8* %27 to float*
%29 = load float, float* %28
store float %29, float* %3
br label %30
30: ; preds = %10, %9
%31 = load float, float* %3
ret float %31
}

LLVM IR (-O2):
define float @packFloat(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = and i32 %1, -2147483648
%6 = shl i32 %0, 23
%7 = add i32 %6, 1065353216
%8 = and i32 %7, 2139095040
%9 = or i32 %8, %5
%10 = tail call i32 @absolute(i32 %1)
%11 = and i32 %10, 8388607
%12 = or i32 %9, %11
%13 = bitcast i32 %12 to float
br label %14
14: ; preds = %2, %4
%15 = phi float [ %13, %4 ], [ 0.000000e+00, %2 ]
ret float %15
}