#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 */
unsigned int LowPassMul(unsigned int, unsigned int, int *);
void deNoiseSpacial(unsigned char *Frame, unsigned char *FrameDest,
                    unsigned int *LineAnt, int W, int H, int sStride,
                    int dStride, int *Horizontal, int *Vertical) {
  long sLineOffs = 0, dLineOffs = 0;
  unsigned int PixelAnt;
  unsigned int PixelDst;
  PixelDst = LineAnt[0] = PixelAnt = Frame[0] << 16;
  FrameDest[0] = ((PixelDst + 0x10007FFF) >> 16);
  for (long X = 1; X < W; X++) {
    PixelDst = LineAnt[X] = LowPassMul(PixelAnt, Frame[X] << 16, Horizontal);
    FrameDest[X] = ((PixelDst + 0x10007FFF) >> 16);
  }
  for (long Y = 1; Y < H; Y++) {
    unsigned int PixelAnt;
    sLineOffs += sStride, dLineOffs += dStride;
    PixelAnt = Frame[sLineOffs] << 16;
    PixelDst = LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
    FrameDest[dLineOffs] = ((PixelDst + 0x10007FFF) >> 16);
    for (long X = 1; X < W; X++) {
      unsigned int PixelDst;
      PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs + X] << 16, Horizontal);
      PixelDst = LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical);
      FrameDest[dLineOffs + X] = ((PixelDst + 0x10007FFF) >> 16);
    }
  }
}


