; LLVM IR from HandmadeMath/HandmadeMath :: test/hmm_test.ll (Z22hmt_check_all_coveragev)

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

@_hmt_num_covercases = external dso_local global i32, align 4
@_hmt_covercases = external dso_local global ptr, align 8
@_hmt_num_covererrors = external dso_local global i32, align 4
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [66 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22hmt_check_all_coveragev() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.hmt_covercase_struct, align 8
  %5 = alloca i32, align 4
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %33, %0
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr @_hmt_num_covercases, align 4, !tbaa !5
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %36

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  %13 = load ptr, ptr @_hmt_covercases, align 8, !tbaa !9
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %13, i64 %15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %16, i64 24, i1 false), !tbaa.struct !11
  %17 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %4, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %4, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = icmp ne i32 %18, %20
  br i1 %21, label %22, label %32

22:                                               ; preds = %12
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  %25 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %4, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %4, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !12
  %29 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %4, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !14
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %26, i32 noundef %28, i32 noundef %30)
  br label %32

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

33:                                               ; preds = %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !16

36:                                               ; preds = %11
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %44

42:                                               ; preds = %36
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %44

44:                                               ; preds = %42, %39
  %45 = load i32, ptr @_hmt_num_covercases, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %45, i32 noundef %46)
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %50 = load i32, ptr @_hmt_num_covererrors, align 4, !tbaa !5
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %44
  %53 = load i32, ptr @_hmt_num_covererrors, align 4, !tbaa !5
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %53)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %59

55:                                               ; preds = %44
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = icmp sgt i32 %56, 0
  %58 = zext i1 %57 to i32
  store i32 %58, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %59

59:                                               ; preds = %55, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %60 = load i32, ptr %1, align 4
  ret i32 %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { 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 = !{i64 0, i64 8, !9, i64 8, i64 4, !5, i64 12, i64 4, !5, i64 16, i64 8, !9}
!12 = !{!13, !6, i64 8}
!13 = !{!"_ZTS20hmt_covercase_struct", !10, i64 0, !6, i64 8, !6, i64 12, !10, i64 16}
!14 = !{!13, !6, i64 12}
!15 = !{!13, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%struct.hmt_covercase_struct = type { ptr, i32, i32, ptr }

@_hmt_num_covercases = external dso_local local_unnamed_addr global i32, align 4
@_hmt_covercases = external dso_local local_unnamed_addr global ptr, align 8
@_hmt_num_covererrors = external dso_local local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z22hmt_check_all_coveragev() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %2 = load i32, ptr @_hmt_num_covercases, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %0
  %.pre16 = load ptr, ptr @_hmt_covercases, align 8, !tbaa !9
  br label %.lr.ph

._crit_edge:                                      ; preds = %11
  %4 = icmp sgt i32 %.1, 0
  br i1 %4, label %16, label %._crit_edge.thread

.lr.ph:                                           ; preds = %.lr.ph.preheader, %11
  %5 = phi i32 [ %2, %.lr.ph.preheader ], [ %12, %11 ]
  %6 = phi ptr [ %.pre16, %.lr.ph.preheader ], [ %13, %11 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %11 ]
  %.01014 = phi i32 [ 0, %.lr.ph.preheader ], [ %.1, %11 ]
  %7 = getelementptr inbounds %struct.hmt_covercase_struct, ptr %6, i64 %indvars.iv
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 12
  %.sroa.6.0.copyload = load i32, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  %.not = icmp eq i32 %.sroa.4.0.copyload, %.sroa.6.0.copyload
  br i1 %.not, label %11, label %8

8:                                                ; preds = %.lr.ph
  %.sroa.0.0.copyload = load ptr, ptr %7, align 8, !tbaa !9
  %9 = add nsw i32 %.01014, 1
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %.sroa.0.0.copyload, i32 noundef %.sroa.4.0.copyload, i32 noundef %.sroa.6.0.copyload)
  %.pre = load ptr, ptr @_hmt_covercases, align 8, !tbaa !9
  %.pre17 = load i32, ptr @_hmt_num_covercases, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %8, %.lr.ph
  %12 = phi i32 [ %.pre17, %8 ], [ %5, %.lr.ph ]
  %13 = phi ptr [ %.pre, %8 ], [ %6, %.lr.ph ]
  %.1 = phi i32 [ %9, %8 ], [ %.01014, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = sext i32 %12 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !11

16:                                               ; preds = %._crit_edge
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %._crit_edge, %0, %16
  %.str.8.sink = phi ptr [ @.str.7, %16 ], [ @.str.8, %0 ], [ @.str.8, %._crit_edge ]
  %18 = phi i32 [ 1, %16 ], [ 0, %0 ], [ 0, %._crit_edge ]
  %.010.lcssa19 = phi i32 [ %.1, %16 ], [ 0, %0 ], [ %.1, %._crit_edge ]
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.8.sink)
  %20 = load i32, ptr @_hmt_num_covercases, align 4, !tbaa !5
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %20, i32 noundef %.010.lcssa19)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %24 = load i32, ptr @_hmt_num_covererrors, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %._crit_edge.thread
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %24)
  br label %28

28:                                               ; preds = %._crit_edge.thread, %26
  %.0 = phi i32 [ 1, %26 ], [ %18, %._crit_edge.thread ]
  ret i32 %.0
}

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

!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"}


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