; 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.range_task_helper_context = type { ptr, ptr, ptr, ptr, i64, i32, i32, i32, i32 }
%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.1 = external hidden unnamed_addr constant [21 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 @cpu_parallel_range_for_task(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @cpu_parallel_range_for(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %9) #1 {
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca %struct.range_task_helper_context, align 8
  %22 = alloca ptr, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !9
  store i32 %2, ptr %13, align 4, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !9
  store i32 %4, ptr %15, align 4, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !9
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  store i64 %9, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 56, ptr %21) #4
  call void @_ZN25range_task_helper_contextC2Ev(ptr noundef nonnull align 8 dereferenceable(56) %21) #4
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 0
  store ptr %23, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %17, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 1
  store ptr %25, ptr %26, align 8, !tbaa !15
  %27 = load i64, ptr %20, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 4
  store i64 %27, ptr %28, align 8, !tbaa !16
  %29 = load ptr, ptr %18, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 2
  store ptr %29, ptr %30, align 8, !tbaa !17
  %31 = load ptr, ptr %19, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 3
  store ptr %31, ptr %32, align 8, !tbaa !18
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 5
  store i32 %33, ptr %34, align 8, !tbaa !19
  %35 = load i32, ptr %14, align 4, !tbaa !9
  %36 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 6
  store i32 %35, ptr %36, align 4, !tbaa !20
  %37 = load i32, ptr %15, align 4, !tbaa !9
  %38 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 8
  store i32 %37, ptr %38, align 4, !tbaa !21
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 1
  br i1 %40, label %41, label %48

41:                                               ; preds = %10
  %42 = load i32, ptr %15, align 4, !tbaa !9
  %43 = icmp ne i32 %42, -1
  br i1 %43, label %44, label %48

44:                                               ; preds = %41
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.RuntimeContext, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !22
  call void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef %47, ptr noundef @.str.1, ptr noundef nonnull align 4 dereferenceable(4) %15)
  call void @exit(i32 noundef -1) #5
  unreachable

48:                                               ; preds = %41, %10
  %49 = load i32, ptr %16, align 4, !tbaa !9
  %50 = getelementptr inbounds %struct.range_task_helper_context, ptr %21, i32 0, i32 7
  store i32 %49, ptr %50, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.RuntimeContext, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  store ptr %53, ptr %22, align 8, !tbaa !5
  %54 = load ptr, ptr %22, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.LLVMRuntime, ptr %54, i32 0, i32 10
  %56 = load ptr, ptr %55, align 8, !tbaa !25
  %57 = load ptr, ptr %22, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.LLVMRuntime, ptr %57, i32 0, i32 9
  %59 = load ptr, ptr %58, align 8, !tbaa !28
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = sub nsw i32 %60, %61
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = add nsw i32 %62, %63
  %65 = sub nsw i32 %64, 1
  %66 = load i32, ptr %16, align 4, !tbaa !9
  %67 = sdiv i32 %65, %66
  %68 = load i32, ptr %12, align 4, !tbaa !9
  call void %56(ptr noundef %59, i32 noundef %67, i32 noundef %68, ptr noundef %21, ptr noundef @cpu_parallel_range_for_task)
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr %21) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN25range_task_helper_contextC2Ev(ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #2 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: noreturn nounwind
declare void @exit(i32 noundef) #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 = { inlinehint 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS25range_task_helper_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !12, i64 32}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !10, i64 40}
!20 = !{!14, !10, i64 44}
!21 = !{!14, !10, i64 52}
!22 = !{!23, !6, i64 8}
!23 = !{!"_ZTS14RuntimeContext", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24}
!24 = !{!14, !10, i64 48}
!25 = !{!26, !6, i64 8288}
!26 = !{!"_ZTS11LLVMRuntime", !27, i64 0, !27, 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, !12, i64 35224, !6, i64 35232, !10, i64 35240, !10, i64 35244, !12, i64 35248}
!27 = !{!"_ZTS23PreallocatedMemoryChunk", !6, i64 0, !6, i64 8, !12, i64 16}
!28 = !{!26, !6, i64 8280}


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

@.str.1 = external hidden unnamed_addr constant [21 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 @cpu_parallel_range_for_task(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @cpu_parallel_range_for(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %9) local_unnamed_addr #1 {
  %11 = alloca i32, align 4
  %12 = alloca %struct.range_task_helper_context, align 8
  store i32 %4, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %12) #4
  call void @_ZN25range_task_helper_contextC2Ev(ptr noundef nonnull align 8 dereferenceable(56) %12) #4
  store ptr %0, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %6, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %12, i64 32
  store i64 %9, ptr %14, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr %7, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %8, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %12, i64 40
  store i32 %2, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %12, i64 44
  store i32 %3, ptr %18, align 4, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %12, i64 52
  store i32 %4, ptr %19, align 4, !tbaa !19
  switch i32 %4, label %20 [
    i32 -1, label %23
    i32 1, label %23
  ]

20:                                               ; preds = %10
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !20
  call void @_Z13taichi_printfIJRiEEvP11LLVMRuntimePKcDpOT_(ptr noundef %22, ptr noundef nonnull @.str.1, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @exit(i32 noundef -1) #5
  unreachable

23:                                               ; preds = %10, %10
  %24 = getelementptr inbounds i8, ptr %12, i64 48
  store i32 %5, ptr %24, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %26, i64 8288
  %28 = load ptr, ptr %27, align 8, !tbaa !23
  %29 = getelementptr inbounds i8, ptr %26, i64 8280
  %30 = load ptr, ptr %29, align 8, !tbaa !26
  %31 = xor i32 %2, -1
  %32 = add i32 %31, %3
  %33 = add i32 %32, %5
  %34 = sdiv i32 %33, %5
  call void %28(ptr noundef %30, i32 noundef %34, i32 noundef %1, ptr noundef nonnull %12, ptr noundef nonnull @cpu_parallel_range_for_task)
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %12) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN25range_task_helper_contextC2Ev(ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #2 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: noreturn nounwind
declare void @exit(i32 noundef) 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 = { inlinehint 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS25range_task_helper_context", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !12, i64 32}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !6, i64 44}
!19 = !{!10, !6, i64 52}
!20 = !{!21, !11, i64 8}
!21 = !{!"_ZTS14RuntimeContext", !11, i64 0, !11, i64 8, !6, i64 16, !11, i64 24}
!22 = !{!10, !6, i64 48}
!23 = !{!24, !11, i64 8288}
!24 = !{!"_ZTS11LLVMRuntime", !25, i64 0, !25, i64 24, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 4184, !11, i64 8280, !11, i64 8288, !7, i64 8296, !7, i64 16488, !7, i64 24680, !11, i64 32872, !11, i64 32880, !11, i64 32888, !11, i64 32896, !11, i64 32904, !7, i64 32912, !7, i64 34960, !6, i64 35216, !12, i64 35224, !11, i64 35232, !6, i64 35240, !6, i64 35244, !12, i64 35248}
!25 = !{!"_ZTS23PreallocatedMemoryChunk", !11, i64 0, !11, i64 8, !12, i64 16}
!26 = !{!24, !11, i64 8280}


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