x86 assembly (clang, -O0):
<deNoiseSpacial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rcx
mov    %eax,(%rcx)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movq   $0x1,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jge    11de <deNoiseSpacial+0xce>
mov    -0x3c(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
shl    $0x10,%esi
mov    0x18(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    -0x18(%rbp),%rcx
mov    -0x48(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    117b <deNoiseSpacial+0x6b>
movq   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
jge    12f7 <deNoiseSpacial+0x1e7>
movslq -0x24(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movslq 0x10(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0x10,%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%esi
mov    0x20(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    -0x18(%rbp),%rcx
mov    %eax,(%rcx)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movq   $0x1,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jge    12e1 <deNoiseSpacial+0x1d1>
mov    -0x54(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
add    -0x60(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
shl    $0x10,%esi
mov    0x18(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x54(%rbp),%esi
mov    0x20(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    -0x18(%rbp),%rcx
mov    -0x60(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
add    -0x60(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    125c <deNoiseSpacial+0x14c>
jmp    12e6 <deNoiseSpacial+0x1d6>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11e6 <deNoiseSpacial+0xd6>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deNoiseSpacial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9d,0x10(%rsp)
mov    %r8d,0x8(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r13
mov    0xa8(%rsp),%r15
movzbl (%rdi),%eax
mov    %eax,%r12d
shl    $0x10,%r12d
mov    %r12d,(%rdx)
mov    %al,(%rsi)
mov    %ecx,0x1c(%rsp)
movslq %ecx,%r14
cmp    $0x2,%r14d
mov    %rdi,0x28(%rsp)
jl     1190 <deNoiseSpacial+0x80>
mov    $0x1,%ebp
nopl   0x0(%rax)
movzbl (%rdi,%rbp,1),%esi
shl    $0x10,%esi
mov    %r12d,%edi
mov    %r15,%rdx
call   1030 <LowPassMul@plt>
mov    0x28(%rsp),%rdi
mov    %eax,(%rbx,%rbp,4)
add    $0x7fff,%eax
shr    $0x10,%eax
mov    %al,0x0(%r13,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1160 <deNoiseSpacial+0x50>
mov    %rbx,0x48(%rsp)
mov    %r14,0x50(%rsp)
mov    %r13,0x20(%rsp)
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
jl     12ec <deNoiseSpacial+0x1dc>
mov    0xb0(%rsp),%r8
cltq
mov    %rax,0x40(%rsp)
movslq 0x10(%rsp),%rcx
movslq 0xa0(%rsp),%rdx
mov    0x20(%rsp),%rax
lea    (%rax,%rdx,1),%r13
lea    (%rdi,%rcx,1),%rbx
mov    $0x1,%eax
xor    %esi,%esi
xor    %ebp,%ebp
mov    %rcx,0x38(%rsp)
mov    %rdx,0x30(%rsp)
mov    0x48(%rsp),%r12
jmp    1233 <deNoiseSpacial+0x123>
nop
mov    0x10(%rsp),%rax
add    $0x1,%rax
mov    0x30(%rsp),%rdx
add    %rdx,%r13
mov    0x38(%rsp),%rcx
mov    0x8(%rsp),%rsi
add    %rcx,%rsi
cmp    0x40(%rsp),%rax
mov    0x28(%rsp),%rdi
mov    0xb0(%rsp),%r8
mov    %rsi,%rbx
mov    0x60(%rsp),%rsi
mov    0x58(%rsp),%rbp
je     12ec <deNoiseSpacial+0x1dc>
mov    %rbx,0x8(%rsp)
mov    %rax,0x10(%rsp)
add    %rcx,%rsi
add    %rdx,%rbp
mov    %rsi,0x60(%rsp)
movzbl (%rdi,%rsi,1),%r14d
shl    $0x10,%r14d
mov    (%r12),%edi
mov    %r14d,%esi
mov    %r8,%rdx
call   1030 <LowPassMul@plt>
lea    0x7fff(%rax),%ecx
shr    $0x10,%ecx
mov    %eax,(%r12)
mov    0x20(%rsp),%rax
mov    %rbp,0x58(%rsp)
mov    %cl,(%rax,%rbp,1)
cmpl   $0x2,0x1c(%rsp)
mov    0xa8(%rsp),%r15
mov    0x50(%rsp),%rbx
jl     11f0 <deNoiseSpacial+0xe0>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
movzbl (%rax,%rbp,1),%esi
shl    $0x10,%esi
mov    %r14d,%edi
mov    %r15,%rdx
call   1030 <LowPassMul@plt>
mov    %eax,%r14d
mov    (%r12,%rbp,4),%edi
mov    %eax,%esi
mov    0xb0(%rsp),%rdx
call   1030 <LowPassMul@plt>
mov    %eax,(%r12,%rbp,4)
add    $0x7fff,%eax
shr    $0x10,%eax
mov    %al,0x0(%r13,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12a0 <deNoiseSpacial+0x190>
jmp    11f0 <deNoiseSpacial+0xe0>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @deNoiseSpacial(i8* %0, i8* %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i32* %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i64
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
%23 = alloca i64
%24 = alloca i64
%25 = alloca i32
%26 = alloca i64
%27 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32* %2, i32** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32* %7, i32** %17
store i32* %8, i32** %18
store i64 0, i64* %19
store i64 0, i64* %20
%28 = load i8*, i8** %10
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 16
store i32 %32, i32* %21
%33 = load i32*, i32** %12
%34 = getelementptr inbounds i32, i32* %33, i64 0
store i32 %32, i32* %34
store i32 %32, i32* %22
%35 = load i32, i32* %22
%36 = add i32 %35, 268468223
%37 = lshr i32 %36, 16
%38 = trunc i32 %37 to i8
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i64 0
store i8 %38, i8* %40
store i64 1, i64* %23
br label %41
41: ; preds = %66, %9
%42 = load i64, i64* %23
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %46, label %69
46: ; preds = %41
%47 = load i32, i32* %21
%48 = load i8*, i8** %10
%49 = load i64, i64* %23
%50 = getelementptr inbounds i8, i8* %48, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = shl i32 %52, 16
%54 = load i32*, i32** %17
%55 = call i32 @LowPassMul(i32 %47, i32 %53, i32* %54)
%56 = load i32*, i32** %12
%57 = load i64, i64* %23
%58 = getelementptr inbounds i32, i32* %56, i64 %57
store i32 %55, i32* %58
store i32 %55, i32* %22
%59 = load i32, i32* %22
%60 = add i32 %59, 268468223
%61 = lshr i32 %60, 16
%62 = trunc i32 %61 to i8
%63 = load i8*, i8** %11
%64 = load i64, i64* %23
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8 %62, i8* %65
br label %66
66: ; preds = %46
%67 = load i64, i64* %23
%68 = add nsw i64 %67, 1
store i64 %68, i64* %23
br label %41
69: ; preds = %41
store i64 1, i64* %24
br label %70
70: ; preds = %145, %69
%71 = load i64, i64* %24
%72 = load i32, i32* %14
%73 = sext i32 %72 to i64
%74 = icmp slt i64 %71, %73
br i1 %74, label %75, label %148
75: ; preds = %70
%76 = load i32, i32* %15
%77 = sext i32 %76 to i64
%78 = load i64, i64* %19
%79 = add nsw i64 %78, %77
store i64 %79, i64* %19
%80 = load i32, i32* %16
%81 = sext i32 %80 to i64
%82 = load i64, i64* %20
%83 = add nsw i64 %82, %81
store i64 %83, i64* %20
%84 = load i8*, i8** %10
%85 = load i64, i64* %19
%86 = getelementptr inbounds i8, i8* %84, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = shl i32 %88, 16
store i32 %89, i32* %25
%90 = load i32*, i32** %12
%91 = getelementptr inbounds i32, i32* %90, i64 0
%92 = load i32, i32* %91
%93 = load i32, i32* %25
%94 = load i32*, i32** %18
%95 = call i32 @LowPassMul(i32 %92, i32 %93, i32* %94)
%96 = load i32*, i32** %12
%97 = getelementptr inbounds i32, i32* %96, i64 0
store i32 %95, i32* %97
store i32 %95, i32* %22
%98 = load i32, i32* %22
%99 = add i32 %98, 268468223
%100 = lshr i32 %99, 16
%101 = trunc i32 %100 to i8
%102 = load i8*, i8** %11
%103 = load i64, i64* %20
%104 = getelementptr inbounds i8, i8* %102, i64 %103
store i8 %101, i8* %104
store i64 1, i64* %26
br label %105
105: ; preds = %141, %75
%106 = load i64, i64* %26
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = icmp slt i64 %106, %108
br i1 %109, label %110, label %144
110: ; preds = %105
%111 = load i32, i32* %25
%112 = load i8*, i8** %10
%113 = load i64, i64* %19
%114 = load i64, i64* %26
%115 = add nsw i64 %113, %114
%116 = getelementptr inbounds i8, i8* %112, i64 %115
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = shl i32 %118, 16
%120 = load i32*, i32** %17
%121 = call i32 @LowPassMul(i32 %111, i32 %119, i32* %120)
store i32 %121, i32* %25
%122 = load i32*, i32** %12
%123 = load i64, i64* %26
%124 = getelementptr inbounds i32, i32* %122, i64 %123
%125 = load i32, i32* %124
%126 = load i32, i32* %25
%127 = load i32*, i32** %18
%128 = call i32 @LowPassMul(i32 %125, i32 %126, i32* %127)
%129 = load i32*, i32** %12
%130 = load i64, i64* %26
%131 = getelementptr inbounds i32, i32* %129, i64 %130
store i32 %128, i32* %131
store i32 %128, i32* %27
%132 = load i32, i32* %27
%133 = add i32 %132, 268468223
%134 = lshr i32 %133, 16
%135 = trunc i32 %134 to i8
%136 = load i8*, i8** %11
%137 = load i64, i64* %20
%138 = load i64, i64* %26
%139 = add nsw i64 %137, %138
%140 = getelementptr inbounds i8, i8* %136, i64 %139
store i8 %135, i8* %140
br label %141
141: ; preds = %110
%142 = load i64, i64* %26
%143 = add nsw i64 %142, 1
store i64 %143, i64* %26
br label %105
144: ; preds = %105
br label %145
145: ; preds = %144
%146 = load i64, i64* %24
%147 = add nsw i64 %146, 1
store i64 %147, i64* %24
br label %70
148: ; preds = %70
ret void
}

LLVM IR (-O2):
define void @deNoiseSpacial(i8* nocapture %0, i8* nocapture writeonly %1, i32* nocapture %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i32* %8) {
%10 = load i8, i8* %0
%11 = zext i8 %10 to i32
%12 = shl nuw nsw i32 %11, 16
store i32 %12, i32* %2
store i8 %10, i8* %1
%13 = sext i32 %3 to i64
%14 = icmp sgt i32 %3, 1
br i1 %14, label %21, label %15
15: ; preds = %21, %9
%16 = sext i32 %4 to i64
%17 = icmp sgt i32 %4, 1
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = sext i32 %5 to i64
%20 = sext i32 %6 to i64
br label %36
21: ; preds = %9, %21
%22 = phi i64 [ %33, %21 ], [ 1, %9 ]
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = shl nuw nsw i32 %25, 16
%27 = tail call i32 @LowPassMul(i32 %12, i32 %26, i32* %7)
%28 = getelementptr inbounds i32, i32* %2, i64 %22
store i32 %27, i32* %28
%29 = add i32 %27, 32767
%30 = lshr i32 %29, 16
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 %31, i8* %32
%33 = add nuw nsw i64 %22, 1
%34 = icmp eq i64 %33, %13
br i1 %34, label %15, label %21
35: ; preds = %52, %15
ret void
36: ; preds = %18, %52
%37 = phi i64 [ 0, %18 ], [ %40, %52 ]
%38 = phi i64 [ 1, %18 ], [ %53, %52 ]
%39 = phi i64 [ 0, %18 ], [ %41, %52 ]
%40 = add nsw i64 %37, %19
%41 = add nsw i64 %39, %20
%42 = getelementptr inbounds i8, i8* %0, i64 %40
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = shl nuw nsw i32 %44, 16
%46 = load i32, i32* %2
%47 = tail call i32 @LowPassMul(i32 %46, i32 %45, i32* %8)
store i32 %47, i32* %2
%48 = add i32 %47, 32767
%49 = lshr i32 %48, 16
%50 = trunc i32 %49 to i8
%51 = getelementptr inbounds i8, i8* %1, i64 %41
store i8 %50, i8* %51
br i1 %14, label %55, label %52
52: ; preds = %55, %36
%53 = add nuw nsw i64 %38, 1
%54 = icmp eq i64 %53, %16
br i1 %54, label %35, label %36
55: ; preds = %36, %55
%56 = phi i64 [ %72, %55 ], [ 1, %36 ]
%57 = phi i32 [ %63, %55 ], [ %45, %36 ]
%58 = add nsw i64 %56, %40
%59 = getelementptr inbounds i8, i8* %0, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = shl nuw nsw i32 %61, 16
%63 = tail call i32 @LowPassMul(i32 %57, i32 %62, i32* %7)
%64 = getelementptr inbounds i32, i32* %2, i64 %56
%65 = load i32, i32* %64
%66 = tail call i32 @LowPassMul(i32 %65, i32 %63, i32* %8)
store i32 %66, i32* %64
%67 = add i32 %66, 32767
%68 = lshr i32 %67, 16
%69 = trunc i32 %68 to i8
%70 = add nsw i64 %56, %41
%71 = getelementptr inbounds i8, i8* %1, i64 %70
store i8 %69, i8* %71
%72 = add nuw nsw i64 %56, 1
%73 = icmp eq i64 %72, %13
br i1 %73, label %52, label %55
}