; LLVM IR from DanEngelbrecht/longtail :: test/main.ll (Z12jc_test_exitv)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z17jc_test_get_statev() #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

10:                                               ; preds = %58, %0
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %59

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.jc_test_fixture, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  store ptr %16, ptr %3, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %46, %13
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %47

20:                                               ; preds = %17
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.jc_test_entry, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = icmp eq ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %23, align 8, !tbaa !18
  %27 = getelementptr inbounds ptr, ptr %26, i64 1
  %28 = load ptr, ptr %27, align 8
  call void %28(ptr noundef nonnull align 8 dereferenceable(8) %23) #3
  br label %29

29:                                               ; preds = %25, %20
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.jc_test_entry, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = icmp eq ptr %32, null
  br i1 %33, label %38, label %34

34:                                               ; preds = %29
  %35 = load ptr, ptr %32, align 8, !tbaa !18
  %36 = getelementptr inbounds ptr, ptr %35, i64 1
  %37 = load ptr, ptr %36, align 8
  call void %37(ptr noundef nonnull align 8 dereferenceable(8) %32) #3
  br label %38

38:                                               ; preds = %34, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %39, ptr %4, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.jc_test_entry, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !21
  store ptr %42, ptr %3, align 8, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = icmp eq ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %38
  call void @_ZdlPvm(ptr noundef %43, i64 noundef 40) #4
  br label %46

46:                                               ; preds = %45, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %17, !llvm.loop !22

47:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %48, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.jc_test_fixture, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !24
  store ptr %51, ptr %2, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %58, label %54

54:                                               ; preds = %47
  %55 = load ptr, ptr %52, align 8, !tbaa !18
  %56 = getelementptr inbounds ptr, ptr %55, i64 1
  %57 = load ptr, ptr %56, align 8
  call void %57(ptr noundef nonnull align 8 dereferenceable(104) %52) #3
  br label %58

58:                                               ; preds = %54, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %10, !llvm.loop !25

59:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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 = { nobuiltin 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 = { builtin 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, !6, i64 224}
!10 = !{!"_ZTS13jc_test_state", !7, i64 0, !7, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !11, i64 232, !12, i64 256, !12, i64 259}
!11 = !{!"_ZTS13jc_test_stats", !12, i64 0, !12, i64 4, !12, i64 6, !12, i64 8, !12, i64 12, !13, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"_ZTS15jc_test_fixture", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !12, i64 88, !12, i64 91, !12, i64 91, !12, i64 91, !12, i64 91, !12, i64 92, !12, i64 96, !12, i64 97, !12, i64 99, !12, i64 100}
!16 = !{!17, !6, i64 16}
!17 = !{!"_ZTS13jc_test_entry", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 32}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!17, !6, i64 24}
!21 = !{!17, !6, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!15, !6, i64 8}
!25 = distinct !{!25, !23}


; 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z17jc_test_get_statev() local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12jc_test_exitv() local_unnamed_addr #0 {
  %1 = tail call noundef ptr @_Z17jc_test_get_statev()
  %2 = getelementptr inbounds i8, ptr %1, i64 224
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not18 = icmp eq ptr %3, null
  br i1 %.not18, label %._crit_edge22, label %.lr.ph21

.lr.ph21:                                         ; preds = %0, %._crit_edge
  %.019 = phi ptr [ %24, %._crit_edge ], [ %3, %0 ]
  %4 = getelementptr inbounds i8, ptr %.019, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  %.not1516 = icmp eq ptr %5, null
  br i1 %.not1516, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph21, %21
  %.01217 = phi ptr [ %22, %21 ], [ %5, %.lr.ph21 ]
  %6 = getelementptr inbounds i8, ptr %.01217, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %8 = icmp eq ptr %7, null
  br i1 %8, label %13, label %9

9:                                                ; preds = %.lr.ph
  %10 = load ptr, ptr %7, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8
  tail call void %12(ptr noundef nonnull align 8 dereferenceable(8) %7) #2
  br label %13

13:                                               ; preds = %9, %.lr.ph
  %14 = getelementptr inbounds i8, ptr %.01217, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = icmp eq ptr %15, null
  br i1 %16, label %21, label %17

17:                                               ; preds = %13
  %18 = load ptr, ptr %15, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8
  tail call void %20(ptr noundef nonnull align 8 dereferenceable(8) %15) #2
  br label %21

21:                                               ; preds = %17, %13
  %22 = load ptr, ptr %.01217, align 8, !tbaa !20
  tail call void @_ZdlPvm(ptr noundef nonnull %.01217, i64 noundef 40) #3
  %.not15 = icmp eq ptr %22, null
  br i1 %.not15, label %._crit_edge, label %.lr.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %21, %.lr.ph21
  %23 = getelementptr inbounds i8, ptr %.019, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !23
  %25 = load ptr, ptr %.019, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load ptr, ptr %26, align 8
  tail call void %27(ptr noundef nonnull align 8 dereferenceable(104) %.019) #2
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %._crit_edge22, label %.lr.ph21, !llvm.loop !24

._crit_edge22:                                    ; preds = %._crit_edge, %0
  ret void
}

attributes #0 = { 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 #1 = { nobuiltin 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 = { nounwind }
attributes #3 = { builtin 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, !9, i64 224}
!6 = !{!"_ZTS13jc_test_state", !7, i64 0, !7, i64 200, !9, i64 208, !9, i64 216, !9, i64 224, !10, i64 232, !11, i64 256, !11, i64 259}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"_ZTS13jc_test_stats", !11, i64 0, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 12, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !9, i64 16}
!14 = !{!"_ZTS15jc_test_fixture", !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !9, i64 56, !10, i64 64, !11, i64 88, !11, i64 91, !11, i64 91, !11, i64 91, !11, i64 91, !11, i64 92, !11, i64 96, !11, i64 97, !11, i64 99, !11, i64 100}
!15 = !{!16, !9, i64 16}
!16 = !{!"_ZTS13jc_test_entry", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !11, i64 32, !11, i64 32}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = !{!16, !9, i64 24}
!20 = !{!16, !9, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!14, !9, i64 8}
!24 = distinct !{!24, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass