#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 */
double *calloc(size_t, int);
int /*<<< orphan*/ convolutions_convolve(double *, size_t, double const *,
                                         size_t, double *);
int /*<<< orphan*/ convolutions_shrink(double *, size_t, size_t);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memcpy(double *, double const *, size_t);
int convolutions_convolve_shrink(const double first[], size_t first_len,
                                 const double second[], size_t second_len,
                                 size_t delta_second, double convolved[]) {
  double *first_copy;
  if (delta_second > first_len + second_len) {
    return 0;
  }
  first_copy = calloc(first_len, sizeof(double));
  if (!first_copy)
    return 0;
  memcpy(first_copy, first, first_len * sizeof(double));
  convolutions_shrink(first_copy, first_len, delta_second);
  convolutions_convolve(first_copy, first_len, second, second_len, convolved);
  free(first_copy);
  return 1;
}


x86 assembly (clang, -O0):
<convolutions_convolve_shrink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jbe    1191 <convolutions_convolve_shrink+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1209 <convolutions_convolve_shrink+0xb9>
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11ba <convolutions_convolve_shrink+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    1209 <convolutions_convolve_shrink+0xb9>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
shl    $0x3,%rdx
call   1050 <memcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1070 <convolutions_shrink@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1060 <convolutions_convolve@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolutions_convolve_shrink>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    (%rcx,%rsi,1),%rax
xor    %r15d,%r15d
cmp    %r8,%rax
jb     11dc <convolutions_convolve_shrink+0x8c>
mov    %r8,%r13
mov    %rcx,%r12
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,0x8(%rsp)
mov    %r9,0x10(%rsp)
mov    %rsi,%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     11dc <convolutions_convolve_shrink+0x8c>
mov    %rax,%rbp
lea    0x0(,%rbx,8),%rdx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <memcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <convolutions_shrink@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    0x8(%rsp),%rdx
mov    %r12,%rcx
mov    0x10(%rsp),%r8
call   1060 <convolutions_convolve@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @convolutions_convolve_shrink(double* %0, i64 %1, double* %2, i64 %3, i64 %4, double* %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca i64
%10 = alloca double*
%11 = alloca i64
%12 = alloca i64
%13 = alloca double*
%14 = alloca double*
store double* %0, double** %8
store i64 %1, i64* %9
store double* %2, double** %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store double* %5, double** %13
%15 = load i64, i64* %12
%16 = load i64, i64* %9
%17 = load i64, i64* %11
%18 = add i64 %16, %17
%19 = icmp ugt i64 %15, %18
br i1 %19, label %20, label %21
20: ; preds = %6
store i32 0, i32* %7
br label %45
21: ; preds = %6
%22 = load i64, i64* %9
%23 = call double* @calloc(i64 %22, i32 8)
store double* %23, double** %14
%24 = load double*, double** %14
%25 = icmp ne double* %24, null
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 0, i32* %7
br label %45
27: ; preds = %21
%28 = load double*, double** %14
%29 = load double*, double** %8
%30 = load i64, i64* %9
%31 = mul i64 %30, 8
%32 = call i32 @memcpy(double* %28, double* %29, i64 %31)
%33 = load double*, double** %14
%34 = load i64, i64* %9
%35 = load i64, i64* %12
%36 = call i32 @convolutions_shrink(double* %33, i64 %34, i64 %35)
%37 = load double*, double** %14
%38 = load i64, i64* %9
%39 = load double*, double** %10
%40 = load i64, i64* %11
%41 = load double*, double** %13
%42 = call i32 @convolutions_convolve(double* %37, i64 %38, double* %39, i64 %40, double* %41)
%43 = load double*, double** %14
%44 = call i32 @free(double* %43)
store i32 1, i32* %7
br label %45
45: ; preds = %27, %26, %20
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
define i32 @convolutions_convolve_shrink(double* %0, i64 %1, double* %2, i64 %3, i64 %4, double* %5) {
%7 = add i64 %3, %1
%8 = icmp ult i64 %7, %4
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call double* @calloc(i64 %1, i32 8)
%11 = icmp eq double* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = shl i64 %1, 3
%14 = tail call i32 @memcpy(double* %10, double* %0, i64 %13)
%15 = tail call i32 @convolutions_shrink(double* %10, i64 %1, i64 %4)
%16 = tail call i32 @convolutions_convolve(double* %10, i64 %1, double* %2, i64 %3, double* %5)
%17 = tail call i32 @free(double* %10)
br label %18
18: ; preds = %9, %6, %12
%19 = phi i32 [ 1, %12 ], [ 0, %6 ], [ 0, %9 ]
ret i32 %19
}