; LLVM IR from jingweizhanghuai/Morn :: src/deep_learning (morn_tensor_channel)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.TensorRegister = type { [32 x i8], ptr, ptr, ptr }
%struct.TensorSplitPara = type { ptr, i32, i32, i32 }
%struct.MLayer = type { [32 x i8], i32, ptr, ptr, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@morn_tensor_register = external global [256 x %struct.TensorRegister], align 16
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.mTensorSplitPara = external hidden unnamed_addr constant [17 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @m_Malloc(i32 noundef) #1

declare ptr @m_INIRead(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ...) #1

declare ptr @mNetworkLayer(ptr noundef, ptr noundef) #1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @mTensorSplitPara(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call ptr @m_Malloc(i32 noundef 24)
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = ptrtoint ptr %13 to i64
  %15 = call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %12, i64 noundef %14, i64 noundef ptrtoint (ptr @.str.12 to i64), ptr noundef inttoptr (i64 -1 to ptr), i32 noundef -1)
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call ptr @mNetworkLayer(ptr noundef %16, ptr noundef %17)
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TensorSplitPara, ptr %19, i32 0, i32 0
  store ptr %18, ptr %20, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TensorSplitPara, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = icmp eq ptr %24, null
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %7, align 4, !tbaa !12
  %27 = load i32, ptr %7, align 4, !tbaa !12
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = load i32, ptr %7, align 4, !tbaa !12
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %30, i32 noundef -1, ptr noundef @.str.1, i32 noundef 148, ptr noundef @__FUNCTION__.mTensorSplitPara, ptr noundef @.str.2)
  br label %31

31:                                               ; preds = %29, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.TensorSplitPara, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.MLayer, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.TensorRegister, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds [32 x i8], ptr %41, i64 0, i64 0
  %43 = call i32 @strcmp(ptr noundef @.str.3, ptr noundef %42) #6
  %44 = icmp ne i32 %43, 0
  %45 = zext i1 %44 to i32
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TensorSplitPara, ptr %46, i32 0, i32 1
  store i32 %45, ptr %47, align 8, !tbaa !15
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = ptrtoint ptr %49 to i64
  %51 = call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %48, i64 noundef %50, i64 noundef ptrtoint (ptr @.str.13 to i64), ptr noundef inttoptr (i64 -1 to ptr), i32 noundef -1)
  store ptr %51, ptr %6, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  %55 = zext i1 %54 to i32
  store i32 %55, ptr %8, align 4, !tbaa !12
  %56 = load i32, ptr %8, align 4, !tbaa !12
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %52
  %59 = load i32, ptr %8, align 4, !tbaa !12
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %59, i32 noundef -1, ptr noundef @.str.1, i32 noundef 153, ptr noundef @__FUNCTION__.mTensorSplitPara, ptr noundef @.str.14)
  br label %60

60:                                               ; preds = %58, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = call i32 @atoi(ptr noundef %63) #6
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TensorSplitPara, ptr %65, i32 0, i32 2
  store i32 %64, ptr %66, align 4, !tbaa !16
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.TensorSplitPara, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !16
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.TensorSplitPara, ptr %70, i32 0, i32 3
  store i32 %69, ptr %71, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call ptr @strchr(ptr noundef %72, i32 noundef 58) #6
  store ptr %73, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %82

76:                                               ; preds = %62
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 1
  %79 = call i32 @atoi(ptr noundef %78) #6
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TensorSplitPara, ptr %80, i32 0, i32 3
  store i32 %79, ptr %81, align 8, !tbaa !17
  br label %82

82:                                               ; preds = %76, %62
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TensorSplitPara, ptr %83, i32 0, i32 2
  %85 = load i32, ptr %84, align 4, !tbaa !16
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.TensorSplitPara, ptr %86, i32 0, i32 3
  %88 = load i32, ptr %87, align 8, !tbaa !17
  %89 = icmp sgt i32 %85, %88
  br i1 %89, label %90, label %102

90:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TensorSplitPara, ptr %91, i32 0, i32 2
  %93 = load i32, ptr %92, align 4, !tbaa !16
  store i32 %93, ptr %10, align 4, !tbaa !12
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.TensorSplitPara, ptr %94, i32 0, i32 3
  %96 = load i32, ptr %95, align 8, !tbaa !17
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.TensorSplitPara, ptr %97, i32 0, i32 2
  store i32 %96, ptr %98, align 4, !tbaa !16
  %99 = load i32, ptr %10, align 4, !tbaa !12
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.TensorSplitPara, ptr %100, i32 0, i32 3
  store i32 %99, ptr %101, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %102

102:                                              ; preds = %90, %82
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %103
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"TensorSplitPara", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 32}
!14 = !{!"MLayer", !7, i64 0, !11, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !11, i64 12}
!17 = !{!10, !11, i64 16}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.TensorRegister = type { [32 x i8], ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@morn_tensor_register = external global [256 x %struct.TensorRegister], align 16
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.mTensorSplitPara = external hidden unnamed_addr constant [17 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [16 x i8], align 1

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #0

declare ptr @m_INIRead(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #0

declare ptr @mNetworkLayer(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @mTensorSplitPara(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = tail call ptr @m_Malloc(i32 noundef 24) #4
  %4 = ptrtoint ptr %1 to i64
  %5 = tail call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %0, i64 noundef %4, i64 noundef ptrtoint (ptr @.str.12 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #4
  %6 = tail call ptr @mNetworkLayer(ptr noundef %0, ptr noundef %5) #4
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.1, i32 noundef 148, ptr noundef nonnull @__FUNCTION__.mTensorSplitPara, ptr noundef nonnull @.str.2) #4
  %.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %8, %2
  %10 = phi ptr [ %.pre, %8 ], [ %6, %2 ]
  %11 = getelementptr inbounds i8, ptr %10, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %13
  %15 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef nonnull dereferenceable(1) %14) #5
  %16 = icmp ne i32 %15, 0
  %17 = zext i1 %16 to i32
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %17, ptr %18, align 8, !tbaa !13
  %19 = tail call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %0, i64 noundef %4, i64 noundef ptrtoint (ptr @.str.13 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #4
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %9
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.1, i32 noundef 153, ptr noundef nonnull @__FUNCTION__.mTensorSplitPara, ptr noundef nonnull @.str.14) #4
  br label %22

22:                                               ; preds = %21, %9
  %23 = tail call i32 @atoi(ptr nocapture noundef %19) #5
  %24 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 %23, ptr %24, align 4, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 %23, ptr %25, align 8, !tbaa !15
  %26 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %19, i32 noundef 58) #5
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %.thread, label %27

27:                                               ; preds = %22
  %28 = getelementptr inbounds i8, ptr %26, i64 1
  %29 = tail call i32 @atoi(ptr nocapture noundef %28) #5
  store i32 %29, ptr %25, align 8, !tbaa !15
  %30 = icmp sgt i32 %23, %29
  br i1 %30, label %31, label %.thread

31:                                               ; preds = %27
  store i32 %29, ptr %24, align 4, !tbaa !14
  store i32 %23, ptr %25, align 8, !tbaa !15
  br label %.thread

.thread:                                          ; preds = %22, %31, %27
  ret ptr %3
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"TensorSplitPara", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"MLayer", !8, i64 0, !10, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass