#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*/ filter_wave(float **, float **, int, int, int);
int log(double);
int /*<<< orphan*/ wave_down(float **, float **, float *, int, int *);
int /*<<< orphan*/ wave_up(float **, float **, float *, int, int *);
void Haar_wavelet(float *S_in, float *S_out, int size, int Threshold) {
  int size_1 = size / 2;
  int size_2 = (int)(log((double)size) / log(2.0));
  int index;
  float S[40][20];
  float d[40][20];
  int i, j;
  wave_down(S, d, S_in, size, &index);
  filter_wave(S, d, size_1, size_2, Threshold);
  wave_up(S, d, S_out, size, &index);
}


x86 assembly (clang, -O0):
<Haar_wavelet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1940,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,-0x193c(%rbp)
movsd  0xe81(%rip),%xmm0
call   1050 <log@plt>
mov    %eax,%ecx
mov    -0x193c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
lea    -0xcb0(%rbp),%rdi
lea    -0x1930(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x24(%rbp),%r8
call   1040 <wave_down@plt>
lea    -0xcb0(%rbp),%rdi
lea    -0x1930(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1060 <filter_wave@plt>
lea    -0xcb0(%rbp),%rdi
lea    -0x1930(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x24(%rbp),%r8
call   1030 <wave_up@plt>
add    $0x1940,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Haar_wavelet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1928,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,%ebp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
mov    %edx,%ebx
shr    $0x1f,%ebx
add    %edx,%ebx
sar    %ebx
cvtsi2sd %edx,%xmm0
call   1050 <log@plt>
mov    %eax,%r13d
movsd  0xe84(%rip),%xmm0
call   1050 <log@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
mov    %eax,%r13d
lea    0xca0(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x1c(%rsp),%r8
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
mov    %r8,%r12
call   1040 <wave_down@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r13d,%ecx
mov    0xc(%rsp),%r8d
call   1060 <filter_wave@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    0x10(%rsp),%rdx
mov    %ebp,%ecx
mov    %r12,%r8
call   1030 <wave_up@plt>
add    $0x1928,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Haar_wavelet(float* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [40 x [20 x float]]
%13 = alloca [40 x [20 x float]]
%14 = alloca i32
%15 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%16 = load i32, i32* %7
%17 = sdiv i32 %16, 2
store i32 %17, i32* %9
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = call i32 @log(double %19)
%21 = call i32 @log(double 2.000000e+00)
%22 = sdiv i32 %20, %21
store i32 %22, i32* %10
%23 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %12, i64 0, i64 0
%24 = bitcast [20 x float]* %23 to float**
%25 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %13, i64 0, i64 0
%26 = bitcast [20 x float]* %25 to float**
%27 = load float*, float** %5
%28 = load i32, i32* %7
%29 = call i32 @wave_down(float** %24, float** %26, float* %27, i32 %28, i32* %11)
%30 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %12, i64 0, i64 0
%31 = bitcast [20 x float]* %30 to float**
%32 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %13, i64 0, i64 0
%33 = bitcast [20 x float]* %32 to float**
%34 = load i32, i32* %9
%35 = load i32, i32* %10
%36 = load i32, i32* %8
%37 = call i32 @filter_wave(float** %31, float** %33, i32 %34, i32 %35, i32 %36)
%38 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %12, i64 0, i64 0
%39 = bitcast [20 x float]* %38 to float**
%40 = getelementptr inbounds [40 x [20 x float]], [40 x [20 x float]]* %13, i64 0, i64 0
%41 = bitcast [20 x float]* %40 to float**
%42 = load float*, float** %6
%43 = load i32, i32* %7
%44 = call i32 @wave_up(float** %39, float** %41, float* %42, i32 %43, i32* %11)
ret void
}

LLVM IR (-O2):
define void @Haar_wavelet(float* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca [40 x [20 x float]]
%7 = alloca [40 x [20 x float]]
%8 = sdiv i32 %2, 2
%9 = sitofp i32 %2 to double
%10 = tail call i32 @log(double %9)
%11 = tail call i32 @log(double 2.000000e+00)
%12 = sdiv i32 %10, %11
%13 = bitcast i32* %5 to i8*
%14 = bitcast [40 x [20 x float]]* %6 to i8*
%15 = bitcast [40 x [20 x float]]* %7 to i8*
%16 = bitcast [40 x [20 x float]]* %6 to float**
%17 = bitcast [40 x [20 x float]]* %7 to float**
%18 = call i32 @wave_down(float** %16, float** %17, float* %0, i32 %2, i32* %5)
%19 = call i32 @filter_wave(float** %16, float** %17, i32 %8, i32 %12, i32 %3)
%20 = call i32 @wave_up(float** %16, float** %17, float* %1, i32 %2, i32* %5)
ret void
}