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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int);
int **threeSum(int *, int, int *);
int main(void) {
  int x[] = {-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6};
  int i;
  int **res;
  res = threeSum(x, sizeof(x) / sizeof(int), &i);
  while (i-- > 0)
    printf("%d %d %d\n", res[i][0], res[i][1], res[i][2]);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x3c,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0xf,%esi
lea    -0x44(%rbp),%rdx
call   1050 <threeSum@plt>
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x44(%rbp)
cmp    $0x0,%eax
jle    11bb <main+0x8b>
mov    -0x50(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
mov    -0x50(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x4(%rax),%edx
mov    -0x50(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x8(%rax),%ecx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    116a <main+0x3a>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movups 0xefe(%rip),%xmm0
movups %xmm0,0x3c(%rsp)
movaps 0xee6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0xf,%esi
call   1040 <threeSum@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
test   %ecx,%ecx
jle    11b5 <main+0x95>
lea    0xeb8(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%eax
mov    (%rbx,%rax,8),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
test   %ecx,%ecx
jg     1190 <main+0x70>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@__const.main.x = [15 x i32] [i32 -4, i32 -2, i32 -2, i32 -2, i32 0, i32 1, i32 2, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 6, i32 6]
@.str = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
%1 = alloca [15 x i32]
%2 = alloca i32
%3 = bitcast [15 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [15 x i32], [15 x i32]* %1, i64 0, i64 0
%6 = call i32** @threeSum(i32* %5, i32 15, i32* %2)
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %24
10: ; preds = %0, %10
%11 = phi i32 [ %22, %10 ], [ %8, %0 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i32*, i32** %6, 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 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17, i32 %19)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
%23 = icmp sgt i32 %21, 0
br i1 %23, label %10, label %24
24: ; preds = %10, %0
ret i32 0
}