#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 **permute(int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int a[4] = {1, 2, 3, 4};
  int **sa, size;
  sa = permute(a, 4, &size);
  for (int i = 0; i < size; printf("\n"), i++)
    for (int j = 0; j < 4; printf("%d ", sa[i][j]), j++) {
    }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
lea    -0x2c(%rbp),%rdx
call   1030 <permute@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11db <main+0xbb>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11ba <main+0x9a>
jmp    118b <main+0x6b>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117c <main+0x5c>
jmp    11bf <main+0x9f>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1169 <main+0x49>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0x4,%esi
call   1040 <permute@plt>
cmpl   $0x0,0xc(%rsp)
jle    11cb <main+0x9b>
mov    %rax,%r15
lea    0xea6(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15,%rbx,8),%rax
mov    0x4(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15,%rbx,8),%rax
mov    0x8(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15,%rbx,8),%rax
mov    0xc(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1170 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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