#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*/ differenceSequenceRecurse(int *, int, int *);
scalar_t__ malloc(int);
int *differenceSequence(int array[], int n, int count) {
  int *resultArray = (int *)malloc(sizeof(int) * n);
  if (n == 0 && count == 0) {
    resultArray[n] = -1 * array[n];
    return resultArray;
  }
  differenceSequenceRecurse(array, n, resultArray);
  return resultArray;
}


x86 assembly (clang, -O0):
<differenceSequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1180 <differenceSequence+0x60>
cmpl   $0x0,-0x18(%rbp)
jne    1180 <differenceSequence+0x60>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xffffffff,(%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <differenceSequence+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <differenceSequenceRecurse@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<differenceSequence>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x0(,%rbx,4),%edi
call   1030 <malloc@plt>
mov    %rax,%r15
or     %ebx,%ebp
je     1150 <differenceSequence+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1040 <differenceSequenceRecurse@plt>
jmp    115d <differenceSequence+0x3d>
movslq %ebx,%rax
xor    %ecx,%ecx
sub    (%r14,%rax,4),%ecx
mov    %ecx,(%r15,%rax,4)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @differenceSequence(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = mul i64 4, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %8
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %32
17: ; preds = %3
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = mul nsw i32 -1, %25
%27 = load i32*, i32** %8
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
%31 = load i32*, i32** %8
store i32* %31, i32** %4
br label %38
32: ; preds = %17, %3
%33 = load i32*, i32** %5
%34 = load i32, i32* %6
%35 = load i32*, i32** %8
%36 = call i32 @differenceSequenceRecurse(i32* %33, i32 %34, i32* %35)
%37 = load i32*, i32** %8
store i32* %37, i32** %4
br label %38
38: ; preds = %32, %20
%39 = load i32*, i32** %4
ret i32* %39
}

LLVM IR (-O2):
define i32* @differenceSequence(i32* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = shl i32 %1, 2
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = or i32 %2, %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = getelementptr inbounds i32, i32* %0, i64 %4
%12 = load i32, i32* %11
%13 = sub nsw i32 0, %12
%14 = getelementptr inbounds i32, i32* %7, i64 %4
store i32 %13, i32* %14
br label %17
15: ; preds = %3
%16 = tail call i32 @differenceSequenceRecurse(i32* %0, i32 %1, i32* %7)
br label %17
17: ; preds = %15, %10
ret i32* %7
}