#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*/ nums;

/* Variables and functions */
int **fourSum(int *, int, int, int *, int **);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(void) {
  int i, count, target = 11, *col_sizes;
  int nums[] = {0, 1, 5, 0, 1, 5, 5, -4};
  int **quadruplets =
      fourSum(nums, sizeof(nums) / sizeof(*nums), target, &count, &col_sizes);
  for (i = 0; i < count; i++) {
    printf("%d %d %d %d\n", quadruplets[i][0], quadruplets[i][1],
           quadruplets[i][2], quadruplets[i][3]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xb,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    $0x8,%esi
lea    -0xc(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1040 <fourSum@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e8 <main+0xc8>
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x4(%rax),%edx
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x8(%rax),%ecx
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rdi
mov    (%rax,%rdi,8),%rax
mov    0xc(%rax),%r8d
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1186 <main+0x66>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x8,%esi
mov    $0xb,%edx
call   1040 <fourSum@plt>
cmpl   $0x0,0x4(%rsp)
jle    11a6 <main+0x86>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xeae(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1180 <main+0x60>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.nums = [8 x i32] [i32 0, i32 1, i32 5, i32 0, i32 1, i32 5, i32 5, i32 -4]
@.str = [13 x i8] c"%d %d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [8 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32** %2 to i8*
%6 = bitcast [8 x i32]* %3 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%8 = call i32** @fourSum(i32* %7, i32 8, i32 11, i32* %1, i32** %2)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %0, %11
%12 = phi i64 [ %23, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds i32*, i32** %8, i64 %12
%14 = load i32*, i32** %13
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %14, i64 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %14, i64 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds i32, i32* %14, i64 3
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17, i32 %19, i32 %21)
%23 = add nuw nsw i64 %12, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %11, label %27
27: ; preds = %11, %0
ret i32 0
}