; 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
@UnityStrExpected = external hidden constant [11 x i8], align 1
@UnityStrWas = external hidden constant [6 x i8], align 1
@UnityStrPointless = external hidden constant [55 x i8], align 16
@UnityStrElement = external hidden constant [10 x i8], align 1
@UnityStrMemory = external hidden constant [18 x i8], align 16
@UnityStrByte = external hidden constant [7 x i8], align 1

; 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 @UnityPrintNumberByStyle(i64 noundef, i32 noundef) #0

; 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 @UnityAssertEqualMemory(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store i64 %5, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %18, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %19, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %20 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %20, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %21 = load i64, ptr getelementptr inbounds (%struct._Unity, ptr @Unity, i32 0, i32 8), align 8, !tbaa !13
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %26, label %23

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

26:                                               ; preds = %23, %6
  store i32 1, ptr %17, align 4
  br label %97

27:                                               ; preds = %23
  %28 = load i32, ptr %15, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %33, label %30

30:                                               ; preds = %27
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %36

33:                                               ; preds = %30, %27
  %34 = load i64, ptr %12, align 8, !tbaa !11
  call void @UnityTestResultsFailBegin(i64 noundef %34)
  call void @UnityPrint(ptr noundef @UnityStrPointless)
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  call void @UnityAddMsgIfSpecified(ptr noundef %35)
  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

36:                                               ; preds = %30
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %12, align 8, !tbaa !11
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = call i32 @UnityCheckArraysForNull(ptr noundef %37, ptr noundef %38, i64 noundef %39, ptr noundef %40)
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %44

43:                                               ; preds = %36
  store i32 1, ptr %17, align 4
  br label %97

44:                                               ; preds = %36
  br label %45

45:                                               ; preds = %95, %44
  %46 = load i32, ptr %15, align 4, !tbaa !9
  %47 = add i32 %46, -1
  store i32 %47, ptr %15, align 4, !tbaa !9
  %48 = icmp ne i32 %46, 0
  br i1 %48, label %49, label %96

49:                                               ; preds = %45
  %50 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %50, ptr %16, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %86, %49
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = add i32 %52, -1
  store i32 %53, ptr %16, align 4, !tbaa !9
  %54 = icmp ne i32 %52, 0
  br i1 %54, label %55, label %95

55:                                               ; preds = %51
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = load i8, ptr %56, align 1, !tbaa !16
  %58 = zext i8 %57 to i32
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load i8, ptr %59, align 1, !tbaa !16
  %61 = zext i8 %60 to i32
  %62 = icmp ne i32 %58, %61
  br i1 %62, label %63, label %86

63:                                               ; preds = %55
  %64 = load i64, ptr %12, align 8, !tbaa !11
  call void @UnityTestResultsFailBegin(i64 noundef %64)
  call void @UnityPrint(ptr noundef @UnityStrMemory)
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = icmp ugt i32 %65, 1
  br i1 %66, label %67, label %73

67:                                               ; preds = %63
  call void @UnityPrint(ptr noundef @UnityStrElement)
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = sub i32 %68, %69
  %71 = sub i32 %70, 1
  %72 = zext i32 %71 to i64
  call void @UnityPrintNumberUnsigned(i64 noundef %72)
  br label %73

73:                                               ; preds = %67, %63
  call void @UnityPrint(ptr noundef @UnityStrByte)
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = load i32, ptr %16, align 4, !tbaa !9
  %76 = sub i32 %74, %75
  %77 = sub i32 %76, 1
  %78 = zext i32 %77 to i64
  call void @UnityPrintNumberUnsigned(i64 noundef %78)
  call void @UnityPrint(ptr noundef @UnityStrExpected)
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = load i8, ptr %79, align 1, !tbaa !16
  %81 = zext i8 %80 to i64
  call void @UnityPrintNumberByStyle(i64 noundef %81, i32 noundef 65)
  call void @UnityPrint(ptr noundef @UnityStrWas)
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load i8, ptr %82, align 1, !tbaa !16
  %84 = zext i8 %83 to i64
  call void @UnityPrintNumberByStyle(i64 noundef %84, i32 noundef 65)
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  call void @UnityAddMsgIfSpecified(ptr noundef %85)
  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

86:                                               ; preds = %55
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = ptrtoint ptr %87 to i64
  %89 = add i64 %88, 1
  %90 = inttoptr i64 %89 to ptr
  store ptr %90, ptr %13, align 8, !tbaa !5
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = ptrtoint ptr %91 to i64
  %93 = add i64 %92, 1
  %94 = inttoptr i64 %93 to ptr
  store ptr %94, ptr %14, align 8, !tbaa !5
  br label %51, !llvm.loop !17

95:                                               ; preds = %51
  br label %45, !llvm.loop !19

96:                                               ; preds = %45
  store i32 0, ptr %17, align 4
  br label %97

97:                                               ; preds = %96, %43, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %98 = load i32, ptr %17, align 4
  switch i32 %98, label %100 [
    i32 0, label %99
    i32 1, label %99
  ]

99:                                               ; preds = %97, %97
  ret void

100:                                              ; preds = %97
  unreachable
}

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 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
@UnityStrExpected = external hidden constant [11 x i8], align 1
@UnityStrWas = external hidden constant [6 x i8], align 1
@UnityStrPointless = external hidden constant [55 x i8], align 16
@UnityStrElement = external hidden constant [10 x i8], align 1
@UnityStrMemory = external hidden constant [18 x i8], align 16
@UnityStrByte = external hidden constant [7 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @UnityPrintNumberByStyle(i64 noundef, i32 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 @UnityAssertEqualMemory(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = load i64, ptr getelementptr inbounds (i8, ptr @Unity, i64 64), align 8, !tbaa !5
  %8 = icmp ne i64 %7, 0
  %9 = load i64, ptr getelementptr inbounds (i8, ptr @Unity, i64 72), align 8
  %10 = icmp ne i64 %9, 0
  %or.cond = select i1 %8, i1 true, i1 %10
  br i1 %or.cond, label %.loopexit38, label %11

11:                                               ; preds = %6
  %12 = icmp eq i32 %3, 0
  %13 = icmp eq i32 %2, 0
  %or.cond3 = or i1 %13, %12
  br i1 %or.cond3, label %14, label %15

14:                                               ; preds = %11
  tail call void @UnityTestResultsFailBegin(i64 noundef %5)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrPointless)
  tail call void @UnityAddMsgIfSpecified(ptr noundef %4)
  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

15:                                               ; preds = %11
  %16 = tail call i32 @UnityCheckArraysForNull(ptr noundef %0, ptr noundef %1, i64 noundef %5, ptr noundef %4)
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %.loopexit38, label %.preheader

..loopexit_crit_edge:                             ; preds = %33
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %.loopexit38, label %.preheader, !llvm.loop !11

.preheader:                                       ; preds = %15, %..loopexit_crit_edge
  %.02951 = phi i32 [ %18, %..loopexit_crit_edge ], [ %3, %15 ]
  %.03050 = phi ptr [ %40, %..loopexit_crit_edge ], [ %1, %15 ]
  %.03149 = phi ptr [ %37, %..loopexit_crit_edge ], [ %0, %15 ]
  %18 = add i32 %.02951, -1
  br label %19

19:                                               ; preds = %.preheader, %33
  %.046 = phi i32 [ %2, %.preheader ], [ %34, %33 ]
  %.145 = phi ptr [ %.03050, %.preheader ], [ %40, %33 ]
  %.13244 = phi ptr [ %.03149, %.preheader ], [ %37, %33 ]
  %20 = load i8, ptr %.13244, align 1, !tbaa !13
  %21 = load i8, ptr %.145, align 1, !tbaa !13
  %.not36 = icmp eq i8 %20, %21
  br i1 %.not36, label %33, label %22

22:                                               ; preds = %19
  tail call void @UnityTestResultsFailBegin(i64 noundef %5)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrMemory)
  %.not52 = icmp eq i32 %3, 1
  br i1 %.not52, label %26, label %23

23:                                               ; preds = %22
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrElement)
  %24 = sub i32 %3, %.02951
  %25 = zext i32 %24 to i64
  tail call void @UnityPrintNumberUnsigned(i64 noundef %25)
  br label %26

