#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void convertPermutation(uint8_t len, const uint8_t *P, const char *name,
                        uint8_t lineLength) {
  printf("static const uint8_t %s[] =\n", name);
  printf("{\n");
  for (uint8_t i = 0; i < len;) {
    printf("\t");
    for (uint8_t j = 0; j < lineLength; j++, i++)
      printf("%2d, ", P[i] - 1);
    printf("\t\n");
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<convertPermutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11d0 <convertPermutation+0xc0>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11bd <convertPermutation+0xad>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
sub    $0x1,%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1174 <convertPermutation+0x64>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1150 <convertPermutation+0x40>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertPermutation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xeb5(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,(%rsp)
test   %rbp,%rbp
jle    11dd <convertPermutation+0xad>
test   %r14,%r14
mov    $0x0,%ebp
cmovg  %r14,%rbp
shl    $0x3,%rbp
lea    0xe9c(%rip),%r12
xor    %r13d,%r13d
jmp    11a5 <convertPermutation+0x75>
cs nopw 0x0(%rax,%rax,1)
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
add    %rbp,%rbx
cmp    (%rsp),%r13
jge    11dd <convertPermutation+0xad>
mov    $0x9,%edi
call   1030 <putchar@plt>
test   %r14,%r14
jle    1190 <convertPermutation+0x60>
add    %r14,%r13
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r15,8),%rsi
add    $0xffffffffffffffff,%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    11c0 <convertPermutation+0x90>
jmp    1190 <convertPermutation+0x60>
lea    0xe41(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str = [29 x i8] c"static const uint8_t %s[] =\0A\00"
@.str.3 = [6 x i8] c"%2d, \00"
@str = [2 x i8] c"{\00"
@str.6 = [3 x i8] c"};\00"
@str.7 = [2 x i8] c"\09\00"
define void @convertPermutation(i64 %0, i64* nocapture %1, i8* %2, i64 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%7 = icmp sgt i64 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = icmp sgt i64 %3, 0
br label %12
10: ; preds = %17, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0))
ret void
12: ; preds = %8, %17
%13 = phi i64 [ 0, %8 ], [ %18, %17 ]
%14 = tail call i32 @putchar(i32 9)
br i1 %9, label %15, label %17
15: ; preds = %12
%16 = add i64 %13, %3
br label %21
17: ; preds = %21, %12
%18 = phi i64 [ %13, %12 ], [ %16, %21 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%20 = icmp slt i64 %18, %0
br i1 %20, label %12, label %10
21: ; preds = %15, %21
%22 = phi i64 [ %27, %21 ], [ %13, %15 ]
%23 = getelementptr inbounds i64, i64* %1, i64 %22
%24 = load i64, i64* %23
%25 = add nsw i64 %24, -1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %25)
%27 = add i64 %22, 1
%28 = icmp eq i64 %27, %16
br i1 %28, label %17, label %21
}