; LLVM IR from yuanming-hu/taichi_mpm :: external/libccd/src/testsuites/cu (cu)

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

@cu_test_suites = external global [0 x %struct._cu_test_suites_t], align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @cu_run(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  store i8 0, ptr %7, align 1, !tbaa !11
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 1
  br i1 %9, label %10, label %77

10:                                               ; preds = %2
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %68, %10
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %15, label %71

15:                                               ; preds = %11
  store ptr @cu_test_suites, ptr %5, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %46, %15
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct._cu_test_suites_t, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %26

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct._cu_test_suites_t, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = icmp ne ptr %24, null
  br label %26

26:                                               ; preds = %21, %16
  %27 = phi i1 [ false, %16 ], [ %25, %21 ]
  br i1 %27, label %28, label %49

28:                                               ; preds = %26
  %29 = load ptr, ptr %4, align 8, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds ptr, ptr %29, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct._cu_test_suites_t, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = call i32 @strcmp(ptr noundef %33, ptr noundef %36) #5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %46

39:                                               ; preds = %28
  store i8 1, ptr %7, align 1, !tbaa !11
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct._cu_test_suites_t, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !12
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct._cu_test_suites_t, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  call void @cu_run_fork(ptr noundef %42, ptr noundef %45)
  br label %49

46:                                               ; preds = %28
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct._cu_test_suites_t, ptr %47, i32 1
  store ptr %48, ptr %5, align 8, !tbaa !9
  br label %16, !llvm.loop !15

49:                                               ; preds = %39, %26
  %50 = load ptr, ptr %5, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct._cu_test_suites_t, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = icmp eq ptr %52, null
  br i1 %53, label %59, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct._cu_test_suites_t, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !14
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %67

59:                                               ; preds = %54, %49
  %60 = load ptr, ptr @stderr, align 8, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str, ptr noundef %65) #4
  br label %67

67:                                               ; preds = %59, %54
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %6, align 4, !tbaa !5
  br label %11, !llvm.loop !17

71:                                               ; preds = %11
  %72 = load i8, ptr %7, align 1, !tbaa !11
  %73 = sext i8 %72 to i32
  %74 = icmp eq i32 %73, 1
  br i1 %74, label %75, label %76

75:                                               ; preds = %71
  call void @cu_print_results()
  br label %76

76:                                               ; preds = %75, %71
  br label %100

77:                                               ; preds = %2
  store ptr @cu_test_suites, ptr %5, align 8, !tbaa !9
  br label %78

78:                                               ; preds = %90, %77
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct._cu_test_suites_t, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !12
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %88

83:                                               ; preds = %78
  %84 = load ptr, ptr %5, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct._cu_test_suites_t, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !14
  %87 = icmp ne ptr %86, null
  br label %88

88:                                               ; preds = %83, %78
  %89 = phi i1 [ false, %78 ], [ %87, %83 ]
  br i1 %89, label %90, label %99

90:                                               ; preds = %88
  %91 = load ptr, ptr %5, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct._cu_test_suites_t, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !12
  %94 = load ptr, ptr %5, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct._cu_test_suites_t, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !14
  call void @cu_run_fork(ptr noundef %93, ptr noundef %96)
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct._cu_test_suites_t, ptr %97, i32 1
  store ptr %98, ptr %5, align 8, !tbaa !9
  br label %78, !llvm.loop !18

99:                                               ; preds = %88
  call void @cu_print_results()
  br label %100

100:                                              ; preds = %99, %76
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @cu_run_fork(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
declare hidden void @cu_print_results() #0

; 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 = { nounwind willreturn memory(read) "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 "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"_cu_test_suites_t", !10, i64 0, !10, i64 8}
!14 = !{!13, !10, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


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

@cu_test_suites = external local_unnamed_addr global [0 x %struct._cu_test_suites_t], align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @cu_run(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %.preheader.preheader, label %.preheader38

.preheader.preheader:                             ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.preheader

.preheader38:                                     ; preds = %2
  %4 = load ptr, ptr @cu_test_suites, align 8, !tbaa !5
  %.not46 = icmp eq ptr %4, null
  br i1 %.not46, label %.sink.split, label %.lr.ph

.preheader:                                       ; preds = %.preheader.backedge, %.preheader.preheader
  %indvars.iv = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.be, %.preheader.backedge ]
  %.053 = phi i8 [ 0, %.preheader.preheader ], [ %.053.be, %.preheader.backedge ]
  %5 = load ptr, ptr @cu_test_suites, align 8, !tbaa !5
  %.not3249 = icmp eq ptr %5, null
  br i1 %.not3249, label %.loopexit, label %.lr.ph51

.lr.ph51:                                         ; preds = %.preheader
  %6 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  br label %7

7:                                                ; preds = %.lr.ph51, %15
  %8 = phi ptr [ %5, %.lr.ph51 ], [ %17, %15 ]
  %.02450 = phi ptr [ @cu_test_suites, %.lr.ph51 ], [ %16, %15 ]
  %9 = getelementptr inbounds i8, ptr %.02450, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !10
  %.not33 = icmp eq ptr %10, null
  br i1 %.not33, label %.loopexit, label %11

11:                                               ; preds = %7
  %12 = load ptr, ptr %6, align 8, !tbaa !11
  %13 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %12, ptr noundef nonnull dereferenceable(1) %8) #3
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %.critedge, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %.02450, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %.not32 = icmp eq ptr %17, null
  br i1 %.not32, label %.loopexit, label %7, !llvm.loop !12

.critedge:                                        ; preds = %11
  tail call void @cu_run_fork(ptr noundef nonnull %8, ptr noundef nonnull %10)
  %.pr.pre = load ptr, ptr %.02450, align 8, !tbaa !5
  %18 = icmp eq ptr %.pr.pre, null
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %.critedge
  %20 = getelementptr inbounds i8, ptr %.02450, i64 8
  %.pr = load ptr, ptr %20, align 8, !tbaa !10
  %21 = icmp eq ptr %.pr, null
  br i1 %21, label %.loopexit, label %.thread68

.loopexit:                                        ; preds = %15, %7, %.critedge, %19, %.preheader
  %.136 = phi i8 [ 1, %19 ], [ 1, %.critedge ], [ %.053, %.preheader ], [ %.053, %7 ], [ %.053, %15 ]
  %22 = load ptr, ptr @stderr, align 8, !tbaa !11
  %23 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str, ptr noundef %24) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %26, label %.preheader.backedge

.preheader.backedge:                              ; preds = %.loopexit, %.thread68
  %indvars.iv.be = phi i64 [ %indvars.iv.next, %.loopexit ], [ %indvars.iv.next70, %.thread68 ]
  %.053.be = phi i8 [ %.136, %.loopexit ], [ 1, %.thread68 ]
  br label %.preheader, !llvm.loop !14

.thread68:                                        ; preds = %19
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not71 = icmp eq i64 %indvars.iv.next70, %wide.trip.count
  br i1 %exitcond.not71, label %.sink.split, label %.preheader.backedge

26:                                               ; preds = %.loopexit
  %27 = icmp eq i8 %.136, 1
  br i1 %27, label %.sink.split, label %34

.lr.ph:                                           ; preds = %.preheader38, %31
  %28 = phi ptr [ %33, %31 ], [ %4, %.preheader38 ]
  %.12547 = phi ptr [ %32, %31 ], [ @cu_test_suites, %.preheader38 ]
  %29 = getelementptr inbounds i8, ptr %.12547, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  %.not31 = icmp eq ptr %30, null
  br i1 %.not31, label %.sink.split, label %31

31:                                               ; preds = %.lr.ph
  tail call void @cu_run_fork(ptr noundef nonnull %28, ptr noundef nonnull %30)
  %32 = getelementptr inbounds i8, ptr %.12547, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %.not = icmp eq ptr %33, null
  br i1 %.not, label %.sink.split, label %.lr.ph, !llvm.loop !15

.sink.split:                                      ; preds = %31, %.lr.ph, %.thread68, %.preheader38, %26
  tail call void @cu_print_results()
  br label %34

34:                                               ; preds = %.sink.split, %26
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @cu_run_fork(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @cu_print_results() local_unnamed_addr #0

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nofree 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 #3 = { nounwind willreturn memory(read) }
attributes #4 = { cold 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 0}
!6 = !{!"_cu_test_suites_t", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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