#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*/ invers(int);
int /*<<< orphan*/ lexperms(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, aux = 0, i;
  printf("Introduzca el tamaño de la matriz\n");
  scanf("%d", &a);
  aux = a + 1;
  int P[a];
  for (i = 0; i < aux; i++) {
    P[i] = i;
  }
  lexperms(P, (aux - 1));
  read((aux - 1));
  printf("Las permutaciones y el numero de inversiones son:\n");
  invers(aux - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e1 <main+0x91>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%edx
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b9 <main+0x69>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1060 <lexperms@plt>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1040 <read@plt>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1050 <invers@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xf32(%rip),%rdi
call   1030 <puts@plt>
lea    0xf23(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r14
mov    -0x1c(%rbp),%r15d
mov    %rsp,%rdi
lea    0xf(,%r15,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
test   %r15d,%r15d
js     130c <main+0x1bc>
lea    0x1(%r15),%rax
cmp    $0x7,%r15d
jae    11ac <main+0x5c>
xor    %ecx,%ecx
jmp    1300 <main+0x1b0>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%rbx
mov    %rbx,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%rbx
jae    11da <main+0x8a>
movdqa 0xe2d(%rip),%xmm0
xor    %ebx,%ebx
jmp    12a8 <main+0x158>
and    $0xfffffffffffffffc,%rsi
movdqa 0xe1a(%rip),%xmm0
xor    %ebx,%ebx
movdqa 0xe1f(%rip),%xmm8
movdqa 0xe26(%rip),%xmm9
movdqa 0xe2d(%rip),%xmm10
movdqa 0xe35(%rip),%xmm4
movdqa 0xe3d(%rip),%xmm5
movdqa 0xe45(%rip),%xmm6
movdqa 0xe4d(%rip),%xmm7
movdqa 0xe55(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqa %xmm0,(%rdi,%rbx,4)
movdqa %xmm2,0x10(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqa %xmm2,0x20(%rdi,%rbx,4)
movdqa %xmm3,0x30(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqa %xmm2,0x40(%rdi,%rbx,4)
movdqa %xmm3,0x50(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqa %xmm2,0x60(%rdi,%rbx,4)
movdqa %xmm3,0x70(%rdi,%rbx,4)
add    $0x20,%rbx
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rsi
jne    1230 <main+0xe0>
test   %rdx,%rdx
je     12f0 <main+0x1a0>
lea    (%rdi,%rbx,4),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %ebx,%ebx
movdqa 0xd4d(%rip),%xmm1
movdqa 0xd55(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
movdqa %xmm0,-0x10(%rsi,%rbx,1)
movdqa %xmm3,(%rsi,%rbx,1)
paddd  %xmm2,%xmm0
add    $0x20,%rbx
cmp    %rbx,%rdx
jne    12d0 <main+0x180>
cmp    %rax,%rcx
je     130c <main+0x1bc>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,(%rdi,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1300 <main+0x1b0>
mov    %r15d,%esi
call   1060 <lexperms@plt>
mov    %r15d,%edi
call   1040 <read@plt>
lea    0xd93(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
call   1050 <invers@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Introduzca el tama\C3\B1o de la matriz\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Las permutaciones y el numero de inversiones son:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i32, i64 %12
store i64 %12, i64* %6
store i32 0, i32* %4
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %14, i64 %22
store i32 %20, i32* %23
br label %24
24: ; preds = %19
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %15
27: ; preds = %15
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 1
%30 = call i32 @lexperms(i32* %14, i32 %29)
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = call i32 @read(i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %3
%36 = sub nsw i32 %35, 1
%37 = call i32 @invers(i32 %36)
store i32 0, i32* %1
%38 = load i8*, i8** %5
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [35 x i8] c"Introduzca el tama\C3\B1o de la matriz\00"
@str.3 = [50 x i8] c"Las permutaciones y el numero de inversiones son:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = icmp slt i32 %5, 0
br i1 %9, label %84, label %10
10: ; preds = %0
%11 = add nuw i32 %5, 1
%12 = zext i32 %11 to i64
%13 = icmp ult i32 %5, 7
br i1 %13, label %76, label %14
14: ; preds = %10
%15 = and i64 %12, 4294967288
%16 = add nsw i64 %15, -8
%17 = lshr exact i64 %16, 3
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 3
%20 = icmp ult i64 %16, 24
br i1 %20, label %57, label %21
21: ; preds = %14
%22 = and i64 %18, 4611686018427387900
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %53, %23 ]
%25 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %21 ], [ %54, %23 ]
%26 = phi i64 [ 0, %21 ], [ %55, %23 ]
%27 = add <4 x i32> %25, <i32 4, i32 4, i32 4, i32 4>
%28 = getelementptr inbounds i32, i32* %8, i64 %24
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %31
%32 = or i64 %24, 8
%33 = add <4 x i32> %25, <i32 8, i32 8, i32 8, i32 8>
%34 = add <4 x i32> %25, <i32 12, i32 12, i32 12, i32 12>
%35 = getelementptr inbounds i32, i32* %8, i64 %32
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %38
%39 = or i64 %24, 16
%40 = add <4 x i32> %25, <i32 16, i32 16, i32 16, i32 16>
%41 = add <4 x i32> %25, <i32 20, i32 20, i32 20, i32 20>
%42 = getelementptr inbounds i32, i32* %8, i64 %39
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %43
%44 = getelementptr inbounds i32, i32* %42, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %45
%46 = or i64 %24, 24
%47 = add <4 x i32> %25, <i32 24, i32 24, i32 24, i32 24>
%48 = add <4 x i32> %25, <i32 28, i32 28, i32 28, i32 28>
%49 = getelementptr inbounds i32, i32* %8, i64 %46
%50 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> %47, <4 x i32>* %50
%51 = getelementptr inbounds i32, i32* %49, i64 4
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %52
%53 = add nuw i64 %24, 32
%54 = add <4 x i32> %25, <i32 32, i32 32, i32 32, i32 32>
%55 = add i64 %26, 4
%56 = icmp eq i64 %55, %22
br i1 %56, label %57, label %23
57: ; preds = %23, %14
%58 = phi i64 [ 0, %14 ], [ %53, %23 ]
%59 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %14 ], [ %54, %23 ]
%60 = icmp eq i64 %19, 0
br i1 %60, label %74, label %61
61: ; preds = %57, %61
%62 = phi i64 [ %70, %61 ], [ %58, %57 ]
%63 = phi <4 x i32> [ %71, %61 ], [ %59, %57 ]
%64 = phi i64 [ %72, %61 ], [ 0, %57 ]
%65 = add <4 x i32> %63, <i32 4, i32 4, i32 4, i32 4>
%66 = getelementptr inbounds i32, i32* %8, i64 %62
%67 = bitcast i32* %66 to <4 x i32>*
store <4 x i32> %63, <4 x i32>* %67
%68 = getelementptr inbounds i32, i32* %66, i64 4
%69 = bitcast i32* %68 to <4 x i32>*
store <4 x i32> %65, <4 x i32>* %69
%70 = add nuw i64 %62, 8
%71 = add <4 x i32> %63, <i32 8, i32 8, i32 8, i32 8>
%72 = add i64 %64, 1
%73 = icmp eq i64 %72, %19
br i1 %73, label %74, label %61
74: ; preds = %61, %57
%75 = icmp eq i64 %15, %12
br i1 %75, label %84, label %76
76: ; preds = %10, %74
%77 = phi i64 [ 0, %10 ], [ %15, %74 ]
br label %78
78: ; preds = %76, %78
%79 = phi i64 [ %82, %78 ], [ %77, %76 ]
%80 = getelementptr inbounds i32, i32* %8, i64 %79
%81 = trunc i64 %79 to i32
store i32 %81, i32* %80
%82 = add nuw nsw i64 %79, 1
%83 = icmp eq i64 %82, %12
br i1 %83, label %84, label %78
84: ; preds = %78, %74, %0
%85 = call i32 @lexperms(i32* %8, i32 %5)
%86 = call i32 @read(i32 %5)
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.3, i64 0, i64 0))
%88 = call i32 @invers(i32 %5)
ret i32 0
}