#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 dwt_getnorm(int, int);
double dwt_getnorm_real(int, int);
double mct_getnorm(int);
double mct_getnorm_real(int);
double t1_getwmsedec(int nmsedec, int compno, int level, int orient, int bpno,
                     int qmfbid, double stepsize) {
  double w1, w2, wmsedec;
  if (qmfbid == 1) {
    w1 = mct_getnorm(compno);
    w2 = dwt_getnorm(level, orient);
  } else if (qmfbid == 0) {
    w1 = mct_getnorm_real(compno);
    w2 = dwt_getnorm_real(level, orient);
  }
  wmsedec = w1 * w2 * stepsize * (1 << bpno);
  wmsedec *= wmsedec * nmsedec / 8192.0;
  return wmsedec;
}


x86 assembly (clang, -O0):
<t1_getwmsedec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    118d <t1_getwmsedec+0x4d>
mov    -0x8(%rbp),%edi
call   1060 <mct_getnorm@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <dwt_getnorm@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    11b9 <t1_getwmsedec+0x79>
cmpl   $0x0,-0x18(%rbp)
jne    11b4 <t1_getwmsedec+0x74>
mov    -0x8(%rbp),%edi
call   1050 <mct_getnorm_real@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <dwt_getnorm_real@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    11b9 <t1_getwmsedec+0x79>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0b(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1_getwmsedec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movapd %xmm0,%xmm2
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %edi,%r14d
test   %r9d,%r9d
je     1181 <t1_getwmsedec+0x41>
cmp    $0x1,%r9d
jne    11a9 <t1_getwmsedec+0x69>
mov    %esi,%edi
movsd  %xmm2,0x10(%rsp)
call   1060 <mct_getnorm@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <dwt_getnorm@plt>
jmp    119d <t1_getwmsedec+0x5d>
mov    %esi,%edi
movsd  %xmm2,0x10(%rsp)
call   1050 <mct_getnorm_real@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <dwt_getnorm_real@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    $0x1,%eax
mov    %r15d,%ecx
shl    %cl,%eax
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe26(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @t1_getwmsedec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double %6, double* %14
%18 = load i32, i32* %13
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %26
20: ; preds = %7
%21 = load i32, i32* %9
%22 = call double @mct_getnorm(i32 %21)
store double %22, double* %15
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = call double @dwt_getnorm(i32 %23, i32 %24)
store double %25, double* %16
br label %36
26: ; preds = %7
%27 = load i32, i32* %13
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %9
%31 = call double @mct_getnorm_real(i32 %30)
store double %31, double* %15
%32 = load i32, i32* %10
%33 = load i32, i32* %11
%34 = call double @dwt_getnorm_real(i32 %32, i32 %33)
store double %34, double* %16
br label %35
35: ; preds = %29, %26
br label %36
36: ; preds = %35, %20
%37 = load double, double* %15
%38 = load double, double* %16
%39 = fmul double %37, %38
%40 = load double, double* %14
%41 = fmul double %39, %40
%42 = load i32, i32* %12
%43 = shl i32 1, %42
%44 = sitofp i32 %43 to double
%45 = fmul double %41, %44
store double %45, double* %17
%46 = load double, double* %17
%47 = load i32, i32* %8
%48 = sitofp i32 %47 to double
%49 = fmul double %46, %48
%50 = fdiv double %49, 8.192000e+03
%51 = load double, double* %17
%52 = fmul double %51, %50
store double %52, double* %17
%53 = load double, double* %17
ret double %53
}

LLVM IR (-O2):
define double @t1_getwmsedec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
switch i32 %5, label %14 [
i32 1, label %8
i32 0, label %11
]
8: ; preds = %7
%9 = tail call double @mct_getnorm(i32 %1)
%10 = tail call double @dwt_getnorm(i32 %2, i32 %3)
br label %14
11: ; preds = %7
%12 = tail call double @mct_getnorm_real(i32 %1)
%13 = tail call double @dwt_getnorm_real(i32 %2, i32 %3)
br label %14
14: ; preds = %7, %11, %8
%15 = phi double [ %10, %8 ], [ %13, %11 ], [ undef, %7 ]
%16 = phi double [ %9, %8 ], [ %12, %11 ], [ undef, %7 ]
%17 = fmul double %15, %16
%18 = fmul double %17, %6
%19 = shl nuw i32 1, %4
%20 = sitofp i32 %19 to double
%21 = fmul double %18, %20
%22 = sitofp i32 %0 to double
%23 = fmul double %21, %22
%24 = fmul double %23, 0x3F20000000000000
%25 = fmul double %21, %24
ret double %25
}