#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, int mct) {
  double w1, w2, wmsedec;
  if (qmfbid == 1) {
    w1 = (mct && numcomps == 3) ? mct_getnorm(compno) : 1.0;
    w2 = dwt_getnorm(level, orient);
  } else {
    w1 = (mct && numcomps == 3) ? 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    0x18(%rbp),%eax
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    11c8 <t1_getwmsedec+0x88>
cmpl   $0x0,0x18(%rbp)
je     1197 <t1_getwmsedec+0x57>
cmpl   $0x3,0x10(%rbp)
jne    1197 <t1_getwmsedec+0x57>
mov    -0x8(%rbp),%edi
call   1060 <mct_getnorm@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    11a9 <t1_getwmsedec+0x69>
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11a9 <t1_getwmsedec+0x69>
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    121a <t1_getwmsedec+0xda>
cmpl   $0x0,0x18(%rbp)
je     11ee <t1_getwmsedec+0xae>
cmpl   $0x3,0x10(%rbp)
jne    11ee <t1_getwmsedec+0xae>
mov    -0x8(%rbp),%edi
call   1050 <mct_getnorm_real@plt>
movsd  %xmm0,-0x48(%rbp)
jmp    1200 <t1_getwmsedec+0xc0>
movsd  0xe0a(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1200 <t1_getwmsedec+0xc0>
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  0xdb2(%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   %r12
push   %rbx
sub    $0x10,%rsp
cmpl   $0x0,0x48(%rsp)
setne  %bl
cmpl   $0x3,0x40(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %edi,%r14d
sete   %al
and    %bl,%al
cmp    $0x1,%r9d
jne    1182 <t1_getwmsedec+0x42>
test   %al,%al
je     118f <t1_getwmsedec+0x4f>
mov    %esi,%edi
call   1060 <mct_getnorm@plt>
jmp    1197 <t1_getwmsedec+0x57>
test   %al,%al
je     11a8 <t1_getwmsedec+0x68>
mov    %esi,%edi
call   1050 <mct_getnorm_real@plt>
jmp    11b0 <t1_getwmsedec+0x70>
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %r12d,%esi
call   1040 <dwt_getnorm@plt>
jmp    11bf <t1_getwmsedec+0x7f>
movsd  0xe50(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %r12d,%esi
call   1030 <dwt_getnorm_real@plt>
mov    $0x1,%eax
mov    %r15d,%ecx
shl    %cl,%eax
mulsd  (%rsp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe18(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
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, i32 %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double %6, double* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%22 = load i32, i32* %15
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %39
24: ; preds = %9
%25 = load i32, i32* %18
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i32, i32* %17
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %11
%32 = call double @mct_getnorm(i32 %31)
br label %34
33: ; preds = %27, %24
br label %34
34: ; preds = %33, %30
%35 = phi double [ %32, %30 ], [ 1.000000e+00, %33 ]
store double %35, double* %19
%36 = load i32, i32* %12
%37 = load i32, i32* %13
%38 = call double @dwt_getnorm(i32 %36, i32 %37)
store double %38, double* %20
br label %54
39: ; preds = %9
%40 = load i32, i32* %18
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %17
%44 = icmp eq i32 %43, 3
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %11
%47 = call double @mct_getnorm_real(i32 %46)
br label %49
48: ; preds = %42, %39
br label %49
49: ; preds = %48, %45
%50 = phi double [ %47, %45 ], [ 1.000000e+00, %48 ]
store double %50, double* %19
%51 = load i32, i32* %12
%52 = load i32, i32* %13
%53 = call double @dwt_getnorm_real(i32 %51, i32 %52)
store double %53, double* %20
br label %54
54: ; preds = %49, %34
%55 = load double, double* %19
%56 = load double, double* %20
%57 = fmul double %55, %56
%58 = load double, double* %16
%59 = fmul double %57, %58
%60 = load i32, i32* %14
%61 = shl i32 1, %60
%62 = sitofp i32 %61 to double
%63 = fmul double %59, %62
store double %63, double* %21
%64 = load double, double* %21
%65 = load i32, i32* %10
%66 = sitofp i32 %65 to double
%67 = fmul double %64, %66
%68 = fdiv double %67, 8.192000e+03
%69 = load double, double* %21
%70 = fmul double %69, %68
store double %70, double* %21
%71 = load double, double* %21
ret double %71
}

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