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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@__FUNCTION__.mTensorMergePara = external hidden unnamed_addr constant [17 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.4 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

27:                                               ; preds = %19
  %28 = load i32, ptr %7, align 4, !tbaa !12
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %28, i32 noundef -1, ptr noundef @.str.1, i32 noundef 24, ptr noundef @__FUNCTION__.mTensorMergePara, ptr noundef @.str.2)
  br label %29

29:                                               ; preds = %27, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %30

30:                                               ; preds = %29
  br label %31

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

55:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TensorMergePara, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = icmp eq ptr %58, null
  %60 = zext i1 %59 to i32
  store i32 %60, ptr %8, align 4, !tbaa !12
  %61 = load i32, ptr %8, align 4, !tbaa !12
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %55
  %64 = load i32, ptr %8, align 4, !tbaa !12
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %64, i32 noundef -1, ptr noundef @.str.1, i32 noundef 30, ptr noundef @__FUNCTION__.mTensorMergePara, ptr noundef @.str.2)
  br label %65

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

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TensorMergePara, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = getelementptr inbounds %struct.MLayer, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !13
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.TensorRegister, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds [32 x i8], ptr %75, i64 0, i64 0
  %77 = call i32 @strcmp(ptr noundef @.str.3, ptr noundef %76) #5
  %78 = icmp ne i32 %77, 0
  %79 = zext i1 %78 to i32
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TensorMergePara, ptr %80, i32 0, i32 3
  store i32 %79, ptr %81, align 4, !tbaa !17
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %82
}

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

declare ptr @m_Malloc(i32 noundef) #2

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

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

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!10 = !{!"TensorMergePara", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20}
!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 16}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !11, i64 20}


; 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 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@__FUNCTION__.mTensorMergePara = external hidden unnamed_addr constant [17 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.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @mTensorMergePara(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @m_Malloc(i32 noundef 24) #3
  %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 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #3
  %6 = tail call ptr @mNetworkLayer(ptr noundef %0, ptr noundef %5) #3
  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 24, ptr noundef nonnull @__FUNCTION__.mTensorMergePara, ptr noundef nonnull @.str.2) #3
  %.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) #4
  %16 = icmp ne i32 %15, 0
  %17 = zext i1 %16 to i32
  %18 = getelementptr inbounds i8, ptr %3, i64 16
  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.4 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #3
  %20 = tail call ptr @mNetworkLayer(ptr noundef %0, ptr noundef %19) #3
  %21 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %20, ptr %21, align 8, !tbaa !14
  %22 = icmp eq ptr %20, null
  br i1 %22, label %23, label %24

23:                                               ; 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 30, ptr noundef nonnull @__FUNCTION__.mTensorMergePara, ptr noundef nonnull @.str.2) #3
  %.pre20 = load ptr, ptr %21, align 8, !tbaa !14
  br label %24

24:                                               ; preds = %23, %9
  %25 = phi ptr [ %.pre20, %23 ], [ %20, %9 ]
  %26 = getelementptr inbounds i8, ptr %25, i64 32
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [256 x %struct.TensorRegister], ptr @morn_tensor_register, i64 0, i64 %28
  %30 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef nonnull dereferenceable(1) %29) #4
  %31 = icmp ne i32 %30, 0
  %32 = zext i1 %31 to i32
  %33 = getelementptr inbounds i8, ptr %3, i64 20
  store i32 %32, ptr %33, align 4, !tbaa !15
  ret ptr %3
}

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #1

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

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

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, !7, i64 0}
!6 = !{!"TensorMergePara", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!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 16}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !10, i64 20}


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