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

%class.anon = type { ptr, ptr, ptr, 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 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @mark_force_no_inline() #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @taichi_assert_format(ptr noundef %0, i1 noundef zeroext %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %class.anon, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %12 = zext i1 %1 to i8
  store i8 %12, ptr %7, align 1, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @mark_force_no_inline()
  %13 = load i8, ptr %7, align 1, !tbaa !9, !range !13, !noundef !14
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %30

18:                                               ; preds = %5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.LLVMRuntime, ptr %19, i32 0, i32 22
  %21 = load i64, ptr %20, align 8, !tbaa !15
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %30, label %23

23:                                               ; preds = %18
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.LLVMRuntime, ptr %24, i32 0, i32 21
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #3
  %26 = getelementptr inbounds %class.anon, ptr %11, i32 0, i32 0
  store ptr %6, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.anon, ptr %11, i32 0, i32 1
  store ptr %8, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.anon, ptr %11, i32 0, i32 2
  store ptr %9, ptr %28, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.anon, ptr %11, i32 0, i32 3
  store ptr %10, ptr %29, align 8, !tbaa !5
  call void @"_Z11locked_taskIZ20taichi_assert_formatE3$_0EvPvRKT_"(ptr noundef %25, ptr noundef nonnull align 8 dereferenceable(32) %11)
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #3
  br label %30

30:                                               ; preds = %23, %18, %17
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_Z11locked_taskIZ20taichi_assert_formatE3$_0EvPvRKT_"(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!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, !12, i64 35216, !18, i64 35224, !6, i64 35232, !12, i64 35240, !12, i64 35244, !18, i64 35248}
!17 = !{!"_ZTS23PreallocatedMemoryChunk", !6, i64 0, !6, i64 8, !18, i64 16}
!18 = !{!"long", !7, i64 0}


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

%class.anon = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @mark_force_no_inline() local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @taichi_assert_format(ptr noundef %0, i1 noundef zeroext %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %class.anon, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  store ptr %4, ptr %9, align 8, !tbaa !5
  tail call void @mark_force_no_inline()
  br i1 %1, label %19, label %11

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 35224
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %14, label %19

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 35216
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #3
  store ptr %6, ptr %10, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %7, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %8, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %10, i64 24
  store ptr %9, ptr %18, align 8, !tbaa !5
  call void @"_Z11locked_taskIZ20taichi_assert_formatE3$_0EvPvRKT_"(ptr noundef nonnull %15, ptr noundef nonnull align 8 dereferenceable(32) %10)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #3
  br label %19

19:                                               ; preds = %5, %14, %11
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_Z11locked_taskIZ20taichi_assert_formatE3$_0EvPvRKT_"(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 35224}
!12 = !{!"_ZTS11LLVMRuntime", !13, i64 0, !13, 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, !10, i64 35216, !14, i64 35224, !6, i64 35232, !10, i64 35240, !10, i64 35244, !14, i64 35248}
!13 = !{!"_ZTS23PreallocatedMemoryChunk", !6, i64 0, !6, i64 8, !14, i64 16}
!14 = !{!"long", !7, i64 0}


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