; 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.TensorInputPara = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @mTensorInputPara(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
  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
  %7 = call ptr @m_Malloc(i32 noundef 12)
  store ptr %7, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = ptrtoint ptr %9 to i64
  %11 = call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %8, i64 noundef %10, i64 noundef ptrtoint (ptr @.str to i64), ptr noundef inttoptr (i64 -1 to ptr), i32 noundef -1)
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %19

14:                                               ; preds = %2
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call i32 @atoi(ptr noundef %15) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.TensorInputPara, ptr %17, i32 0, i32 0
  store i32 %16, ptr %18, align 4, !tbaa !9
  br label %22

19:                                               ; preds = %2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.TensorInputPara, ptr %20, i32 0, i32 0
  store i32 -1, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %19, %14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = ptrtoint ptr %24 to i64
  %26 = call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %23, i64 noundef %25, i64 noundef ptrtoint (ptr @.str.1 to i64), ptr noundef inttoptr (i64 -1 to ptr), i32 noundef -1)
  store ptr %26, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %34

29:                                               ; preds = %22
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call i32 @atoi(ptr noundef %30) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TensorInputPara, ptr %32, i32 0, i32 1
  store i32 %31, ptr %33, align 4, !tbaa !12
  br label %37

34:                                               ; preds = %22
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TensorInputPara, ptr %35, i32 0, i32 1
  store i32 -1, ptr %36, align 4, !tbaa !12
  br label %37

37:                                               ; preds = %34, %29
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = ptrtoint ptr %39 to i64
  %41 = call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %38, i64 noundef %40, i64 noundef ptrtoint (ptr @.str.2 to i64), ptr noundef inttoptr (i64 -1 to ptr), i32 noundef -1)
  store ptr %41, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %49

44:                                               ; preds = %37
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i32 @atoi(ptr noundef %45) #5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.TensorInputPara, ptr %47, i32 0, i32 2
  store i32 %46, ptr %48, align 4, !tbaa !13
  br label %52

49:                                               ; preds = %37
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TensorInputPara, ptr %50, i32 0, i32 2
  store i32 -1, ptr %51, align 4, !tbaa !13
  br label %52

52:                                               ; preds = %49, %44
  %53 = 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 %53
}

; 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

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

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

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 = { 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 #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, !11, i64 0}
!10 = !{!"TensorInputPara", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}


; 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"

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @mTensorInputPara(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @m_Malloc(i32 noundef 12) #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
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %2
  %7 = tail call i32 @atoi(ptr nocapture noundef %5) #4
  br label %8

8:                                                ; preds = %2, %6
  %storemerge = phi i32 [ %7, %6 ], [ -1, %2 ]
  store i32 %storemerge, ptr %3, align 4, !tbaa !5
  %9 = tail call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %0, i64 noundef %4, i64 noundef ptrtoint (ptr @.str.1 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #3
  %.not21 = icmp eq ptr %9, null
  br i1 %.not21, label %12, label %10

10:                                               ; preds = %8
  %11 = tail call i32 @atoi(ptr nocapture noundef %9) #4
  br label %12

12:                                               ; preds = %8, %10
  %.sink = phi i32 [ %11, %10 ], [ -1, %8 ]
  %13 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %.sink, ptr %13, align 4
  %14 = tail call ptr (ptr, i64, i64, ptr, ...) @m_INIRead(ptr noundef %0, i64 noundef %4, i64 noundef ptrtoint (ptr @.str.2 to i64), ptr noundef nonnull inttoptr (i64 -1 to ptr), i32 noundef -1) #3
  %.not22 = icmp eq ptr %14, null
  br i1 %.not22, label %17, label %15

15:                                               ; preds = %12
  %16 = tail call i32 @atoi(ptr nocapture noundef %14) #4
  br label %17

17:                                               ; preds = %12, %15
  %.sink23 = phi i32 [ %16, %15 ], [ -1, %12 ]
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %.sink23, ptr %18, align 4
  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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) 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 = { 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 #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 = !{!"TensorInputPara", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


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