#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*/ filterh2d(int *, int, int *, int *, int, int);
int /*<<< orphan*/ filterv2d(int *, int, int *, int *, int, int);
int /*<<< orphan*/ gaussian1d(int *, int, double, int);
int gaussian_blur(int *in, int *out, int *tmp, int width, int height,
                  double sd) {
  int nker;
  int ker[30];
  nker = 3.0 * 2.0 * sd;
  if (nker > 30)
    return 1;
  gaussian1d(ker, nker, sd, 255);
  filterh2d(ker, nker, in, tmp, width, height);
  filterv2d(ker, nker, tmp, out, width, height);
  return 0;
}


x86 assembly (clang, -O0):
<gaussian_blur>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  0xea5(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1e,-0x34(%rbp)
jle    117d <gaussian_blur+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    11db <gaussian_blur+0xab>
lea    -0xb0(%rbp),%rdi
mov    -0x34(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
mov    $0xff,%edx
call   1030 <gaussian1d@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1050 <filterh2d@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1040 <filterv2d@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian_blur>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  0xeba(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
mov    $0x1,%eax
cmp    $0x1e,%ebp
jg     11a4 <gaussian_blur+0x74>
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r13
mov    %rsp,%rdi
mov    %ebp,%esi
mov    $0xff,%edx
call   1030 <gaussian1d@plt>
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1050 <filterh2d@plt>
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1040 <filterv2d@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gaussian_blur(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4, double %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca i32
%15 = alloca [30 x i32]
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store double %5, double* %13
%16 = load double, double* %13
%17 = fmul double 6.000000e+00, %16
%18 = fptosi double %17 to i32
store i32 %18, i32* %14
%19 = load i32, i32* %14
%20 = icmp sgt i32 %19, 30
br i1 %20, label %21, label %22
21: ; preds = %6
store i32 1, i32* %7
br label %41
22: ; preds = %6
%23 = getelementptr inbounds [30 x i32], [30 x i32]* %15, i64 0, i64 0
%24 = load i32, i32* %14
%25 = load double, double* %13
%26 = call i32 @gaussian1d(i32* %23, i32 %24, double %25, i32 255)
%27 = getelementptr inbounds [30 x i32], [30 x i32]* %15, i64 0, i64 0
%28 = load i32, i32* %14
%29 = load i32*, i32** %8
%30 = load i32*, i32** %10
%31 = load i32, i32* %11
%32 = load i32, i32* %12
%33 = call i32 @filterh2d(i32* %27, i32 %28, i32* %29, i32* %30, i32 %31, i32 %32)
%34 = getelementptr inbounds [30 x i32], [30 x i32]* %15, i64 0, i64 0
%35 = load i32, i32* %14
%36 = load i32*, i32** %10
%37 = load i32*, i32** %9
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = call i32 @filterv2d(i32* %34, i32 %35, i32* %36, i32* %37, i32 %38, i32 %39)
store i32 0, i32* %7
br label %41
41: ; preds = %22, %21
%42 = load i32, i32* %7
ret i32 %42
}

LLVM IR (-O2):
define i32 @gaussian_blur(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4, double %5) {
%7 = alloca [30 x i32]
%8 = bitcast [30 x i32]* %7 to i8*
%9 = fmul double %5, 6.000000e+00
%10 = fptosi double %9 to i32
%11 = icmp sgt i32 %10, 30
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = getelementptr inbounds [30 x i32], [30 x i32]* %7, i64 0, i64 0
%14 = call i32 @gaussian1d(i32* %13, i32 %10, double %5, i32 255)
%15 = call i32 @filterh2d(i32* %13, i32 %10, i32* %0, i32* %2, i32 %3, i32 %4)
%16 = call i32 @filterv2d(i32* %13, i32 %10, i32* %2, i32* %1, i32 %3, i32 %4)
br label %17
17: ; preds = %6, %12
%18 = phi i32 [ 0, %12 ], [ 1, %6 ]
ret i32 %18
}