#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ __build_gaussian_coefs(float, float *);
int /*<<< orphan*/ __gauss16_line(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  float *, float *, int, int);
void blurMono16(uint32_t offset_src, uint32_t offset_out,
                uint32_t offset_tmp_out, uint32_t offset_line,
                uint32_t offset_coefs, uint32_t width, uint32_t height,
                float radius) {
  uint8_t *memory = 0;
  uint16_t *src = (uint16_t *)(memory + offset_src);
  uint16_t *out = (uint16_t *)(memory + offset_out);
  uint16_t *tmp_out = (uint16_t *)(memory + offset_tmp_out);
  float *tmp_line = (float *)(memory + offset_line);
  float *coefs = (float *)(memory + offset_coefs);
  if (!radius)
    return;
  if (radius < 0.5)
    radius = 0.5;
  __build_gaussian_coefs(radius, coefs);
  int line;
  uint16_t *src_line_offset;
  uint16_t *out_col_offset;
  for (line = 0; line < height; line++) {
    src_line_offset = src + line * width;
    out_col_offset = tmp_out + line;
    __gauss16_line(src_line_offset, out_col_offset, tmp_line, coefs, width,
                   height);
  }
  for (line = 0; line < width; line++) {
    src_line_offset = tmp_out + line * height;
    out_col_offset = out + line;
    __gauss16_line(src_line_offset, out_col_offset, tmp_line, coefs, height,
                   width);
  }
}


