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

; 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.MLayer = type { [32 x i8], i32, ptr, ptr, ptr, i32 }
%struct.TensorInputPara = type { i32, i32, i32 }
%struct.MTensor = type { i32, i32, i32, i32, ptr, i32 }

@.str.3 = external hidden unnamed_addr constant [94 x i8], align 1
@__FUNCTION__.mTensorInputForward = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@morn_tensor_register = external global [256 x %struct.TensorRegister], align 16
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 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

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

; Function Attrs: nounwind uwtable
define dso_local void @mTensorInputForward(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %17, label %13

13:                                               ; preds = %10
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = ptrtoint ptr %14 to i64
  %16 = icmp eq i64 %15, -1
  br label %17

17:                                               ; preds = %13, %10
  %18 = phi i1 [ true, %10 ], [ %16, %13 ]
  %19 = zext i1 %18 to i32
  store i32 %19, ptr %3, align 4, !tbaa !9
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = load i32, ptr %3, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %23, i32 noundef -1, ptr noundef @.str.3, i32 noundef 29, ptr noundef @__FUNCTION__.mTensorInputForward, ptr noundef @.str.4)
  br label %24

24:                                               ; preds = %22, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MLayer, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.TensorRegister, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [32 x i8], ptr %32, i64 0, i64 0
  %34 = call i32 @strcmp(ptr noundef @.str.5, ptr noundef %33) #5
  store i32 %34, ptr %4, align 4, !tbaa !9
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %26
  %38 = load i32, ptr %4, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %38, i32 noundef -1, ptr noundef @.str.3, i32 noundef 30, ptr noundef @__FUNCTION__.mTensorInputForward, ptr noundef @.str.6)
  br label %39

39:                                               ; preds = %37, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %40

40:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.MLayer, ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  store ptr %43, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MLayer, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  store ptr %46, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TensorInputPara, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = icmp ne i32 %49, -1
  br i1 %50, label %51, label %68

51:                                               ; preds = %40
  br label %52

52:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.MTensor, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !17
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TensorInputPara, ptr %56, i32 0, i32 2
  %58 = load i32, ptr %57, align 4, !tbaa !15
  %59 = icmp ne i32 %55, %58
  %60 = zext i1 %59 to i32
  store i32 %60, ptr %7, align 4, !tbaa !9
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %52
  %64 = load i32, ptr %7, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %64, i32 noundef -1, ptr noundef @.str.3, i32 noundef 35, ptr noundef @__FUNCTION__.mTensorInputForward, ptr noundef @.str.7)
  br label %65

65:                                               ; preds = %63, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67, %40
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TensorInputPara, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !19
  %72 = icmp ne i32 %71, -1
  br i1 %72, label %73, label %90

73:                                               ; preds = %68
  br label %74

74:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MTensor, ptr %75, i32 0, i32 2
  %77 = load i32, ptr %76, align 8, !tbaa !20
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TensorInputPara, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = icmp ne i32 %77, %80
  %82 = zext i1 %81 to i32
  store i32 %82, ptr %8, align 4, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %87

85:                                               ; preds = %74
  %86 = load i32, ptr %8, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %86, i32 noundef -1, ptr noundef @.str.3, i32 noundef 36, ptr noundef @__FUNCTION__.mTensorInputForward, ptr noundef @.str.8)
  br label %87

87:                                               ; preds = %85, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89, %68
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TensorInputPara, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !21
  %94 = icmp ne i32 %93, -1
  br i1 %94, label %95, label %112

95:                                               ; preds = %90
  br label %96

96:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.MTensor, ptr %97, i32 0, i32 3
  %99 = load i32, ptr %98, align 4, !tbaa !22
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.TensorInputPara, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !21
  %103 = icmp ne i32 %99, %102
  %104 = zext i1 %103 to i32
  store i32 %104, ptr %9, align 4, !tbaa !9
  %105 = load i32, ptr %9, align 4, !tbaa !9
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %109

107:                                              ; preds = %96
  %108 = load i32, ptr %9, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %108, i32 noundef -1, ptr noundef @.str.3, i32 noundef 37, ptr noundef @__FUNCTION__.mTensorInputForward, ptr noundef @.str.9)
  br label %109

109:                                              ; preds = %107, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111, %90
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.MLayer, ptr %113, i32 0, i32 5
  store i32 0, ptr %114, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"MLayer", !7, i64 0, !10, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64}
