#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 */
scalar_t__ intCalloc(int);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *);
int /*<<< orphan*/ superlu_abort_and_exit(char *);
int check_perm(char *what, int n, int *perm) {
  register int i;
  int *marker;
  marker = (int *)intCalloc(n);
  for (i = 0; i < n; ++i) {
    if (marker[perm[i]] == 1 || perm[i] >= n) {
      printf("%s: Not a valid PERM[%d] = %d\n", what, i, perm[i]);
      {
        char msg[256];
        sprintf(msg, "%s at line %d in file %s\n", "Invalid perm.", 234,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/dilawar/sesc/refs/heads/"
                "master/src/libsesctherm/SuperLU_MT/SRC/sp_colorder.c");
        superlu_abort_and_exit(msg);
      };
    } else {
      marker[perm[i]] = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <intCalloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1222 <check_perm+0xe2>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     11a3 <check_perm+0x63>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
jl     11f8 <check_perm+0xb8>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe50(%rip),%rsi
lea    0xe63(%rip),%rdx
mov    $0xea,%ecx
lea    0xe65(%rip),%r8
call   1060 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1040 <superlu_abort_and_exit@plt>
jmp    120f <check_perm+0xcf>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1214 <check_perm+0xd4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1169 <check_perm+0x29>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_perm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%edi
call   1030 <intCalloc@plt>
test   %ebx,%ebx
jle    11d0 <check_perm+0x90>
mov    %rax,%r12
mov    %ebx,%ebp
xor    %ebx,%ebx
mov    %rsp,%r13
jmp    11b4 <check_perm+0x74>
lea    0xe89(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <printf@plt>
mov    %r13,%rdi
lea    0xe94(%rip),%rsi
lea    0xea7(%rip),%rdx
mov    $0xea,%ecx
lea    0xea9(%rip),%r8
call   1060 <sprintf@plt>
mov    %r13,%rdi
call   1040 <superlu_abort_and_exit@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11d0 <check_perm+0x90>
mov    (%r15,%rbx,4),%ecx
movslq %ecx,%rax
cmpl   $0x1,(%r12,%rax,4)
je     1170 <check_perm+0x30>
cmp    %ebp,%ecx
jge    1170 <check_perm+0x30>
movl   $0x1,(%r12,%rax,4)
jmp    11ab <check_perm+0x6b>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"%s: Not a valid PERM[%d] = %d\0A\00"
@.str.1 = [26 x i8] c"%s at line %d in file %s\0A\00"
@.str.2 = [14 x i8] c"Invalid perm.\00"
@.str.3 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dilawar/sesc/refs/heads/master/src/libsesctherm/SuperLU_MT/SRC/sp_colorder.c\00"
define i32 @check_perm(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [256 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i32, i32* %5
%11 = call i64 @intCalloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %8
store i32 0, i32* %7
br label %13
13: ; preds = %59, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %62
17: ; preds = %13
%18 = load i32*, i32** %8
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %18, i64 %24
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 1
br i1 %27, label %36, label %28
28: ; preds = %17
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %5
%35 = icmp sge i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %28, %17
%37 = load i8*, i8** %4
%38 = load i32, i32* %7
%39 = load i32*, i32** %6
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %37, i32 %38, i32 %43)
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%46 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 234, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.3, i64 0, i64 0))
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%48 = call i32 @superlu_abort_and_exit(i8* %47)
br label %58
49: ; preds = %28
%50 = load i32*, i32** %8
%51 = load i32*, i32** %6
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %50, i64 %56
store i32 1, i32* %57
br label %58
58: ; preds = %49, %36
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %13
62: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"%s: Not a valid PERM[%d] = %d\0A\00"
@.str.1 = [26 x i8] c"%s at line %d in file %s\0A\00"
@.str.2 = [14 x i8] c"Invalid perm.\00"
@.str.3 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dilawar/sesc/refs/heads/master/src/libsesctherm/SuperLU_MT/SRC/sp_colorder.c\00"
define i32 @check_perm(i8* %0, i32 %1, i32* nocapture %2) {
%4 = alloca [256 x i8]
%5 = tail call i64 @intCalloc(i32 %1)
%6 = inttoptr i64 %5 to i32*
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %30
8: ; preds = %3
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %27
%12 = phi i64 [ 0, %8 ], [ %28, %27 ]
%13 = getelementptr inbounds i32, i32* %2, i64 %12
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %6, i64 %15
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 1
%19 = icmp slt i32 %14, %1
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %26, label %21
21: ; preds = %11
%22 = trunc i64 %12 to i32
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %22, i32 %14)
%24 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 234, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @superlu_abort_and_exit(i8* %9)
br label %27
26: ; preds = %11
store i32 1, i32* %16
br label %27
27: ; preds = %21, %26
%28 = add nuw nsw i64 %12, 1
%29 = icmp eq i64 %28, %10
br i1 %29, label %30, label %11
30: ; preds = %27, %3
ret i32 0
}