x86 assembly (clang, -O0):
<blurMono16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c7 <blurMono16+0xa7>
jp     11c7 <blurMono16+0xa7>
jmp    12d1 <blurMono16+0x1b1>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe28(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ef <blurMono16+0xcf>
movss  0xe1e(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mov    -0x50(%rbp),%rdi
call   1040 <__build_gaussian_coefs@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1267 <blurMono16+0x147>
mov    -0x30(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    0x10(%rbp),%r9d
call   1030 <__gauss16_line@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1204 <blurMono16+0xe4>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12d1 <blurMono16+0x1b1>
mov    -0x40(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   0x10(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    0x10(%rbp),%r8d
mov    -0x18(%rbp),%r9d
call   1030 <__gauss16_line@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    126e <blurMono16+0x14e>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blurMono16>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113c <blurMono16+0x1c>
jnp    1218 <blurMono16+0xf8>
mov    %r9d,%ebp
mov    %edi,%ebx
mov    %esi,0xc(%rsp)
mov    0x50(%rsp),%r12d
movslq %edx,%r15
shl    $0x2,%r15
movslq %ecx,%rax
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
movslq %r8d,%r14
shl    $0x2,%r14
movss  0xe94(%rip),%xmm1
maxss  %xmm0,%xmm1
movaps %xmm1,%xmm0
mov    %r14,%rdi
call   1040 <__build_gaussian_coefs@plt>
mov    %r12d,%r8d
test   %r12d,%r12d
mov    %ebp,0x8(%rsp)
jle    11cf <blurMono16+0xaf>
movslq %ebx,%r13
shl    $0x2,%r13
movslq 0x8(%rsp),%rbp
mov    %r8d,%r12d
shl    $0x2,%rbp
mov    %r15,%rbx
nopl   (%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    0x10(%rsp),%rdx
mov    %r14,%rcx
mov    0x8(%rsp),%r8d
mov    0x50(%rsp),%r9d
call   1030 <__gauss16_line@plt>
mov    0x50(%rsp),%r8d
add    %rbp,%r13
add    $0x4,%rbx
add    $0xffffffffffffffff,%r12
jne    11a0 <blurMono16+0x80>
mov    0x8(%rsp),%r13d
test   %r13d,%r13d
mov    0xc(%rsp),%eax
jle    1218 <blurMono16+0xf8>
movslq %eax,%rbx
shl    $0x2,%rbx
movslq %r8d,%r12
mov    %r13d,%ebp
shl    $0x2,%r12
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
mov    0x10(%rsp),%rdx
mov    %r14,%rcx
mov    %r13d,%r9d
call   1030 <__gauss16_line@plt>
mov    0x50(%rsp),%r8d
add    %r12,%r15
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    11f0 <blurMono16+0xd0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @blurMono16(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca float*
%22 = alloca float*
%23 = alloca i32
%24 = alloca i32*
%25 = alloca i32*
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 i32 %5, i32* %14
store i32 %6, i32* %15
store float %7, float* %16
store i32* null, i32** %17
%26 = load i32*, i32** %17
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32* %29, i32** %18
%30 = load i32*, i32** %17
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32* %33, i32** %19
%34 = load i32*, i32** %17
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32* %37, i32** %20
%38 = load i32*, i32** %17
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = bitcast i32* %41 to float*
store float* %42, float** %21
%43 = load i32*, i32** %17
%44 = load i32, i32* %13
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = bitcast i32* %46 to float*
store float* %47, float** %22
%48 = load float, float* %16
%49 = fcmp une float %48, 0.000000e+00
br i1 %49, label %51, label %50
50: ; preds = %8
br label %111
51: ; preds = %8
%52 = load float, float* %16
%53 = fpext float %52 to double
%54 = fcmp olt double %53, 5.000000e-01
br i1 %54, label %55, label %56
55: ; preds = %51
store float 5.000000e-01, float* %16
br label %56
56: ; preds = %55, %51
%57 = load float, float* %16
%58 = load float*, float** %22
%59 = call i32 @__build_gaussian_coefs(float %57, float* %58)
store i32 0, i32* %23
br label %60
60: ; preds = %82, %56
%61 = load i32, i32* %23
%62 = load i32, i32* %15
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %85
64: ; preds = %60
%65 = load i32*, i32** %18
%66 = load i32, i32* %23
%67 = load i32, i32* %14
%68 = mul nsw i32 %66, %67
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %65, i64 %69
store i32* %70, i32** %24
%71 = load i32*, i32** %20
%72 = load i32, i32* %23
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
store i32* %74, i32** %25
%75 = load i32*, i32** %24
%76 = load i32*, i32** %25
%77 = load float*, float** %21
%78 = load float*, float** %22
%79 = load i32, i32* %14
%80 = load i32, i32* %15
%81 = call i32 @__gauss16_line(i32* %75, i32* %76, float* %77, float* %78, i32 %79, i32 %80)
br label %82
82: ; preds = %64
%83 = load i32, i32* %23
%84 = add nsw i32 %83, 1
store i32 %84, i32* %23
br label %60
85: ; preds = %60
store i32 0, i32* %23
br label %86
86: ; preds = %108, %85
%87 = load i32, i32* %23
%88 = load i32, i32* %14
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %111
90: ; preds = %86
%91 = load i32*, i32** %20
%92 = load i32, i32* %23
%93 = load i32, i32* %15
%94 = mul nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %91, i64 %95
store i32* %96, i32** %24
%97 = load i32*, i32** %19
%98 = load i32, i32* %23
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i32, i32* %97, i64 %99
store i32* %100, i32** %25
%101 = load i32*, i32** %24
%102 = load i32*, i32** %25
%103 = load float*, float** %21
%104 = load float*, float** %22
%105 = load i32, i32* %15
%106 = load i32, i32* %14
%107 = call i32 @__gauss16_line(i32* %101, i32* %102, float* %103, float* %104, i32 %105, i32 %106)
br label %108
108: ; preds = %90
%109 = load i32, i32* %23
%110 = add nsw i32 %109, 1
store i32 %110, i32* %23
br label %86
111: ; preds = %50, %86
ret void
}

LLVM IR (-O2):
define void @blurMono16(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7) {
%9 = sext i32 %0 to i64
%10 = getelementptr inbounds i32, i32* null, i64 %9
%11 = sext i32 %1 to i64
%12 = getelementptr inbounds i32, i32* null, i64 %11
%13 = sext i32 %2 to i64
%14 = getelementptr inbounds i32, i32* null, i64 %13
%15 = sext i32 %3 to i64
%16 = getelementptr inbounds i32, i32* null, i64 %15
%17 = bitcast i32* %16 to float*
%18 = sext i32 %4 to i64
%19 = getelementptr inbounds i32, i32* null, i64 %18
%20 = bitcast i32* %19 to float*
%21 = fcmp une float %7, 0.000000e+00
br i1 %21, label %22, label %51
22: ; preds = %8
%23 = fcmp olt float %7, 5.000000e-01
%24 = select i1 %23, float 5.000000e-01, float %7
%25 = tail call i32 @__build_gaussian_coefs(float %24, float* %20)
%26 = icmp sgt i32 %6, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = sext i32 %5 to i64
%29 = zext i32 %6 to i64
br label %35
30: ; preds = %35, %22
%31 = icmp sgt i32 %5, 0
br i1 %31, label %32, label %51
32: ; preds = %30
%33 = sext i32 %6 to i64
%34 = zext i32 %5 to i64
br label %43
35: ; preds = %27, %35
%36 = phi i64 [ 0, %27 ], [ %41, %35 ]
%37 = mul nsw i64 %36, %28
%38 = getelementptr inbounds i32, i32* %10, i64 %37
%39 = getelementptr inbounds i32, i32* %14, i64 %36
%40 = tail call i32 @__gauss16_line(i32* %38, i32* %39, float* %17, float* %20, i32 %5, i32 %6)
%41 = add nuw nsw i64 %36, 1
%42 = icmp eq i64 %41, %29
br i1 %42, label %30, label %35
43: ; preds = %32, %43
%44 = phi i64 [ 0, %32 ], [ %49, %43 ]
%45 = mul nsw i64 %44, %33
%46 = getelementptr inbounds i32, i32* %14, i64 %45
%47 = getelementptr inbounds i32, i32* %12, i64 %44
%48 = tail call i32 @__gauss16_line(i32* %46, i32* %47, float* %17, float* %20, i32 %6, i32 %5)
%49 = add nuw nsw i64 %44, 1
%50 = icmp eq i64 %49, %34
br i1 %50, label %51, label %43
51: ; preds = %43, %30, %8
ret void
}