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


x86 assembly (clang, -O0):
<convolve_complex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
call   1040 <bounds_check@plt>
cmp    $0x0,%rax
jge    1187 <convolve_complex+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    1213 <convolve_complex+0xe3>
mov    -0x30(%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,-0x40(%rbp)
je     11e3 <convolve_complex+0xb3>
mov    -0x40(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x24(%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    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    0x18(%rbp),%r8d
call   *%rax
jmp    120d <convolve_complex+0xdd>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <_base_convolve_complex@plt>
mov    0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolve_complex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,(%rsp)
mov    %esi,%r15d
mov    %rdi,%r13
mov    0x48(%rsp),%ebx
mov    0x40(%rsp),%ecx
mov    %esi,%edi
mov    %ebp,%esi
mov    %r9d,%edx
mov    %ebx,%r8d
call   1040 <bounds_check@plt>
test   %rax,%rax
js     119d <convolve_complex+0x6d>
lea    0x0(,%rbx,8),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%rdx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %r12d,%r9d
push   %rbx
mov    0x48(%rsp),%eax
push   %rax
call   1050 <_base_convolve_complex@plt>
add    $0x10,%rsp
jmp    11a2 <convolve_complex+0x72>
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_complex(float* %0, i32 %1, float* %2, i32 %3, float* %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
%14 = alloca float*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca void (float*, float*, float*, i32, i32)*
store float* %0, float** %10
store i32 %1, i32* %11
store float* %2, float** %12
store i32 %3, i32* %13
store float* %4, float** %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store void (float*, float*, float*, i32, i32)* null, void (float*, float*, float*, i32, i32)** %18
%19 = load i32, i32* %11
%20 = load i32, i32* %13
%21 = load i32, i32* %15
%22 = load i32, i32* %16
%23 = load i32, i32* %17
%24 = call i64 @bounds_check(i32 %19, i32 %20, i32 %21, i32 %22, i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %8
store i32 -1, i32* %9
br label %64
27: ; preds = %8
%28 = load float*, float** %14
%29 = load i32, i32* %17
%30 = mul nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 4
%33 = trunc i64 %32 to i32
%34 = call i32 @memset(float* %28, i32 0, i32 %33)
%35 = load void (float*, float*, float*, i32, i32)*, void (float*, float*, float*, i32, i32)** %18
%36 = icmp ne void (float*, float*, float*, i32, i32)* %35, null
br i1 %36, label %37, label %52
37: ; preds = %27
%38 = load void (float*, float*, float*, i32, i32)*, void (float*, float*, float*, i32, i32)** %18
%39 = load float*, float** %10
%40 = load i32, i32* %13
%41 = sub nsw i32 %40, 1
%42 = sub nsw i32 0, %41
%43 = load i32, i32* %16
%44 = add nsw i32 %42, %43
%45 = mul nsw i32 2, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds float, float* %39, i64 %46
%48 = load float*, float** %12
%49 = load float*, float** %14
%50 = load i32, i32* %13
%51 = load i32, i32* %17
br label %62
52: ; preds = %27
%53 = load float*, float** %10
%54 = load i32, i32* %11
%55 = load float*, float** %12
%56 = load i32, i32* %13
%57 = load float*, float** %14
%58 = load i32, i32* %15
%59 = load i32, i32* %16
%60 = load i32, i32* %17
%61 = call i32 @_base_convolve_complex(float* %53, i32 %54, float* %55, i32 %56, float* %57, i32 %58, i32 %59, i32 %60)
br label %62
62: ; preds = %52, %37
%63 = load i32, i32* %17
store i32 %63, i32* %9
br label %64
64: ; preds = %62, %26
%65 = load i32, i32* %9
ret i32 %65
}

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