#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 */
float abs(float);
void filter_wave(float S[40][20], float d[40][20], int size1, int size2,
                 float Threshold) {
  int i, j;
  for (i = 0; i < size2; ++i) {
    for (j = 0; j < size1; ++j) {
      if (abs(d[i][j]) <= Threshold) {
        d[i][j] = 0.0;
      }
    }
  }
  if (S[size2 - 1][0] <= Threshold)
    S[size2 - 1][0] = 0.0;
}


x86 assembly (clang, -O0):
<filter_wave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c0 <filter_wave+0xb0>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ad <filter_wave+0x9d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     119a <filter_wave+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    119f <filter_wave+0x8f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <filter_wave+0x35>
jmp    11b2 <filter_wave+0xa2>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1132 <filter_wave+0x22>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movss  (%rax),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1201 <filter_wave+0xf1>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_wave>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,0x10(%rsp)
mov    %ecx,0x4(%rsp)
test   %ecx,%ecx
jle    1217 <filter_wave+0x107>
mov    %edx,%ebx
mov    0x4(%rsp),%eax
mov    %rax,0x20(%rsp)
mov    %edx,%r13d
mov    %r13,0x18(%rsp)
and    $0xfffffffe,%r13d
mov    0x8(%rsp),%rax
lea    0x4(%rax),%r15
xor    %r12d,%r12d
movss  %xmm0,(%rsp)
jmp    1173 <filter_wave+0x63>
xchg   %ax,%ax
add    $0x1,%r12
add    $0x50,%r15
cmp    0x20(%rsp),%r12
je     1217 <filter_wave+0x107>
test   %ebx,%ebx
jle    1160 <filter_wave+0x50>
xor    %r14d,%r14d
cmp    $0x1,%ebx
jne    11d9 <filter_wave+0xc9>
testb  $0x1,0x18(%rsp)
movss  (%rsp),%xmm0
je     1160 <filter_wave+0x50>
lea    (%r12,%r12,4),%rbp
shl    $0x4,%rbp
add    0x8(%rsp),%rbp
movss  0x0(%rbp,%r14,4),%xmm0
call   1030 <abs@plt>
movss  (%rsp),%xmm1
ucomiss %xmm0,%xmm1
movss  (%rsp),%xmm0
jb     1160 <filter_wave+0x50>
lea    0x0(,%r14,4),%rax
add    %rbp,%rax
movl   $0x0,(%rax)
jmp    1160 <filter_wave+0x50>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%r14
cmp    %r14,%r13
je     117f <filter_wave+0x6f>
movss  -0x4(%r15,%r14,4),%xmm0
call   1030 <abs@plt>
movss  (%rsp),%xmm1
ucomiss %xmm0,%xmm1
jb     11f8 <filter_wave+0xe8>
movl   $0x0,-0x4(%r15,%r14,4)
movss  (%r15,%r14,4),%xmm0
call   1030 <abs@plt>
movss  (%rsp),%xmm1
ucomiss %xmm0,%xmm1
jb     11d0 <filter_wave+0xc0>
movl   $0x0,(%r15,%r14,4)
jmp    11d0 <filter_wave+0xc0>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cltq
lea    (%rax,%rax,4),%rax
shl    $0x4,%rax
mov    0x10(%rsp),%rcx
ucomiss (%rcx,%rax,1),%xmm0
jb     123c <filter_wave+0x12c>
add    %rax,%rcx
movl   $0x0,(%rcx)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @filter_wave([20 x float]* %0, [20 x float]* %1, i32 %2, i32 %3, float %4) {
%6 = alloca [20 x float]*
%7 = alloca [20 x float]*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
store [20 x float]* %0, [20 x float]** %6
store [20 x float]* %1, [20 x float]** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store float %4, float* %10
store i32 0, i32* %11
br label %13
13: ; preds = %47, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %50
17: ; preds = %13
store i32 0, i32* %12
br label %18
18: ; preds = %43, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %46
22: ; preds = %18
%23 = load [20 x float]*, [20 x float]** %7
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x float], [20 x float]* %23, i64 %25
%27 = load i32, i32* %12
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x float], [20 x float]* %26, i64 0, i64 %28
%30 = load float, float* %29
%31 = call float @abs(float %30)
%32 = load float, float* %10
%33 = fcmp ole float %31, %32
br i1 %33, label %34, label %42
34: ; preds = %22
%35 = load [20 x float]*, [20 x float]** %7
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x float], [20 x float]* %35, i64 %37
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [20 x float], [20 x float]* %38, i64 0, i64 %40
store float 0.000000e+00, float* %41
br label %42
42: ; preds = %34, %22
br label %43
43: ; preds = %42
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %18
46: ; preds = %18
br label %47
47: ; preds = %46
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
store i32 %49, i32* %11
br label %13
50: ; preds = %13
%51 = load [20 x float]*, [20 x float]** %6
%52 = load i32, i32* %9
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [20 x float], [20 x float]* %51, i64 %54
%56 = getelementptr inbounds [20 x float], [20 x float]* %55, i64 0, i64 0
%57 = load float, float* %56
%58 = load float, float* %10
%59 = fcmp ole float %57, %58
br i1 %59, label %60, label %67
60: ; preds = %50
%61 = load [20 x float]*, [20 x float]** %6
%62 = load i32, i32* %9
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [20 x float], [20 x float]* %61, i64 %64
%66 = getelementptr inbounds [20 x float], [20 x float]* %65, i64 0, i64 0
store float 0.000000e+00, float* %66
br label %67
67: ; preds = %60, %50
ret void
}

LLVM IR (-O2):
define void @filter_wave([20 x float]* nocapture %0, [20 x float]* nocapture %1, i32 %2, i32 %3, float %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %48
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
%9 = zext i32 %3 to i64
%10 = zext i32 %2 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %2, 1
%13 = and i64 %10, 4294967294
%14 = icmp eq i64 %11, 0
br label %15
15: ; preds = %7, %45
%16 = phi i64 [ 0, %7 ], [ %46, %45 ]
br i1 %8, label %17, label %45
17: ; preds = %15
br i1 %12, label %37, label %18
18: ; preds = %17, %33
%19 = phi i64 [ %34, %33 ], [ 0, %17 ]
%20 = phi i64 [ %35, %33 ], [ 0, %17 ]
%21 = getelementptr inbounds [20 x float], [20 x float]* %1, i64 %16, i64 %19
%22 = load float, float* %21
%23 = tail call float @abs(float %22)
%24 = fcmp ugt float %23, %4
br i1 %24, label %26, label %25
25: ; preds = %18
store float 0.000000e+00, float* %21
br label %26
26: ; preds = %18, %25
%27 = or i64 %19, 1
%28 = getelementptr inbounds [20 x float], [20 x float]* %1, i64 %16, i64 %27
%29 = load float, float* %28
%30 = tail call float @abs(float %29)
%31 = fcmp ugt float %30, %4
br i1 %31, label %33, label %32
32: ; preds = %26
store float 0.000000e+00, float* %28
br label %33
33: ; preds = %32, %26
%34 = add nuw nsw i64 %19, 2
%35 = add i64 %20, 2
%36 = icmp eq i64 %35, %13
br i1 %36, label %37, label %18
37: ; preds = %33, %17
%38 = phi i64 [ 0, %17 ], [ %34, %33 ]
br i1 %14, label %45, label %39
39: ; preds = %37
%40 = getelementptr inbounds [20 x float], [20 x float]* %1, i64 %16, i64 %38
%41 = load float, float* %40
%42 = tail call float @abs(float %41)
%43 = fcmp ugt float %42, %4
br i1 %43, label %45, label %44
44: ; preds = %39
store float 0.000000e+00, float* %40
br label %45
45: ; preds = %37, %44, %39, %15
%46 = add nuw nsw i64 %16, 1
%47 = icmp eq i64 %46, %9
br i1 %47, label %48, label %15
48: ; preds = %45, %5
%49 = add nsw i32 %3, -1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [20 x float], [20 x float]* %0, i64 %50, i64 0
%52 = load float, float* %51
%53 = fcmp ugt float %52, %4
br i1 %53, label %55, label %54
54: ; preds = %48
store float 0.000000e+00, float* %51
br label %55
55: ; preds = %54, %48
ret void
}