#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*/ sp_assertion_failed(char *, int, char *);
int /*<<< orphan*/ sp_perm_inverse(int *, int, int *);
void permutations() {
  int i;
  int p[] = {0, 2, 3, 1};
  int pinv[] = {0, 3, 1, 2};
  int result[4];
  sp_perm_inverse(p, 4, result);
  for (i = 0; i < 4; ++i) {
    if (!(pinv[i] == result[i]))
      sp_assertion_failed("/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/fourier/"
                          "libspmatrix/refs/heads/master/test_src/test_main.c",
                          174, "pinv[i] == result[i]");
  };
}


x86 assembly (clang, -O0):
<permutations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    $0x4,%esi
call   1040 <sp_perm_inverse@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    11b8 <permutations+0x98>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x4(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
je     11a5 <permutations+0x85>
lea    0xe8c(%rip),%rdi
mov    $0xae,%esi
lea    0xf15(%rip),%rdx
call   1030 <sp_assertion_failed@plt>
jmp    11aa <permutations+0x8a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116d <permutations+0x4d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permutations>:
sub    $0x28,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x4,%esi
call   1040 <sp_perm_inverse@plt>
cmpl   $0x0,(%rsp)
je     1160 <permutations+0x40>
lea    0xec1(%rip),%rdi
lea    0xf4f(%rip),%rdx
mov    $0xae,%esi
call   1030 <sp_assertion_failed@plt>
cmpl   $0x3,0x4(%rsp)
jne    117a <permutations+0x5a>
cmpl   $0x1,0x8(%rsp)
jne    1199 <permutations+0x79>
cmpl   $0x2,0xc(%rsp)
jne    11b8 <permutations+0x98>
add    $0x28,%rsp
ret
lea    0xe8f(%rip),%rdi
lea    0xf1d(%rip),%rdx
mov    $0xae,%esi
call   1030 <sp_assertion_failed@plt>
cmpl   $0x1,0x8(%rsp)
je     116e <permutations+0x4e>
lea    0xe70(%rip),%rdi
lea    0xefe(%rip),%rdx
mov    $0xae,%esi
call   1030 <sp_assertion_failed@plt>
cmpl   $0x2,0xc(%rsp)
je     1175 <permutations+0x55>
lea    0xe51(%rip),%rdi
lea    0xedf(%rip),%rdx
mov    $0xae,%esi
call   1030 <sp_assertion_failed@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.permutations.p = [4 x i32] [i32 0, i32 2, i32 3, i32 1]
@__const.permutations.pinv = [4 x i32] [i32 0, i32 3, i32 1, i32 2]
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fourier/libspmatrix/refs/heads/master/test_src/test_main.c\00"
@.str.1 = [21 x i8] c"pinv[i] == result[i]\00"
define void @permutations() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [4 x i32]
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %2 to i8*
%6 = bitcast [4 x i32]* %3 to i8*
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%9 = call i32 @sp_perm_inverse(i32* %7, i32 4, i32* %8)
store i32 0, i32* %1
br label %10
10: ; preds = %26, %0
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %29
13: ; preds = %10
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %17, %21
br i1 %22, label %25, label %23
23: ; preds = %13
%24 = call i32 @sp_assertion_failed(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
br label %10
29: ; preds = %10
ret void
}

LLVM IR (-O2):
@__const.permutations.p = [4 x i32] [i32 0, i32 2, i32 3, i32 1]
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fourier/libspmatrix/refs/heads/master/test_src/test_main.c\00"
@.str.1 = [21 x i8] c"pinv[i] == result[i]\00"
define void @permutations() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = call i32 @sp_perm_inverse(i32* %5, i32 4, i32* %6)
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @sp_assertion_failed(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %0, %10
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 3
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @sp_assertion_failed(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = call i32 @sp_assertion_failed(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 2
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i32 @sp_assertion_failed(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
ret void
}