26:                                               ; preds = %23, %22
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrByte)
  %27 = sub i32 %2, %.046
  %28 = zext i32 %27 to i64
  tail call void @UnityPrintNumberUnsigned(i64 noundef %28)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrExpected)
  %29 = load i8, ptr %.13244, align 1, !tbaa !13
  %30 = zext i8 %29 to i64
  tail call void @UnityPrintNumberByStyle(i64 noundef %30, i32 noundef 65)
  tail call void @UnityPrint(ptr noundef nonnull @UnityStrWas)
  %31 = load i8, ptr %.145, align 1, !tbaa !13
  %32 = zext i8 %31 to i64
  tail call void @UnityPrintNumberByStyle(i64 noundef %32, i32 noundef 65)
  tail call void @UnityAddMsgIfSpecified(ptr noundef %4)
  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

33:                                               ; preds = %19
  %34 = add i32 %.046, -1
  %35 = ptrtoint ptr %.13244 to i64
  %36 = add i64 %35, 1
  %37 = inttoptr i64 %36 to ptr
  %38 = ptrtoint ptr %.145 to i64
  %39 = add i64 %38, 1
  %40 = inttoptr i64 %39 to ptr
  %.not35 = icmp eq i32 %34, 0
  br i1 %.not35, label %..loopexit_crit_edge, label %19, !llvm.loop !14

.loopexit38:                                      ; preds = %..loopexit_crit_edge, %15, %6
  ret void
}

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !12}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass