#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, int numcomps) {
  double w1, w2, wmsedec;
  if (qmfbid == 1) {
    w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0;
    w2 = dwt_getnorm(level, orient);
  } else {
    w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0;
    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    $0x50,%rsp
mov    0x10(%rbp),%eax
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    11bb <t1_getwmsedec+0x7b>
cmpl   $0x1,0x10(%rbp)
jle    118a <t1_getwmsedec+0x4a>
mov    -0x8(%rbp),%edi
call   1060 <mct_getnorm@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    119c <t1_getwmsedec+0x5c>
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    119c <t1_getwmsedec+0x5c>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <dwt_getnorm@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1203 <t1_getwmsedec+0xc3>
cmpl   $0x1,0x10(%rbp)
jle    11d7 <t1_getwmsedec+0x97>
mov    -0x8(%rbp),%edi
call   1050 <mct_getnorm_real@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    11e9 <t1_getwmsedec+0xa9>
movsd  0xe21(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11e9 <t1_getwmsedec+0xa9>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <dwt_getnorm_real@plt>
movsd  %xmm0,-0x30(%rbp)
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  0xdc9(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1_getwmsedec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %edi,%r14d
mov    0x40(%rsp),%eax
cmp    $0x1,%r9d
jne    1172 <t1_getwmsedec+0x32>
cmp    $0x2,%eax
jl     1180 <t1_getwmsedec+0x40>
mov    %esi,%edi
call   1060 <mct_getnorm@plt>
jmp    1188 <t1_getwmsedec+0x48>
cmp    $0x2,%eax
jl     1199 <t1_getwmsedec+0x59>
mov    %esi,%edi
call   1050 <mct_getnorm_real@plt>
jmp    11a1 <t1_getwmsedec+0x61>
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <dwt_getnorm@plt>
jmp    11b0 <t1_getwmsedec+0x70>
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <dwt_getnorm_real@plt>
mov    $0x1,%eax
mov    %r15d,%ecx
shl    %cl,%eax
mulsd  0x8(%rsp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  0x10(%rsp),%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, i32 %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store double %6, double* %15
store i32 %7, i32* %16
%20 = load i32, i32* %14
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %34
22: ; preds = %8
%23 = load i32, i32* %16
%24 = icmp sgt i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %10
%27 = call double @mct_getnorm(i32 %26)
br label %29
28: ; preds = %22
br label %29
29: ; preds = %28, %25
%30 = phi double [ %27, %25 ], [ 1.000000e+00, %28 ]
store double %30, double* %17
%31 = load i32, i32* %11
%32 = load i32, i32* %12
%33 = call double @dwt_getnorm(i32 %31, i32 %32)
store double %33, double* %18
br label %46
34: ; preds = %8
%35 = load i32, i32* %16
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %10
%39 = call double @mct_getnorm_real(i32 %38)
br label %41
40: ; preds = %34
br label %41
41: ; preds = %40, %37
%42 = phi double [ %39, %37 ], [ 1.000000e+00, %40 ]
store double %42, double* %17
%43 = load i32, i32* %11
%44 = load i32, i32* %12
%45 = call double @dwt_getnorm_real(i32 %43, i32 %44)
store double %45, double* %18
br label %46
46: ; preds = %41, %29
%47 = load double, double* %17
%48 = load double, double* %18
%49 = fmul double %47, %48
%50 = load double, double* %15
%51 = fmul double %49, %50
%52 = load i32, i32* %13
%53 = shl i32 1, %52
%54 = sitofp i32 %53 to double
%55 = fmul double %51, %54
store double %55, double* %19
%56 = load double, double* %19
%57 = load i32, i32* %9
%58 = sitofp i32 %57 to double
%59 = fmul double %56, %58
%60 = fdiv double %59, 8.192000e+03
%61 = load double, double* %19
%62 = fmul double %61, %60
store double %62, double* %19
%63 = load double, double* %19
ret double %63
}

LLVM IR (-O2):
define double @t1_getwmsedec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, i32 %7) {
%9 = icmp eq i32 %5, 1
%10 = icmp sgt i32 %7, 1
br i1 %9, label %11, label %17
11: ; preds = %8
br i1 %10, label %12, label %14
12: ; preds = %11
%13 = tail call double @mct_getnorm(i32 %1)
br label %14
14: ; preds = %11, %12
%15 = phi double [ %13, %12 ], [ 1.000000e+00, %11 ]
%16 = tail call double @dwt_getnorm(i32 %2, i32 %3)
br label %23
17: ; preds = %8
br i1 %10, label %18, label %20
18: ; preds = %17
%19 = tail call double @mct_getnorm_real(i32 %1)
br label %20
20: ; preds = %17, %18
%21 = phi double [ %19, %18 ], [ 1.000000e+00, %17 ]
%22 = tail call double @dwt_getnorm_real(i32 %2, i32 %3)
br label %23
23: ; preds = %20, %14
%24 = phi double [ %16, %14 ], [ %22, %20 ]
%25 = phi double [ %15, %14 ], [ %21, %20 ]
%26 = fmul double %24, %25
%27 = fmul double %26, %6
%28 = shl nuw i32 1, %4
%29 = sitofp i32 %28 to double
%30 = fmul double %27, %29
%31 = sitofp i32 %0 to double
%32 = fmul double %30, %31
%33 = fmul double %32, 0x3F20000000000000
%34 = fmul double %30, %33
ret double %34
}