#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 X, Y;
  long sLineOffs = 0, dLineOffs = 0;
  unsigned int PixelAnt;
  unsigned int PixelDst;
  PixelDst = LineAnt[0] = PixelAnt = Frame[0] << 16;
  FrameDest[0] = ((PixelDst + 0x10007FFF) >> 16);
  for (X = 1; X < W; X++) {
    PixelDst = LineAnt[X] = LowPassMul(PixelAnt, Frame[X] << 16, Horizontal);
    FrameDest[X] = ((PixelDst + 0x10007FFF) >> 16);
  }
  for (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 (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    $0x60,%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,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x10,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rcx
mov    %eax,(%rcx)
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jge    11de <deNoiseSpacial+0xce>
mov    -0x4c(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
shl    $0x10,%esi
mov    0x18(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    117b <deNoiseSpacial+0x6b>
movq   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
jge    12f7 <deNoiseSpacial+0x1e7>
movslq -0x24(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
movslq 0x10(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%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,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jge    12e1 <deNoiseSpacial+0x1d1>
mov    -0x54(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
add    -0x30(%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    -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x54(%rbp),%esi
mov    0x20(%rbp),%rdx
call   1030 <LowPassMul@plt>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
add    $0x10007fff,%eax
shr    $0x10,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
add    -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    125c <deNoiseSpacial+0x14c>
jmp    12e6 <deNoiseSpacial+0x1d6>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11e6 <deNoiseSpacial+0xd6>
add    $0x60,%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    %ebp,%ebp
xor    %esi,%esi
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),%rbp
mov    0x58(%rsp),%rsi
je     12ec <deNoiseSpacial+0x1dc>
mov    %rbx,0x8(%rsp)
mov    %rax,0x10(%rsp)
add    %rcx,%rsi
add    %rdx,%rbp
mov    %rsi,0x58(%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,0x60(%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 i64
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = 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* %21
store i64 0, i64* %22
%27 = load i8*, i8** %10
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl i32 %30, 16
store i32 %31, i32* %23
%32 = load i32*, i32** %12
%33 = getelementptr inbounds i32, i32* %32, i64 0
store i32 %31, i32* %33
store i32 %31, i32* %24
%34 = load i32, i32* %24
%35 = add i32 %34, 268468223
%36 = lshr i32 %35, 16
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %11
%39 = getelementptr inbounds i8, i8* %38, i64 0
store i8 %37, i8* %39
store i64 1, i64* %19
br label %40
40: ; preds = %65, %9
%41 = load i64, i64* %19
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %41, %43
br i1 %44, label %45, label %68
45: ; preds = %40
%46 = load i32, i32* %23
%47 = load i8*, i8** %10
%48 = load i64, i64* %19
%49 = getelementptr inbounds i8, i8* %47, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = shl i32 %51, 16
%53 = load i32*, i32** %17
%54 = call i32 @LowPassMul(i32 %46, i32 %52, i32* %53)
%55 = load i32*, i32** %12
%56 = load i64, i64* %19
%57 = getelementptr inbounds i32, i32* %55, i64 %56
store i32 %54, i32* %57
store i32 %54, i32* %24
%58 = load i32, i32* %24
%59 = add i32 %58, 268468223
%60 = lshr i32 %59, 16
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %11
%63 = load i64, i64* %19
%64 = getelementptr inbounds i8, i8* %62, i64 %63
store i8 %61, i8* %64
br label %65
65: ; preds = %45
%66 = load i64, i64* %19
%67 = add nsw i64 %66, 1
store i64 %67, i64* %19
br label %40
68: ; preds = %40
store i64 1, i64* %20
br label %69
69: ; preds = %144, %68
%70 = load i64, i64* %20
%71 = load i32, i32* %14
%72 = sext i32 %71 to i64
%73 = icmp slt i64 %70, %72
br i1 %73, label %74, label %147
74: ; preds = %69
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = load i64, i64* %21
%78 = add nsw i64 %77, %76
store i64 %78, i64* %21
%79 = load i32, i32* %16
%80 = sext i32 %79 to i64
%81 = load i64, i64* %22
%82 = add nsw i64 %81, %80
store i64 %82, i64* %22
%83 = load i8*, i8** %10
%84 = load i64, i64* %21
%85 = getelementptr inbounds i8, i8* %83, i64 %84
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = shl i32 %87, 16
store i32 %88, i32* %25
%89 = load i32*, i32** %12
%90 = getelementptr inbounds i32, i32* %89, i64 0
%91 = load i32, i32* %90
%92 = load i32, i32* %25
%93 = load i32*, i32** %18
%94 = call i32 @LowPassMul(i32 %91, i32 %92, i32* %93)
%95 = load i32*, i32** %12
%96 = getelementptr inbounds i32, i32* %95, i64 0
store i32 %94, i32* %96
store i32 %94, i32* %24
%97 = load i32, i32* %24
%98 = add i32 %97, 268468223
%99 = lshr i32 %98, 16
%100 = trunc i32 %99 to i8
%101 = load i8*, i8** %11
%102 = load i64, i64* %22
%103 = getelementptr inbounds i8, i8* %101, i64 %102
store i8 %100, i8* %103
store i64 1, i64* %19
br label %104
104: ; preds = %140, %74
%105 = load i64, i64* %19
%106 = load i32, i32* %13
%107 = sext i32 %106 to i64
%108 = icmp slt i64 %105, %107
br i1 %108, label %109, label %143
109: ; preds = %104
%110 = load i32, i32* %25
%111 = load i8*, i8** %10
%112 = load i64, i64* %21
%113 = load i64, i64* %19
%114 = add nsw i64 %112, %113
%115 = getelementptr inbounds i8, i8* %111, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = shl i32 %117, 16
%119 = load i32*, i32** %17
%120 = call i32 @LowPassMul(i32 %110, i32 %118, i32* %119)
store i32 %120, i32* %25
%121 = load i32*, i32** %12
%122 = load i64, i64* %19
%123 = getelementptr inbounds i32, i32* %121, i64 %122
%124 = load i32, i32* %123
%125 = load i32, i32* %25
%126 = load i32*, i32** %18
%127 = call i32 @LowPassMul(i32 %124, i32 %125, i32* %126)
%128 = load i32*, i32** %12
%129 = load i64, i64* %19
%130 = getelementptr inbounds i32, i32* %128, i64 %129
store i32 %127, i32* %130
store i32 %127, i32* %26
%131 = load i32, i32* %26
%132 = add i32 %131, 268468223
%133 = lshr i32 %132, 16
%134 = trunc i32 %133 to i8
%135 = load i8*, i8** %11
%136 = load i64, i64* %22
%137 = load i64, i64* %19
%138 = add nsw i64 %136, %137
%139 = getelementptr inbounds i8, i8* %135, i64 %138
store i8 %134, i8* %139
br label %140
140: ; preds = %109
%141 = load i64, i64* %19
%142 = add nsw i64 %141, 1
store i64 %142, i64* %19
br label %104
143: ; preds = %104
br label %144
144: ; preds = %143
%145 = load i64, i64* %20
%146 = add nsw i64 %145, 1
store i64 %146, i64* %20
br label %69
147: ; preds = %69
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 %73
18: ; preds = %15
%19 = sext i32 %5 to i64
%20 = sext i32 %6 to i64
br label %35
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 = %18, %70
%36 = phi i64 [ 1, %18 ], [ %71, %70 ]
%37 = phi i64 [ 0, %18 ], [ %40, %70 ]
%38 = phi i64 [ 0, %18 ], [ %39, %70 ]
%39 = add nsw i64 %38, %19
%40 = add nsw i64 %37, %20
%41 = getelementptr inbounds i8, i8* %0, i64 %39
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl nuw nsw i32 %43, 16
%45 = load i32, i32* %2
%46 = tail call i32 @LowPassMul(i32 %45, i32 %44, i32* %8)
store i32 %46, i32* %2
%47 = add i32 %46, 32767
%48 = lshr i32 %47, 16
%49 = trunc i32 %48 to i8
%50 = getelementptr inbounds i8, i8* %1, i64 %40
store i8 %49, i8* %50
br i1 %14, label %51, label %70
51: ; preds = %35, %51
%52 = phi i64 [ %68, %51 ], [ 1, %35 ]
%53 = phi i32 [ %59, %51 ], [ %44, %35 ]
%54 = add nsw i64 %52, %39
%55 = getelementptr inbounds i8, i8* %0, i64 %54
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = shl nuw nsw i32 %57, 16
%59 = tail call i32 @LowPassMul(i32 %53, i32 %58, i32* %7)
%60 = getelementptr inbounds i32, i32* %2, i64 %52
%61 = load i32, i32* %60
%62 = tail call i32 @LowPassMul(i32 %61, i32 %59, i32* %8)
store i32 %62, i32* %60
%63 = add i32 %62, 32767
%64 = lshr i32 %63, 16
%65 = trunc i32 %64 to i8
%66 = add nsw i64 %52, %40
%67 = getelementptr inbounds i8, i8* %1, i64 %66
store i8 %65, i8* %67
%68 = add nuw nsw i64 %52, 1
%69 = icmp eq i64 %68, %13
br i1 %69, label %70, label %51
70: ; preds = %51, %35
%71 = add nuw nsw i64 %36, 1
%72 = icmp eq i64 %71, %16
br i1 %72, label %73, label %35
73: ; preds = %70, %15
ret void
}