#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*/ EXIT_FAILURE;
int INT64_C(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
void var_scale(int datatype, double *mscale, double *mrscale) {
  int mant_bits;
  switch (datatype) {
  case 8:
    mant_bits = 7;
    break;
  case 16:
    mant_bits = 15;
    break;
  case 24:
    mant_bits = 23;
    break;
  case 132:
    mant_bits = 24;
    break;
  case 164:
    mant_bits = 53;
    break;
  case 208:
  case 216:
  case 232:
  default:
    fprintf(stderr, "Unexpected or unusable content format: %d\n", datatype);
    exit(EXIT_FAILURE);
  }
  *mscale = (double)(INT64_C(1) << mant_bits);
  *mrscale = 1.0 / *mscale;
}


x86 assembly (clang, -O0):
<var_scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x8,%eax
je     11d8 <var_scale+0xa8>
jmp    1157 <var_scale+0x27>
mov    -0x20(%rbp),%eax
sub    $0x10,%eax
je     11e4 <var_scale+0xb4>
jmp    1168 <var_scale+0x38>
mov    -0x20(%rbp),%eax
sub    $0x18,%eax
je     11f0 <var_scale+0xc0>
jmp    1179 <var_scale+0x49>
mov    -0x20(%rbp),%eax
sub    $0x84,%eax
je     11fc <var_scale+0xcc>
jmp    118c <var_scale+0x5c>
mov    -0x20(%rbp),%eax
sub    $0xa4,%eax
je     1208 <var_scale+0xd8>
jmp    119f <var_scale+0x6f>
mov    -0x20(%rbp),%eax
sub    $0xd0,%eax
je     1214 <var_scale+0xe4>
jmp    11b2 <var_scale+0x82>
mov    -0x20(%rbp),%eax
sub    $0xd8,%eax
je     1214 <var_scale+0xe4>
jmp    11c5 <var_scale+0x95>
mov    -0x20(%rbp),%eax
sub    $0xe8,%eax
je     1214 <var_scale+0xe4>
jmp    1219 <var_scale+0xe9>
movl   $0x7,-0x1c(%rbp)
jmp    123f <var_scale+0x10f>
movl   $0xf,-0x1c(%rbp)
jmp    123f <var_scale+0x10f>
movl   $0x17,-0x1c(%rbp)
jmp    123f <var_scale+0x10f>
movl   $0x18,-0x1c(%rbp)
jmp    123f <var_scale+0x10f>
movl   $0x35,-0x1c(%rbp)
jmp    123f <var_scale+0x10f>
jmp    1219 <var_scale+0xe9>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xddc(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    $0x1,%edi
call   1030 <INT64_C@plt>
mov    -0x1c(%rbp),%ecx
shl    %cl,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd9a(%rip),%xmm0
divsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<var_scale>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%edx
cmp    $0x17,%edi
jle    115d <var_scale+0x2d>
cmp    $0x18,%edx
je     1173 <var_scale+0x43>
cmp    $0x84,%edx
je     117a <var_scale+0x4a>
cmp    $0xa4,%edx
jne    11ab <var_scale+0x7b>
mov    $0x35,%ebp
jmp    117f <var_scale+0x4f>
mov    $0x7,%ebp
cmp    $0x8,%edx
je     117f <var_scale+0x4f>
cmp    $0x10,%edx
jne    11ab <var_scale+0x7b>
mov    $0xf,%ebp
jmp    117f <var_scale+0x4f>
mov    $0x17,%ebp
jmp    117f <var_scale+0x4f>
mov    $0x18,%ebp
mov    $0x1,%edi
call   1030 <INT64_C@plt>
mov    %ebp,%ecx
shl    %cl,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rbx)
movsd  0xe63(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Unexpected or unusable content format: %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @var_scale(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load i32, i32* %4
switch i32 %8, label %15 [
i32 8, label %9
i32 16, label %10
i32 24, label %11
i32 132, label %12
i32 164, label %13
i32 208, label %14
i32 216, label %14
i32 232, label %14
]
9: ; preds = %3
store i32 7, i32* %7
br label %21
10: ; preds = %3
store i32 15, i32* %7
br label %21
11: ; preds = %3
store i32 23, i32* %7
br label %21
12: ; preds = %3
store i32 24, i32* %7
br label %21
13: ; preds = %3
store i32 53, i32* %7
br label %21
14: ; preds = %3, %3, %3
br label %15
15: ; preds = %3, %14
%16 = load i32, i32* @stderr
%17 = load i32, i32* %4
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %13, %12, %11, %10, %9
%22 = call i32 @INT64_C(i32 1)
%23 = load i32, i32* %7
%24 = shl i32 %22, %23
%25 = sitofp i32 %24 to double
%26 = load double*, double** %5
store double %25, double* %26
%27 = load double*, double** %5
%28 = load double, double* %27
%29 = fdiv double 1.000000e+00, %28
%30 = load double*, double** %6
store double %29, double* %30
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Unexpected or unusable content format: %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @var_scale(i32 %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
switch i32 %0, label %8 [
i32 8, label %13
i32 16, label %4
i32 24, label %5
i32 132, label %6
i32 164, label %7
]
4: ; preds = %3
br label %13
5: ; preds = %3
br label %13
6: ; preds = %3
br label %13
7: ; preds = %3
br label %13
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %0)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %3, %7, %6, %5, %4
%14 = phi i32 [ 53, %7 ], [ 24, %6 ], [ 23, %5 ], [ 15, %4 ], [ 7, %3 ]
%15 = tail call i32 @INT64_C(i32 1)
%16 = shl i32 %15, %14
%17 = sitofp i32 %16 to double
store double %17, double* %1
%18 = fdiv double 1.000000e+00, %17
store double %18, double* %2
ret void
}