#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__ malloc(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 *);
int check_perm(char *what, int n, int *perm) {
  register int i;
  int *marker;
  marker = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; ++i)
    marker[i] = 0;
  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", 207,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/TLCFEM/suanPan/refs/heads/"
                "master/Toolbox/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)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a9 <check_perm+0x59>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <check_perm+0x30>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1269 <check_perm+0x119>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     11ea <check_perm+0x9a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
jl     123f <check_perm+0xef>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe09(%rip),%rsi
lea    0xe1c(%rip),%rdx
mov    $0xcf,%ecx
lea    0xe1b(%rip),%r8
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
call   1030 <superlu_abort_and_exit@plt>
jmp    1256 <check_perm+0x106>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    125b <check_perm+0x10b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <check_perm+0x60>
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
lea    0x0(,%rbx,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
jle    1210 <check_perm+0xb0>
mov    %ebx,%ebp
lea    0x0(,%rbp,4),%rdx
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%r13
jmp    11f4 <check_perm+0x94>
nopl   0x0(%rax,%rax,1)
lea    0xe49(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %r13,%rdi
lea    0xe54(%rip),%rsi
lea    0xe67(%rip),%rdx
mov    $0xcf,%ecx
lea    0xe66(%rip),%r8
call   1080 <sprintf@plt>
mov    %r13,%rdi
call   1030 <superlu_abort_and_exit@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1210 <check_perm+0xb0>
mov    (%r15,%rbx,4),%ecx
movslq %ecx,%rax
cmpl   $0x1,(%r12,%rax,4)
je     11b0 <check_perm+0x50>
cmp    %ebp,%ecx
jge    11b0 <check_perm+0x50>
movl   $0x1,(%r12,%rax,4)
jmp    11eb <check_perm+0x8b>
mov    %r12,%rdi
call   1070 <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 = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/TLCFEM/suanPan/refs/heads/master/Toolbox/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 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %8
store i32 0, i32* %7
br label %16
16: ; preds = %25, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32*, i32** %8
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 0, i32* %24
br label %25
25: ; preds = %20
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %16
28: ; preds = %16
store i32 0, i32* %7
br label %29
29: ; preds = %75, %28
%30 = load i32, i32* %7
%31 = load i32, i32* %5
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %78
33: ; preds = %29
%34 = load i32*, i32** %8
%35 = load i32*, i32** %6
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %34, i64 %40
%42 = load i32, i32* %41
%43 = icmp eq i32 %42, 1
br i1 %43, label %52, label %44
44: ; preds = %33
%45 = load i32*, i32** %6
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %5
%51 = icmp sge i32 %49, %50
br i1 %51, label %52, label %65
52: ; preds = %44, %33
%53 = load i8*, i8** %4
%54 = load i32, i32* %7
%55 = load i32*, i32** %6
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %53, i32 %54, i32 %59)
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%62 = call i32 @sprintf(i8* %61, 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 207, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.3, i64 0, i64 0))
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%64 = call i32 @superlu_abort_and_exit(i8* %63)
br label %74
65: ; preds = %44
%66 = load i32*, i32** %8
%67 = load i32*, i32** %6
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %66, i64 %72
store i32 1, i32* %73
br label %74
74: ; preds = %65, %52
br label %75
75: ; preds = %74
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %29
78: ; preds = %29
%79 = load i32*, i32** %8
%80 = call i32 @superlu_free(i32* %79)
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 = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/TLCFEM/suanPan/refs/heads/master/Toolbox/superlu-src/sp_preorder.c\00"
define i32 @check_perm(i8* %0, i32 %1, i32* nocapture %2) {
%4 = alloca [256 x i8]
%5 = shl i32 %1, 2
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %34
9: ; preds = %3
%10 = inttoptr i64 %6 to i8*
%11 = zext i32 %1 to i64
%12 = shl nuw nsw i64 %11, 2
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %9, %31
%16 = phi i64 [ 0, %9 ], [ %32, %31 ]
%17 = getelementptr inbounds i32, i32* %2, i64 %16
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %7, i64 %19
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 1
%23 = icmp slt i32 %18, %1
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %30, label %25
25: ; preds = %15
%26 = trunc i64 %16 to i32
%27 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %26, i32 %18)
%28 = call i32 @sprintf(i8* %13, 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 207, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @superlu_abort_and_exit(i8* %13)
br label %31
30: ; preds = %15
store i32 1, i32* %20
br label %31
31: ; preds = %25, %30
%32 = add nuw nsw i64 %16, 1
%33 = icmp eq i64 %32, %14
br i1 %33, label %34, label %15
34: ; preds = %31, %3
%35 = call i32 @superlu_free(i32* %7)
ret i32 0
}