#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 */
double frexp(double, int *);
unsigned long ldexp(double, int);
void makeaiffsamprate(double sr, unsigned char *shit) {
  int exponent;
  double mantissa = frexp(sr, &exponent);
  unsigned long fixmantissa = ldexp(mantissa, 32);
  shit[0] = (exponent + 16382) >> 8;
  shit[1] = exponent + 16382;
  shit[2] = fixmantissa >> 24;
  shit[3] = fixmantissa >> 16;
  shit[4] = fixmantissa >> 8;
  shit[5] = fixmantissa;
  shit[6] = shit[7] = shit[8] = shit[9] = 0;
}


x86 assembly (clang, -O0):
<makeaiffsamprate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1040 <frexp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x20,%edi
call   1030 <ldexp@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x3ffe,%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x3ffe,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
shr    $0x18,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%rax
shr    $0x10,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rax
shr    $0x8,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x7(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x6(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeaiffsamprate>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
call   1040 <frexp@plt>
mov    $0x20,%edi
call   1030 <ldexp@plt>
mov    0xc(%rsp),%ecx
lea    0x3ffe(%rcx),%edx
mov    %dh,(%rbx)
add    $0xfe,%cl
mov    %cl,0x1(%rbx)
mov    %rax,%rcx
shr    $0x18,%rcx
mov    %cl,0x2(%rbx)
mov    %rax,%rcx
shr    $0x10,%rcx
mov    %cl,0x3(%rbx)
mov    %ah,0x4(%rbx)
mov    %al,0x5(%rbx)
movl   $0x0,0x6(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @makeaiffsamprate(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double
%7 = alloca i64
store double %0, double* %3
store i8* %1, i8** %4
%8 = load double, double* %3
%9 = call double @frexp(double %8, i32* %5)
store double %9, double* %6
%10 = load double, double* %6
%11 = call i64 @ldexp(double %10, i32 32)
store i64 %11, i64* %7
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 16382
%14 = ashr i32 %13, 8
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 %15, i8* %17
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 16382
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %20, i8* %22
%23 = load i64, i64* %7
%24 = lshr i64 %23, 24
%25 = trunc i64 %24 to i8
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8 %25, i8* %27
%28 = load i64, i64* %7
%29 = lshr i64 %28, 16
%30 = trunc i64 %29 to i8
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 3
store i8 %30, i8* %32
%33 = load i64, i64* %7
%34 = lshr i64 %33, 8
%35 = trunc i64 %34 to i8
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 4
store i8 %35, i8* %37
%38 = load i64, i64* %7
%39 = trunc i64 %38 to i8
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 5
store i8 %39, i8* %41
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i64 9
store i8 0, i8* %43
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 8
store i8 0, i8* %45
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 7
store i8 0, i8* %47
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 6
store i8 0, i8* %49
ret void
}

LLVM IR (-O2):
define void @makeaiffsamprate(double %0, i8* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call double @frexp(double %0, i32* %3)
%6 = tail call i64 @ldexp(double %5, i32 32)
%7 = load i32, i32* %3
%8 = add nsw i32 %7, 16382
%9 = lshr i32 %8, 8
%10 = trunc i32 %9 to i8
store i8 %10, i8* %1
%11 = trunc i32 %7 to i8
%12 = add i8 %11, -2
%13 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %12, i8* %13
%14 = lshr i64 %6, 24
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %15, i8* %16
%17 = lshr i64 %6, 16
%18 = trunc i64 %17 to i8
%19 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %18, i8* %19
%20 = lshr i64 %6, 8
%21 = trunc i64 %20 to i8
%22 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %21, i8* %22
%23 = trunc i64 %6 to i8
%24 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %23, i8* %24
%25 = getelementptr inbounds i8, i8* %1, i64 6
%26 = bitcast i8* %25 to i32*
store i32 0, i32* %26
ret void
}