; LLVM IR from ryanlayer/giggle :: test/unit/unity (unity)

; 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._Unity = type { ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@Unity = external dso_local global %struct._Unity, align 8
@UnityStrPointless = external hidden constant [55 x i8], align 16
@UnityStrElement = external hidden constant [10 x i8], align 1
@UnityStrDelta = external hidden constant [26 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @UnityPrint(ptr noundef) #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: nounwind uwtable
declare dso_local void @UnityPrintNumberUnsigned(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @UnityTestResultsFailBegin(i64 noundef) #0

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

; Function Attrs: noreturn nounwind
declare void @longjmp(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @UnityCheckArraysForNull(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @UnityAssertEqualFloatArray(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %15 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %15, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %16, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %17, ptr %13, align 8, !tbaa !5
  %18 = load i64, ptr getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 8), align 8, !tbaa !13
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %23, label %20

20:                                               ; preds = %5
  %21 = load i64, ptr getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 9), align 8, !tbaa !15
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %20, %5
  store i32 1, ptr %14, align 4
  br label %67

24:                                               ; preds = %20
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load i64, ptr %10, align 8, !tbaa !11
  call void @UnityTestResultsFailBegin(i64 noundef %28)
  call void @UnityPrint(ptr noundef @UnityStrPointless)
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  call void @UnityAddMsgIfSpecified(ptr noundef %29)
  store i64 1, ptr getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 8), align 8, !tbaa !13
  call void @longjmp(ptr noundef getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 10), i32 noundef 1) #4
  unreachable

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i64, ptr %10, align 8, !tbaa !11
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call i32 @UnityCheckArraysForNull(ptr noundef %31, ptr noundef %32, i64 noundef %33, ptr noundef %34)
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %30
  store i32 1, ptr %14, align 4
  br label %67

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %61, %38
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = add i32 %40, -1
  store i32 %41, ptr %11, align 4, !tbaa !9
  %42 = icmp ne i32 %40, 0
  br i1 %42, label %43, label %66

43:                                               ; preds = %39
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load float, ptr %44, align 4, !tbaa !16
  %46 = fmul float %45, 0x3EE4F8B580000000
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = load float, ptr %47, align 4, !tbaa !16
  %49 = load ptr, ptr %13, align 8, !tbaa !5
  %50 = load float, ptr %49, align 4, !tbaa !16
  %51 = call i32 @UnityFloatsWithin(float noundef %46, float noundef %48, float noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %61, label %53

53:                                               ; preds = %43
  %54 = load i64, ptr %10, align 8, !tbaa !11
  call void @UnityTestResultsFailBegin(i64 noundef %54)
  call void @UnityPrint(ptr noundef @UnityStrElement)
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = sub i32 %55, %56
  %58 = sub i32 %57, 1
  %59 = zext i32 %58 to i64
  call void @UnityPrintNumberUnsigned(i64 noundef %59)
  call void @UnityPrint(ptr noundef @UnityStrDelta)
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  call void @UnityAddMsgIfSpecified(ptr noundef %60)
  store i64 1, ptr getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 8), align 8, !tbaa !13
  call void @longjmp(ptr noundef getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 10), i32 noundef 1) #4
  unreachable

61:                                               ; preds = %43
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds float, ptr %62, i32 1
  store ptr %63, ptr %12, align 8, !tbaa !5
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds float, ptr %64, i32 1
  store ptr %65, ptr %13, align 8, !tbaa !5
  br label %39, !llvm.loop !18

66:                                               ; preds = %39
  store i32 0, ptr %14, align 4
  br label %67

67:                                               ; preds = %66, %37, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %68 = load i32, ptr %14, align 4
  switch i32 %68, label %70 [
    i32 0, label %69
    i32 1, label %69
  ]

69:                                               ; preds = %67, %67
  ret void

70:                                               ; preds = %67
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden i32 @UnityFloatsWithin(float noundef, float noundef, float noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 64}
!14 = !{!"_Unity", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !7, i64 80}
!15 = !{!14, !12, i64 72}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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._Unity = type { ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, [1 x %struct.__jmp_buf_tag] }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@Unity = external dso_local global %struct._Unity, align 8
@UnityStrPointless = external hidden constant [55 x i8], align 16
@UnityStrElement = external hidden constant [10 x i8], align 1
@UnityStrDelta = external hidden constant [26 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @UnityPrint(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @UnityPrintNumberUnsigned(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @UnityTestResultsFailBegin(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: noreturn nounwind
declare void @longjmp(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @UnityCheckArraysForNull(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @UnityAssertEqualFloatArray(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @Unity, i64 64), align 8, !tbaa !5
  %7 = icmp ne i64 %6, 0
  %8 = load i64, ptr getelementptr inbounds (i8, ptr @Unity, i64 72), align 8
  %9 = icmp ne i64 %8, 0
  %or.cond = select i1 %7, i1 true, i1 %9
  br i1 %or.cond, label %.loopexit, label %10

10:                                               ; preds = %5
  %11 = icmp eq i32 %2, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %10
  tail call void @UnityTestResultsFailBegin(i64 noundef %4)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrPointless)
  tail call void @UnityAddMsgIfSpecified(ptr noundef %3)
  store i64 1, ptr getelementptr inbounds (i8, ptr @Unity, i64 64), align 8, !tbaa !5
  tail call void @longjmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @Unity, i64 80), i32 noundef 1) #2
  unreachable

13:                                               ; preds = %10
  %14 = tail call i32 @UnityCheckArraysForNull(ptr noundef %0, ptr noundef %1, i64 noundef %4, ptr noundef %3)
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %13, %23
  %.027 = phi ptr [ %26, %23 ], [ %1, %13 ]
  %.02026 = phi ptr [ %25, %23 ], [ %0, %13 ]
  %.02125 = phi i32 [ %24, %23 ], [ %2, %13 ]
  %16 = load float, ptr %.02026, align 4, !tbaa !11
  %17 = fmul float %16, 0x3EE4F8B580000000
  %18 = load float, ptr %.027, align 4, !tbaa !11
  %19 = tail call i32 @UnityFloatsWithin(float noundef %17, float noundef %16, float noundef %18)
  %.not23 = icmp eq i32 %19, 0
  br i1 %.not23, label %20, label %23

20:                                               ; preds = %.preheader
  tail call void @UnityTestResultsFailBegin(i64 noundef %4)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrElement)
  %21 = sub i32 %2, %.02125
  %22 = zext i32 %21 to i64
  tail call void @UnityPrintNumberUnsigned(i64 noundef %22)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrDelta)
  tail call void @UnityAddMsgIfSpecified(ptr noundef %3)
  store i64 1, ptr getelementptr inbounds (i8, ptr @Unity, i64 64), align 8, !tbaa !5
  tail call void @longjmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @Unity, i64 80), i32 noundef 1) #2
  unreachable

23:                                               ; preds = %.preheader
  %24 = add i32 %.02125, -1
  %25 = getelementptr inbounds i8, ptr %.02026, i64 4
  %26 = getelementptr inbounds i8, ptr %.027, i64 4
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %.loopexit, label %.preheader, !llvm.loop !13

.loopexit:                                        ; preds = %23, %13, %5
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @UnityFloatsWithin(float noundef, float noundef, float noundef) 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 = { 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 #2 = { 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, !10, i64 64}
!6 = !{!"_Unity", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !8, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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