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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void output_perm(int n, int *perm, FILE *f) {
  int i;
  fprintf(f, "\nPermutation array:\n");
  for (i = 0; i < n; i++) {
    fprintf(f, "%6d ", perm[i]);
    if ((i + 1) % 10 == 0)
      fprintf(f, "\n");
  }
  fprintf(f, "\n");
  fflush(f);
}


x86 assembly (clang, -O0):
<output_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b1 <output_perm+0x91>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119e <output_perm+0x7e>
mov    -0x18(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a3 <output_perm+0x83>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <output_perm+0x2c>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_perm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,(%rsp)
mov    %edi,%ebp
lea    0xea5(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1060 <fwrite@plt>
test   %ebp,%ebp
jle    11e2 <output_perm+0xa2>
mov    %ebp,%r12d
shl    $0x2,%r12
mov    $0xffffffff,%ebp
mov    $0x1,%ebx
xor    %r15d,%r15d
jmp    119f <output_perm+0x5f>
nopw   0x0(%rax,%rax,1)
add    $0x4,%r15
add    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    %r15,%r12
je     11e2 <output_perm+0xa2>
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%r14d
add    %r14d,%r14d
mov    (%rsp),%rax
mov    (%rax,%r15,1),%edx
mov    %r13,%rdi
lea    0xe4e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    %ebp,%r14d
jne    1190 <output_perm+0x50>
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
jmp    1190 <output_perm+0x50>
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

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

LLVM IR (-O2):
@.str = [21 x i8] c"\0APermutation array:\0A\00"
@.str.1 = [5 x i8] c"%6d \00"
define void @output_perm(i32 %0, i32* nocapture %1, i32* nocapture %2) {
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 20, i64 1, i32* %2)
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ 0, %6 ], [ %13, %19 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %9, 1
%14 = trunc i64 %13 to i32
%15 = urem i32 %14, 10
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @fputc(i32 10, i32* %2)
br label %19
19: ; preds = %8, %17
%20 = icmp eq i64 %13, %7
br i1 %20, label %21, label %8
21: ; preds = %19, %3
%22 = tail call i32 @fputc(i32 10, i32* %2)
%23 = tail call i32 @fflush(i32* %2)
ret void
}