; LLVM IR from huawei-noah/bolt :: inference/engine/src (bolt_c_simplify)

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @MallocTensorDesc(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #0 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !9
  store ptr %7, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !5
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %73

21:                                               ; preds = %8
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = mul i64 8, %23
  %25 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %24)
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %25, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %39, %21
  %28 = load i32, ptr %18, align 4, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %42

32:                                               ; preds = %27
  %33 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef 128)
  %34 = load ptr, ptr %10, align 8, !tbaa !9
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = load i32, ptr %18, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  store ptr %33, ptr %38, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %32
  %40 = load i32, ptr %18, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %18, align 4, !tbaa !5
  br label %27, !llvm.loop !11

42:                                               ; preds = %31
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = mul i64 4, %44
  %46 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %45)
  %47 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %46, ptr %47, align 8, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = mul i64 4, %49
  %51 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %50)
  %52 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %51, ptr %52, align 8, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = mul i64 4, %54
  %56 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %55)
  %57 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %56, ptr %57, align 8, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = mul i64 4, %59
  %61 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %60)
  %62 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %61, ptr %62, align 8, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = mul i64 4, %64
  %66 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %65)
  %67 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %66, ptr %67, align 8, !tbaa !9
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul i64 4, %69
  %71 = call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %70)
  %72 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %71, ptr %72, align 8, !tbaa !9
  br label %73

73:                                               ; preds = %42, %8
  %74 = load i32, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  ret i32 %74
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z10UNI_MALLOCm(i64 noundef) #2

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @MallocTensorDesc(i32 noundef %0, ptr nocapture noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #0 {
  %9 = icmp sgt i32 %0, 0
  br i1 %9, label %10, label %26

10:                                               ; preds = %8
  %11 = zext nneg i32 %0 to i64
  %12 = shl nuw nsw i64 %11, 3
  %13 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %12)
  store ptr %13, ptr %1, align 8, !tbaa !5
  br label %22

14:                                               ; preds = %22
  %15 = shl nuw nsw i64 %11, 2
  %16 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %16, ptr %2, align 8, !tbaa !5
  %17 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %17, ptr %3, align 8, !tbaa !5
  %18 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %19, ptr %5, align 8, !tbaa !5
  %20 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %20, ptr %6, align 8, !tbaa !5
  %21 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef %15)
  store ptr %21, ptr %7, align 8, !tbaa !5
  br label %26

22:                                               ; preds = %10, %22
  %indvars.iv = phi i64 [ 0, %10 ], [ %indvars.iv.next, %22 ]
  %23 = tail call noundef ptr @_Z10UNI_MALLOCm(i64 noundef 128)
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  store ptr %23, ptr %25, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %11
  br i1 %exitcond.not, label %14, label %22, !llvm.loop !9

26:                                               ; preds = %14, %8
  ret i32 0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z10UNI_MALLOCm(i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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" }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass