#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int **fourSum(int *, int, int, int *);
int /*<<< orphan*/ printf(char *, int, ...);
void fourSumMain(void) {
  int len = 0;
  int array[] = {-7, -4, -6, 6,  4, -6, -9, -10, -7, 5,  3,  -1, -5, 8,
                 -1, -2, -8, -1, 5, -3, -5, 4,   2,  -5, -4, 4,  7};
  { len = sizeof(array) / sizeof(array[0]); };
  int returnSize = 0;
  int **result = fourSum(array, len, 4, &returnSize);
  int i = 0;
  for (i = 0; i < returnSize; i++) {
    printf("%d %d %d %d\n", *(*(result + i) + 0), *(*(result + i) + 1),
           *(*(result + i) + 2), *(*(result + i) + 3));
  }
  while (len) {
    printf("%d\n", array[len - 1]);
    len--;
  }
}


x86 assembly (clang, -O0):
<fourSumMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x6c,%edx
call   1040 <memcpy@plt>
movl   $0x1b,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x4,%edx
lea    -0x74(%rbp),%rcx
call   1050 <fourSum@plt>
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    120b <fourSumMain+0xdb>
mov    -0x80(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
mov    -0x80(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x4(%rax),%edx
mov    -0x80(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x8(%rax),%ecx
mov    -0x80(%rbp),%rax
movslq -0x84(%rbp),%rdi
mov    (%rax,%rdi,8),%rax
mov    0xc(%rax),%r8d
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1192 <fourSumMain+0x62>
jmp    1210 <fourSumMain+0xe0>
cmpl   $0x0,-0x4(%rbp)
je     1242 <fourSumMain+0x112>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x70(%rbp,%rax,4),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <fourSumMain+0xe0>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fourSumMain>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
movups 0xf29(%rip),%xmm0
movups %xmm0,0x6c(%rsp)
movaps 0xf11(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xef5(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x1b,%esi
mov    $0x4,%edx
call   1040 <fourSum@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e8 <fourSumMain+0xc8>
mov    %rax,%r15
lea    0xeba(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <fourSumMain+0xa0>
mov    0x78(%rsp),%esi
lea    0xe82(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x74(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x70(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x6c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x68(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x64(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x60(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x5c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x58(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x54(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x50(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.fourSumMain.array = [27 x i32] [i32 -7, i32 -4, i32 -6, i32 6, i32 4, i32 -6, i32 -9, i32 -10, i32 -7, i32 5, i32 3, i32 -1, i32 -5, i32 8, i32 -1, i32 -2, i32 -8, i32 -1, i32 5, i32 -3, i32 -5, i32 4, i32 2, i32 -5, i32 -4, i32 4, i32 7]
@.str = [13 x i8] c"%d %d %d %d\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @fourSumMain() {
%1 = alloca i32
%2 = alloca [27 x i32]
%3 = alloca i32
%4 = alloca i32**
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [27 x i32]* %2 to i8*
store i32 27, i32* %1
store i32 0, i32* %3
%7 = getelementptr inbounds [27 x i32], [27 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %1
%9 = call i32** @fourSum(i32* %7, i32 %8, i32 4, i32* %3)
store i32** %9, i32*** %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %10
10: ; preds = %44, %0
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %47
14: ; preds = %10
%15 = load i32**, i32*** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
%19 = load i32*, i32** %18
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = load i32**, i32*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32*, i32** %22, i64 %24
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = load i32, i32* %27
%29 = load i32**, i32*** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32*, i32** %29, i64 %31
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 2
%35 = load i32, i32* %34
%36 = load i32**, i32*** %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 3
%42 = load i32, i32* %41
%43 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %28, i32 %35, i32 %42)
br label %44
44: ; preds = %14
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %10
47: ; preds = %10
br label %48
48: ; preds = %51, %47
%49 = load i32, i32* %1
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %48
%52 = load i32, i32* %1
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [27 x i32], [27 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %1
%59 = add nsw i32 %58, -1
store i32 %59, i32* %1
br label %48
60: ; preds = %48
ret void
}

LLVM IR (-O2):
@__const.fourSumMain.array = [27 x i32] [i32 -7, i32 -4, i32 -6, i32 6, i32 4, i32 -6, i32 -9, i32 -10, i32 -7, i32 5, i32 3, i32 -1, i32 -5, i32 8, i32 -1, i32 -2, i32 -8, i32 -1, i32 5, i32 -3, i32 -5, i32 4, i32 2, i32 -5, i32 -4, i32 4, i32 7]
@.str = [13 x i8] c"%d %d %d %d\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @fourSumMain() {
%1 = alloca [27 x i32]
%2 = alloca i32
%3 = bitcast [27 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 0
%6 = call i32** @fourSum(i32* %5, i32 27, i32 4, i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %90, label %9
9: ; preds = %90, %0
%10 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 26
%11 = load i32, i32* %10
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 25
%14 = load i32, i32* %13
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 24
%17 = load i32, i32* %16
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 23
%20 = load i32, i32* %19
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 22
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 21
%26 = load i32, i32* %25
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 20
%29 = load i32, i32* %28
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 19
%32 = load i32, i32* %31
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 18
%35 = load i32, i32* %34
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 17
%38 = load i32, i32* %37
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 16
%41 = load i32, i32* %40
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 15
%44 = load i32, i32* %43
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 14
%47 = load i32, i32* %46
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 13
%50 = load i32, i32* %49
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 12
%53 = load i32, i32* %52
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 11
%56 = load i32, i32* %55
%57 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 10
%59 = load i32, i32* %58
%60 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 9
%62 = load i32, i32* %61
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 8
%65 = load i32, i32* %64
%66 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 7
%68 = load i32, i32* %67
%69 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 6
%71 = load i32, i32* %70
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 5
%74 = load i32, i32* %73
%75 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 4
%77 = load i32, i32* %76
%78 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %77)
%79 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 3
%80 = load i32, i32* %79
%81 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %80)
%82 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 2
%83 = load i32, i32* %82
%84 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds [27 x i32], [27 x i32]* %1, i64 0, i64 1
%86 = load i32, i32* %85
%87 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %86)
%88 = load i32, i32* %5
%89 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %88)
ret void
90: ; preds = %0, %90
%91 = phi i64 [ %102, %90 ], [ 0, %0 ]
%92 = getelementptr inbounds i32*, i32** %6, i64 %91
%93 = load i32*, i32** %92
%94 = load i32, i32* %93
%95 = getelementptr inbounds i32, i32* %93, i64 1
%96 = load i32, i32* %95
%97 = getelementptr inbounds i32, i32* %93, i64 2
%98 = load i32, i32* %97
%99 = getelementptr inbounds i32, i32* %93, i64 3
%100 = load i32, i32* %99
%101 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %94, i32 %96, i32 %98, i32 %100)
%102 = add nuw nsw i64 %91, 1
%103 = load i32, i32* %2
%104 = sext i32 %103 to i64
%105 = icmp slt i64 %102, %104
br i1 %105, label %90, label %9
}