; LLVM IR from taichi-dev/taichi :: taichi/runtime/llvm/runtime_module (runtime)

; 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.RuntimeContext = type { ptr, ptr, i32, ptr }
%struct.LLVMRuntime = type { %struct.PreallocatedMemoryChunk, %struct.PreallocatedMemoryChunk, ptr, ptr, ptr, ptr, ptr, [512 x ptr], [512 x i64], ptr, ptr, [1024 x ptr], [1024 x ptr], [1024 x ptr], ptr, ptr, ptr, ptr, ptr, [2048 x i8], [32 x i64], i32, i64, ptr, i32, i32, i64 }
%struct.PreallocatedMemoryChunk = type { ptr, ptr, i64 }

@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 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: mustprogress uwtable
declare dso_local void @taichi_assert(ptr noundef, i1 noundef zeroext, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ListManager6appendEPv(ptr noundef nonnull align 8 dereferenceable(1048616), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN11ListManager3getIiEERT_i(ptr noundef nonnull align 8 dereferenceable(1048616), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @test_list_manager(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.RuntimeContext, ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z13taichi_printfIJRP11LLVMRuntimeEEvS1_PKcDpOT_(ptr noundef %13, ptr noundef @.str.3, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.RuntimeContext, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 4, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 16, ptr %6, align 4, !tbaa !12
  %17 = call noundef ptr @_ZN11LLVMRuntime6createI11ListManagerJRPS_iiEEEPT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(35256) %16, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %27, %1
  %19 = load i32, ptr %7, align 4, !tbaa !12
  %20 = icmp slt i32 %19, 320
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %18
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef %23, ptr noundef @.str.4, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %24 = load i32, ptr %7, align 4, !tbaa !12
  %25 = add nsw i32 %24, 5
  store i32 %25, ptr %8, align 4, !tbaa !12
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11ListManager6appendEPv(ptr noundef nonnull align 8 dereferenceable(1048616) %26, ptr noundef %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %27

27:                                               ; preds = %22
  %28 = load i32, ptr %7, align 4, !tbaa !12
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %7, align 4, !tbaa !12
  br label %18, !llvm.loop !13

30:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %56, %30
  %32 = load i32, ptr %9, align 4, !tbaa !12
  %33 = icmp slt i32 %32, 320
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %59

35:                                               ; preds = %31
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !12
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN11ListManager3getIiEERT_i(ptr noundef nonnull align 8 dereferenceable(1048616) %38, i32 noundef %39)
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = load i32, ptr %9, align 4, !tbaa !12
  %43 = add nsw i32 %42, 5
  %44 = icmp eq i32 %41, %43
  call void @taichi_assert(ptr noundef %37, i1 noundef zeroext %44, ptr noundef @.str.5)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.LLVMRuntime, ptr %45, i32 0, i32 22
  %47 = load i64, ptr %46, align 8, !tbaa !15
  %48 = icmp ne i64 %47, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %36
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.LLVMRuntime, ptr %51, i32 0, i32 19
  call void @_Z13taichi_printfIJRA2048_cEEvP11LLVMRuntimePKcDpOT_(ptr noundef %50, ptr noundef @.str.6, ptr noundef nonnull align 1 dereferenceable(2048) %52)
  call void @abort() #5
  unreachable

53:                                               ; preds = %36
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %9, align 4, !tbaa !12
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !12
  br label %31, !llvm.loop !19

59:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRP11LLVMRuntimeEEvS1_PKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11LLVMRuntime6createI11ListManagerJRPS_iiEEEPT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(35256), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRA2048_cEEvP11LLVMRuntimePKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(2048)) #1

; Function Attrs: noreturn nounwind
declare void @abort() #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { noreturn nounwind "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 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS14RuntimeContext", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !18, i64 35224}
!16 = !{!"_ZTS11LLVMRuntime", !17, i64 0, !17, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !7, i64 88, !7, i64 4184, !6, i64 8280, !6, i64 8288, !7, i64 8296, !7, i64 16488, !7, i64 24680, !6, i64 32872, !6, i64 32880, !6, i64 32888, !6, i64 32896, !6, i64 32904, !7, i64 32912, !7, i64 34960, !11, i64 35216, !18, i64 35224, !6, i64 35232, !11, i64 35240, !11, i64 35244, !18, i64 35248}
!17 = !{!"_ZTS23PreallocatedMemoryChunk", !6, i64 0, !6, i64 8, !18, i64 16}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !14}


; 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.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @taichi_assert(ptr noundef, i1 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ListManager6appendEPv(ptr noundef nonnull align 8 dereferenceable(1048616), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN11ListManager3getIiEERT_i(ptr noundef nonnull align 8 dereferenceable(1048616), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @test_list_manager(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %8, ptr %2, align 8, !tbaa !11
  call void @_Z13taichi_printfIJRP11LLVMRuntimeEEvS1_PKcDpOT_(ptr noundef %8, ptr noundef nonnull @.str.3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 4, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 16, ptr %4, align 4, !tbaa !12
  %10 = call noundef ptr @_ZN11LLVMRuntime6createI11ListManagerJRPS_iiEEEPT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(35256) %9, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %12

11:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %22

12:                                               ; preds = %1, %12
  %13 = load ptr, ptr %2, align 8, !tbaa !11
  call void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef %13, ptr noundef nonnull @.str.4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %14 = load i32, ptr %5, align 4, !tbaa !12
  %15 = add nsw i32 %14, 5
  store i32 %15, ptr %6, align 4, !tbaa !12
  call void @_ZN11ListManager6appendEPv(ptr noundef nonnull align 8 dereferenceable(1048616) %10, ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %16 = load i32, ptr %5, align 4, !tbaa !12
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %5, align 4, !tbaa !12
  %18 = icmp slt i32 %16, 319
  br i1 %18, label %12, label %11, !llvm.loop !13

19:                                               ; preds = %22
  %20 = add nuw nsw i32 %.08, 1
  %exitcond.not = icmp eq i32 %20, 320
  br i1 %exitcond.not, label %21, label %22, !llvm.loop !15

21:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret i32 0

22:                                               ; preds = %11, %19
  %.08 = phi i32 [ 0, %11 ], [ %20, %19 ]
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN11ListManager3getIiEERT_i(ptr noundef nonnull align 8 dereferenceable(1048616) %10, i32 noundef %.08)
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = add nuw nsw i32 %.08, 5
  %26 = icmp eq i32 %24, %25
  call void @taichi_assert(ptr noundef %0, i1 noundef zeroext %26, ptr noundef nonnull @.str.5)
  %27 = load ptr, ptr %2, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %27, i64 35224
  %29 = load i64, ptr %28, align 8, !tbaa !16
  %.not = icmp eq i64 %29, 0
  br i1 %.not, label %19, label %30

30:                                               ; preds = %22
  %31 = getelementptr inbounds i8, ptr %27, i64 32912
  call void @_Z13taichi_printfIJRA2048_cEEvP11LLVMRuntimePKcDpOT_(ptr noundef nonnull %27, ptr noundef nonnull @.str.6, ptr noundef nonnull align 1 dereferenceable(2048) %31)
  call void @abort() #5
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRP11LLVMRuntimeEEvS1_PKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11LLVMRuntime6createI11ListManagerJRPS_iiEEEPT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(35256), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13taichi_printfIJRA2048_cEEvP11LLVMRuntimePKcDpOT_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(2048)) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { noreturn nounwind "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 = { noreturn 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, !7, i64 8}
!6 = !{!"_ZTS14RuntimeContext", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !19, i64 35224}
!17 = !{!"_ZTS11LLVMRuntime", !18, i64 0, !18, i64 24, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !8, i64 88, !8, i64 4184, !7, i64 8280, !7, i64 8288, !8, i64 8296, !8, i64 16488, !8, i64 24680, !7, i64 32872, !7, i64 32880, !7, i64 32888, !7, i64 32896, !7, i64 32904, !8, i64 32912, !8, i64 34960, !10, i64 35216, !19, i64 35224, !7, i64 35232, !10, i64 35240, !10, i64 35244, !19, i64 35248}
!18 = !{!"_ZTS23PreallocatedMemoryChunk", !7, i64 0, !7, i64 8, !19, i64 16}
!19 = !{!"long", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass