#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__ calloc(int, int);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *);
int /*<<< orphan*/ superlu_abort_and_exit(char *);
int /*<<< orphan*/ superlu_free(int *);
check_perm(char *what, int n, int *perm) {
  register int i;
  int *marker;
  marker = (int *)calloc(n, sizeof(int));
  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", "check_perm", 153,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/optimizers/pysparse/refs/"
                "heads/master/pysparse/direct/superlu/src/sp_preorder.c");
        superlu_abort_and_exit(msg);
      };
    } else {
      marker[perm[i]] = 1;
    }
  }
  superlu_free(marker);
  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
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1237 <check_perm+0xe7>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     11b8 <check_perm+0x68>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
jl     120d <check_perm+0xbd>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    0xe4e(%rip),%rdx
mov    $0x99,%ecx
lea    0xe4d(%rip),%r8
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1030 <superlu_abort_and_exit@plt>
jmp    1224 <check_perm+0xd4>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1229 <check_perm+0xd9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <check_perm+0x2e>
mov    -0x28(%rbp),%rdi
call   1060 <superlu_free@plt>
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
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
jle    11f0 <check_perm+0xa0>
mov    %ebx,%ebp
xor    %ebx,%ebx
mov    %rsp,%r13
jmp    11d4 <check_perm+0x84>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %r13,%rdi
lea    0xe74(%rip),%rsi
lea    0xe87(%rip),%rdx
mov    $0x99,%ecx
lea    0xe86(%rip),%r8
call   1070 <sprintf@plt>
mov    %r13,%rdi
call   1030 <superlu_abort_and_exit@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11f0 <check_perm+0xa0>
mov    (%r15,%rbx,4),%ecx
movslq %ecx,%rax
cmpl   $0x1,(%r12,%rax,4)
je     1190 <check_perm+0x40>
cmp    %ebp,%ecx
jge    1190 <check_perm+0x40>
movl   $0x1,(%r12,%rax,4)
jmp    11cb <check_perm+0x7b>
mov    %r12,%rdi
call   1060 <superlu_free@plt>
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 = [11 x i8] c"check_perm\00"
@.str.3 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/optimizers/pysparse/refs/heads/master/pysparse/direct/superlu/src/sp_preorder.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 @calloc(i32 %10, i32 4)
%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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 153, i8* getelementptr inbounds ([170 x i8], [170 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
%63 = load i32*, i32** %8
%64 = call i32 @superlu_free(i32* %63)
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 = [11 x i8] c"check_perm\00"
@.str.3 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/optimizers/pysparse/refs/heads/master/pysparse/direct/superlu/src/sp_preorder.c\00"
define i32 @check_perm(i8* %0, i32 %1, i32* nocapture %2) {
%4 = alloca [256 x i8]
%5 = tail call i64 @calloc(i32 %1, i32 4)
%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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 153, i8* getelementptr inbounds ([170 x i8], [170 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
%31 = call i32 @superlu_free(i32* %6)
ret i32 0
}