#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*/ free(void *);
int /*<<< orphan*/ init_array(int, double **, double *, double *);
int /*<<< orphan*/ kernel_trisolv(int, double **, double *, double *);
scalar_t__ polybench_alloc_data(int, int);
int /*<<< orphan*/ print_array(int, double *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int n = 2000;
  double(*L)[2000 + 0][2000 + 0];
  L = (double(*)[2000 + 0][2000 + 0])
      polybench_alloc_data((2000 + 0) * (2000 + 0), sizeof(double));
  ;
  double(*x)[2000 + 0];
  x = (double(*)[2000 + 0]) polybench_alloc_data(2000 + 0, sizeof(double));
  ;
  double(*b)[2000 + 0];
  b = (double(*)[2000 + 0]) polybench_alloc_data(2000 + 0, sizeof(double));
  ;
  init_array(n, *L, *x, *b);
  ;
  kernel_trisolv(n, *L, *x, *b);
  ;
  ;
  if (argc > 42 && !strcmp(argv[0], ""))
    print_array(n, *x);
  free((void *)L);
  ;
  free((void *)x);
  ;
  free((void *)b);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x7d0,-0x14(%rbp)
mov    $0x3d0900,%edi
mov    $0x8,%esi
call   1080 <polybench_alloc_data@plt>
mov    %rax,-0x20(%rbp)
mov    $0x7d0,%edi
mov    $0x8,%esi
call   1080 <polybench_alloc_data@plt>
mov    %rax,-0x28(%rbp)
mov    $0x7d0,%edi
mov    $0x8,%esi
call   1080 <polybench_alloc_data@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1060 <init_array@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <kernel_trisolv@plt>
cmpl   $0x2a,-0x8(%rbp)
jle    1210 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe0a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1210 <main+0xb0>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1050 <print_array@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0x3d0900,%edi
mov    $0x8,%esi
call   1070 <polybench_alloc_data@plt>
mov    %rax,%r14
mov    $0x7d0,%edi
mov    $0x8,%esi
call   1070 <polybench_alloc_data@plt>
mov    %rax,%rbx
mov    $0x7d0,%edi
mov    $0x8,%esi
call   1070 <polybench_alloc_data@plt>
mov    %rax,%r12
mov    $0x7d0,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <init_array@plt>
mov    $0x7d0,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1040 <kernel_trisolv@plt>
cmp    $0x2b,%ebp
jl     11d3 <main+0x83>
mov    (%r15),%rax
cmpb   $0x0,(%rax)
jne    11d3 <main+0x83>
mov    $0x7d0,%edi
mov    %rbx,%rsi
call   1050 <print_array@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2000 x [2000 x double]]*
%8 = alloca [2000 x double]*
%9 = alloca [2000 x double]*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2000, i32* %6
%10 = call i64 @polybench_alloc_data(i32 4000000, i32 8)
%11 = inttoptr i64 %10 to [2000 x [2000 x double]]*
store [2000 x [2000 x double]]* %11, [2000 x [2000 x double]]** %7
%12 = call i64 @polybench_alloc_data(i32 2000, i32 8)
%13 = inttoptr i64 %12 to [2000 x double]*
store [2000 x double]* %13, [2000 x double]** %8
%14 = call i64 @polybench_alloc_data(i32 2000, i32 8)
%15 = inttoptr i64 %14 to [2000 x double]*
store [2000 x double]* %15, [2000 x double]** %9
%16 = load i32, i32* %6
%17 = load [2000 x [2000 x double]]*, [2000 x [2000 x double]]** %7
%18 = getelementptr inbounds [2000 x [2000 x double]], [2000 x [2000 x double]]* %17, i64 0, i64 0
%19 = bitcast [2000 x double]* %18 to double**
%20 = load [2000 x double]*, [2000 x double]** %8
%21 = getelementptr inbounds [2000 x double], [2000 x double]* %20, i64 0, i64 0
%22 = load [2000 x double]*, [2000 x double]** %9
%23 = getelementptr inbounds [2000 x double], [2000 x double]* %22, i64 0, i64 0
%24 = call i32 @init_array(i32 %16, double** %19, double* %21, double* %23)
%25 = load i32, i32* %6
%26 = load [2000 x [2000 x double]]*, [2000 x [2000 x double]]** %7
%27 = getelementptr inbounds [2000 x [2000 x double]], [2000 x [2000 x double]]* %26, i64 0, i64 0
%28 = bitcast [2000 x double]* %27 to double**
%29 = load [2000 x double]*, [2000 x double]** %8
%30 = getelementptr inbounds [2000 x double], [2000 x double]* %29, i64 0, i64 0
%31 = load [2000 x double]*, [2000 x double]** %9
%32 = getelementptr inbounds [2000 x double], [2000 x double]* %31, i64 0, i64 0
%33 = call i32 @kernel_trisolv(i32 %25, double** %28, double* %30, double* %32)
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 42
br i1 %35, label %36, label %47
36: ; preds = %2
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %36
%43 = load i32, i32* %6
%44 = load [2000 x double]*, [2000 x double]** %8
%45 = getelementptr inbounds [2000 x double], [2000 x double]* %44, i64 0, i64 0
%46 = call i32 @print_array(i32 %43, double* %45)
br label %47
47: ; preds = %42, %36, %2
%48 = load [2000 x [2000 x double]]*, [2000 x [2000 x double]]** %7
%49 = bitcast [2000 x [2000 x double]]* %48 to i8*
%50 = call i32 @free(i8* %49)
%51 = load [2000 x double]*, [2000 x double]** %8
%52 = bitcast [2000 x double]* %51 to i8*
%53 = call i32 @free(i8* %52)
%54 = load [2000 x double]*, [2000 x double]** %9
%55 = bitcast [2000 x double]* %54 to i8*
%56 = call i32 @free(i8* %55)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @polybench_alloc_data(i32 4000000, i32 8)
%4 = tail call i64 @polybench_alloc_data(i32 2000, i32 8)
%5 = inttoptr i64 %4 to [2000 x double]*
%6 = tail call i64 @polybench_alloc_data(i32 2000, i32 8)
%7 = inttoptr i64 %6 to [2000 x double]*
%8 = inttoptr i64 %3 to double**
%9 = getelementptr inbounds [2000 x double], [2000 x double]* %5, i64 0, i64 0
%10 = getelementptr inbounds [2000 x double], [2000 x double]* %7, i64 0, i64 0
%11 = tail call i32 @init_array(i32 2000, double** %8, double* %9, double* %10)
%12 = tail call i32 @kernel_trisolv(i32 2000, double** %8, double* %9, double* %10)
%13 = icmp sgt i32 %0, 42
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @print_array(i32 2000, double* %9)
br label %20
20: ; preds = %18, %14, %2
%21 = inttoptr i64 %3 to i8*
%22 = tail call i32 @free(i8* %21)
%23 = inttoptr i64 %4 to i8*
%24 = tail call i32 @free(i8* %23)
%25 = inttoptr i64 %6 to i8*
%26 = tail call i32 @free(i8* %25)
ret i32 0
}