#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*/ print_perm(int *, int, int);
int /*<<< orphan*/ printf(char *);
void print_array_perm(int *perms, int m, int n, int nl) {
  int j;
  printf("{");
  if (nl)
    printf("\n");
  for (j = 0; j < m; j++) {
    printf(" ");
    print_perm(perms + j * n, n, nl);
  }
  if (nl)
    printf("}\n");
  else
    printf(" }\n");
}


x86 assembly (clang, -O0):
<print_array_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1157 <print_array_perm+0x37>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <print_array_perm+0x83>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <print_perm@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <print_array_perm+0x3e>
cmpl   $0x0,-0x14(%rbp)
je     11be <print_array_perm+0x9e>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
jmp    11ca <print_array_perm+0xaa>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array_perm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
mov    $0x7b,%edi
call   1030 <putchar@plt>
test   %r12d,%r12d
je     1160 <print_array_perm+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    1191 <print_array_perm+0x61>
movslq %r14d,%r13
mov    %r15d,%ebx
shl    $0x2,%r13
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
call   1050 <print_perm@plt>
add    %r13,%rbp
add    $0xffffffffffffffff,%rbx
jne    1170 <print_array_perm+0x40>
test   %r12d,%r12d
lea    0xe65(%rip),%rax
lea    0xe5f(%rip),%rdi
cmove  %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@str = [3 x i8] c" }\00"
@str.5 = [2 x i8] c"}\00"
define void @print_array_perm(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @putchar(i32 123)
%6 = icmp eq i32 %3, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @putchar(i32 10)
br label %9
9: ; preds = %7, %4
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %22
11: ; preds = %9
%12 = sext i32 %2 to i64
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %20, %14 ]
%16 = tail call i32 @putchar(i32 32)
%17 = mul nsw i64 %15, %12
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = tail call i32 @print_perm(i32* %18, i32 %2, i32 %3)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %9
%23 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0)
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret void
}