#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*/ _base_convolve_real(float *, int, float *, int, float *, int,
                                       int, int, int, int);
scalar_t__ bounds_check(int, int, int, int, int, int);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
int convolve_real(float *x, int x_len, float *h, int h_len, float *y, int y_len,
                  int start, int len, int step, int offset) {
  void (*conv_func)(float *, float *, float *, int) = NULL;
  void (*conv_func_n)(float *, float *, float *, int, int) = NULL;
  if (bounds_check(x_len, h_len, y_len, start, len, step) < 0)
    return -1;
  memset(y, 0, len * 2 * sizeof(float));
  if (conv_func) {
    conv_func(&x[2 * (-(h_len - 1) + start)], h, y, len);
  } else if (conv_func_n) {
    conv_func_n(&x[2 * (-(h_len - 1) + start)], h, y, h_len, len);
  } else {
    _base_convolve_real(x, x_len, h, h_len, y, y_len, start, len, step, offset);
  }
  return len;
}


x86 assembly (clang, -O0):
<convolve_real>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9d
call   1040 <bounds_check@plt>
cmp    $0x0,%rax
jge    119a <convolve_real+0x6a>
movl   $0xffffffff,-0xc(%rbp)
jmp    127a <convolve_real+0x14a>
mov    -0x38(%rbp),%rdi
mov    0x18(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
cmpq   $0x0,-0x48(%rbp)
je     11f2 <convolve_real+0xc2>
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
sub    %edx,%ecx
add    0x10(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    0x18(%rbp),%ecx
call   *%rax
jmp    1274 <convolve_real+0x144>
cmpq   $0x0,-0x50(%rbp)
je     1235 <convolve_real+0x105>
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
sub    %edx,%ecx
add    0x10(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    0x18(%rbp),%r8d
call   *%rax
jmp    126f <convolve_real+0x13f>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x38(%rbp),%r8
mov    -0x3c(%rbp),%r9d
mov    0x10(%rbp),%ebx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10d
mov    0x28(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1050 <_base_convolve_real@plt>
jmp    1274 <convolve_real+0x144>
mov    0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolve_real>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r13d
mov    %r8,%r12
mov    %ecx,%ebp
mov    %rdx,(%rsp)
mov    %esi,%r15d
mov    %rdi,%r14
mov    0x50(%rsp),%r9d
mov    0x48(%rsp),%ebx
mov    0x40(%rsp),%ecx
mov    %esi,%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %ebx,%r8d
call   1040 <bounds_check@plt>
test   %rax,%rax
js     11ac <convolve_real+0x7c>
lea    0x0(,%rbx,8),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    (%rsp),%rdx
mov    %ebp,%ecx
mov    %r12,%r8
mov    %r13d,%r9d
mov    0x58(%rsp),%eax
push   %rax
mov    0x58(%rsp),%eax
push   %rax
push   %rbx
mov    0x58(%rsp),%eax
push   %rax
call   1050 <_base_convolve_real@plt>
add    $0x20,%rsp
jmp    11b1 <convolve_real+0x81>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @convolve_real(float* %0, i32 %1, float* %2, i32 %3, float* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
%14 = alloca float*
%15 = alloca i32
%16 = alloca float*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca void (float*, float*, float*, i32)*
%23 = alloca void (float*, float*, float*, i32, i32)*
store float* %0, float** %12
store i32 %1, i32* %13
store float* %2, float** %14
store i32 %3, i32* %15
store float* %4, float** %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
store void (float*, float*, float*, i32)* null, void (float*, float*, float*, i32)** %22
store void (float*, float*, float*, i32, i32)* null, void (float*, float*, float*, i32, i32)** %23
%24 = load i32, i32* %13
%25 = load i32, i32* %15
%26 = load i32, i32* %17
%27 = load i32, i32* %18
%28 = load i32, i32* %19
%29 = load i32, i32* %20
%30 = call i64 @bounds_check(i32 %24, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %10
store i32 -1, i32* %11
br label %90
33: ; preds = %10
%34 = load float*, float** %16
%35 = load i32, i32* %19
%36 = mul nsw i32 %35, 2
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i32 @memset(float* %34, i32 0, i32 %39)
%41 = load void (float*, float*, float*, i32)*, void (float*, float*, float*, i32)** %22
%42 = icmp ne void (float*, float*, float*, i32)* %41, null
br i1 %42, label %43, label %57
43: ; preds = %33
%44 = load void (float*, float*, float*, i32)*, void (float*, float*, float*, i32)** %22
%45 = load float*, float** %12
%46 = load i32, i32* %15
%47 = sub nsw i32 %46, 1
%48 = sub nsw i32 0, %47
%49 = load i32, i32* %18
%50 = add nsw i32 %48, %49
%51 = mul nsw i32 2, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %45, i64 %52
%54 = load float*, float** %14
%55 = load float*, float** %16
%56 = load i32, i32* %19
br label %88
57: ; preds = %33
%58 = load void (float*, float*, float*, i32, i32)*, void (float*, float*, float*, i32, i32)** %23
%59 = icmp ne void (float*, float*, float*, i32, i32)* %58, null
br i1 %59, label %60, label %75
60: ; preds = %57
%61 = load void (float*, float*, float*, i32, i32)*, void (float*, float*, float*, i32, i32)** %23
%62 = load float*, float** %12
%63 = load i32, i32* %15
%64 = sub nsw i32 %63, 1
%65 = sub nsw i32 0, %64
%66 = load i32, i32* %18
%67 = add nsw i32 %65, %66
%68 = mul nsw i32 2, %67
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds float, float* %62, i64 %69
%71 = load float*, float** %14
%72 = load float*, float** %16
%73 = load i32, i32* %15
%74 = load i32, i32* %19
br label %87
75: ; preds = %57
%76 = load float*, float** %12
%77 = load i32, i32* %13
%78 = load float*, float** %14
%79 = load i32, i32* %15
%80 = load float*, float** %16
%81 = load i32, i32* %17
%82 = load i32, i32* %18
%83 = load i32, i32* %19
%84 = load i32, i32* %20
%85 = load i32, i32* %21
%86 = call i32 @_base_convolve_real(float* %76, i32 %77, float* %78, i32 %79, float* %80, i32 %81, i32 %82, i32 %83, i32 %84, i32 %85)
br label %87
87: ; preds = %75, %60
br label %88
88: ; preds = %87, %43
%89 = load i32, i32* %19
store i32 %89, i32* %11
br label %90
90: ; preds = %88, %32
%91 = load i32, i32* %11
ret i32 %91
}

LLVM IR (-O2):
define i32 @convolve_real(float* %0, i32 %1, float* %2, i32 %3, float* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = tail call i64 @bounds_check(i32 %1, i32 %3, i32 %5, i32 %6, i32 %7, i32 %8)
%12 = icmp slt i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = shl i32 %7, 3
%15 = tail call i32 @memset(float* %4, i32 0, i32 %14)
%16 = tail call i32 @_base_convolve_real(float* %0, i32 %1, float* %2, i32 %3, float* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9)
br label %17
17: ; preds = %10, %13
%18 = phi i32 [ %7, %13 ], [ -1, %10 ]
ret i32 %18
}