!13 = !{!12, !6, i64 56}
!14 = !{!12, !6, i64 40}
!15 = !{!16, !10, i64 8}
!16 = !{!"TensorInputPara", !10, i64 0, !10, i64 4, !10, i64 8}
!17 = !{!18, !10, i64 4}
!18 = !{!"MTensor", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24}
!19 = !{!16, !10, i64 0}
!20 = !{!18, !10, i64 8}
!21 = !{!16, !10, i64 4}
!22 = !{!18, !10, i64 12}
!23 = !{!12, !10, i64 64}


; 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.3 = external hidden unnamed_addr constant [94 x i8], align 1
@__FUNCTION__.mTensorInputForward = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@morn_tensor_register = external global [256 x %struct.TensorRegister], align 16
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @mTensorInputForward(ptr noundef %0) local_unnamed_addr #0 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %7 [
    i64 -1, label %2
    i64 0, label %2
  ]

2:                                                ; preds = %1, %1
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %0, inttoptr (i64 -1 to ptr)
  %5 = or i1 %3, %4
  %6 = zext i1 %5 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %6, i32 noundef -1, ptr noundef nonnull @.str.3, i32 noundef 29, ptr noundef nonnull @__FUNCTION__.mTensorInputForward, ptr noundef nonnull @.str.4) #3
  br label %7

7:                                                ; preds = %1, %2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %10
  %12 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull dereferenceable(1) %11) #4
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %14, label %13

13:                                               ; preds = %7
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %12, i32 noundef -1, ptr noundef nonnull @.str.3, i32 noundef 30, ptr noundef nonnull @__FUNCTION__.mTensorInputForward, ptr noundef nonnull @.str.6) #3
  br label %14

14:                                               ; preds = %13, %7
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %16, i64 8
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %.not27 = icmp eq i32 %20, -1
  br i1 %.not27, label %25, label %21

21:                                               ; preds = %14
  %22 = getelementptr inbounds i8, ptr %18, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %.not30 = icmp eq i32 %23, %20
  br i1 %.not30, label %25, label %24

24:                                               ; preds = %21
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.3, i32 noundef 35, ptr noundef nonnull @__FUNCTION__.mTensorInputForward, ptr noundef nonnull @.str.7) #3
  br label %25

25:                                               ; preds = %21, %24, %14
  %26 = load i32, ptr %16, align 4, !tbaa !17
  %.not28 = icmp eq i32 %26, -1
  br i1 %.not28, label %31, label %27

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %18, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %.not31 = icmp eq i32 %29, %26
  br i1 %.not31, label %31, label %30

30:                                               ; preds = %27
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.3, i32 noundef 36, ptr noundef nonnull @__FUNCTION__.mTensorInputForward, ptr noundef nonnull @.str.8) #3
  br label %31

31:                                               ; preds = %27, %30, %25
  %32 = getelementptr inbounds i8, ptr %16, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !19
  %.not29 = icmp eq i32 %33, -1
  br i1 %.not29, label %38, label %34

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %18, i64 12
  %36 = load i32, ptr %35, align 4, !tbaa !20
  %.not32 = icmp eq i32 %36, %33
  br i1 %.not32, label %38, label %37

37:                                               ; preds = %34
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.3, i32 noundef 37, ptr noundef nonnull @__FUNCTION__.mTensorInputForward, ptr noundef nonnull @.str.9) #3
  br label %38

38:                                               ; preds = %34, %37, %31
  %39 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 0, ptr %39, align 8, !tbaa !21
  ret void
}

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

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

attributes #0 = { 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 #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 = { 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 #3 = { nounwind }
attributes #4 = { 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, !9, i64 32}
!6 = !{!"MLayer", !7, i64 0, !9, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !9, i64 64}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !10, i64 56}
!12 = !{!6, !10, i64 40}
!13 = !{!14, !9, i64 8}
!14 = !{!"TensorInputPara", !9, i64 0, !9, i64 4, !9, i64 8}
!15 = !{!16, !9, i64 4}
!16 = !{!"MTensor", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !10, i64 16, !9, i64 24}
!17 = !{!14, !9, i64 0}
!18 = !{!16, !9, i64 8}
!19 = !{!14, !9, i64 4}
!20 = !{!16, !9, i64 12}
!21 = !{!6, !9, i64 64}


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