#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 *, int *);
int mct_getnorm(int);
int mct_getnorm_real(int);
double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient,
                     int bpno, double stepsize, int numcomps, int dwtid[3]) {
  double w1, w2, wmsedec;
  if (dwtid[0] == 1 || dwtid[1] == 1 || dwtid[2] == 1) {
    w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1;
  } else {
    w1 = (numcomps > 1) ? mct_getnorm(compno) : 1;
  }
  w2 = dwt_getnorm(orient, level, dwtid);
  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),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    0x10(%rbp),%rax
cmpl   $0x1,(%rax)
je     117f <t1_getwmsedec+0x4f>
mov    0x10(%rbp),%rax
cmpl   $0x1,0x4(%rax)
je     117f <t1_getwmsedec+0x4f>
mov    0x10(%rbp),%rax
cmpl   $0x1,0x8(%rax)
jne    11b7 <t1_getwmsedec+0x87>
cmpl   $0x1,-0x24(%rbp)
jle    1199 <t1_getwmsedec+0x69>
mov    -0x8(%rbp),%edi
call   1040 <mct_getnorm_real@plt>
mov    %eax,-0x44(%rbp)
jmp    11a6 <t1_getwmsedec+0x76>
mov    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a6 <t1_getwmsedec+0x76>
mov    -0x44(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11ea <t1_getwmsedec+0xba>
cmpl   $0x1,-0x24(%rbp)
jle    11d1 <t1_getwmsedec+0xa1>
mov    -0x8(%rbp),%edi
call   1050 <mct_getnorm@plt>
mov    %eax,-0x48(%rbp)
jmp    11de <t1_getwmsedec+0xae>
mov    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11de <t1_getwmsedec+0xae>
mov    -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   1030 <dwt_getnorm@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc5(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%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
movsd  %xmm0,0x8(%rsp)
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %edi,%r14d
mov    0x40(%rsp),%r12
cmpl   $0x1,(%r12)
je     1169 <t1_getwmsedec+0x39>
cmpl   $0x1,0x4(%r12)
je     1169 <t1_getwmsedec+0x39>
cmpl   $0x1,0x8(%r12)
jne    117f <t1_getwmsedec+0x4f>
cmp    $0x2,%r9d
jl     118e <t1_getwmsedec+0x5e>
mov    %esi,%edi
call   1040 <mct_getnorm_real@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    1196 <t1_getwmsedec+0x66>
cmp    $0x2,%r9d
jl     118e <t1_getwmsedec+0x5e>
mov    %esi,%edi
call   1050 <mct_getnorm@plt>
jmp    1176 <t1_getwmsedec+0x46>
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1030 <dwt_getnorm@plt>
mov    $0x1,%eax
mov    %r15d,%ecx
shl    %cl,%eax
mulsd  (%rsp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xe2f(%rip),%xmm1
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, double %5, i32 %6, i32* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%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 double %5, double* %14
store i32 %6, i32* %15
store i32* %7, i32** %16
%20 = load i32*, i32** %16
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 1
br i1 %23, label %34, label %24
24: ; preds = %8
%25 = load i32*, i32** %16
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 1
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i32*, i32** %16
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %44
34: ; preds = %29, %24, %8
%35 = load i32, i32* %15
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %10
%39 = call i32 @mct_getnorm_real(i32 %38)
br label %41
40: ; preds = %34
br label %41
41: ; preds = %40, %37
%42 = phi i32 [ %39, %37 ], [ 1, %40 ]
%43 = sitofp i32 %42 to double
store double %43, double* %17
br label %54
44: ; preds = %29
%45 = load i32, i32* %15
%46 = icmp sgt i32 %45, 1
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %10
%49 = call i32 @mct_getnorm(i32 %48)
br label %51
50: ; preds = %44
br label %51
51: ; preds = %50, %47
%52 = phi i32 [ %49, %47 ], [ 1, %50 ]
%53 = sitofp i32 %52 to double
store double %53, double* %17
br label %54
54: ; preds = %51, %41
%55 = load i32, i32* %12
%56 = load i32*, i32** %11
%57 = load i32*, i32** %16
%58 = call double @dwt_getnorm(i32 %55, i32* %56, i32* %57)
store double %58, double* %18
%59 = load double, double* %17
%60 = load double, double* %18
%61 = fmul double %59, %60
%62 = load double, double* %14
%63 = fmul double %61, %62
%64 = load i32, i32* %13
%65 = shl i32 1, %64
%66 = sitofp i32 %65 to double
%67 = fmul double %63, %66
store double %67, double* %19
%68 = load double, double* %19
%69 = load i32, i32* %9
%70 = sitofp i32 %69 to double
%71 = fmul double %68, %70
%72 = fdiv double %71, 8.192000e+03
%73 = load double, double* %19
%74 = fmul double %73, %72
store double %74, double* %19
%75 = load double, double* %19
ret double %75
}

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