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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12jc_test_logfPK15jc_test_fixturePK13jc_test_entryPK13jc_test_statsiPKcz(ptr noundef, ptr noundef, ptr noundef, i32 noundef, 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: mustprogress uwtable
declare dso_local noundef ptr @_Z17jc_test_get_statev() #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12jc_test_exitv() #0

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

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

14:                                               ; preds = %11
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZL19jc_test_run_fixtureP15jc_test_fixture(ptr noundef %15)
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.jc_test_fixture, ptr %16, i32 0, i32 8
  %18 = getelementptr inbounds %struct.jc_test_stats, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.jc_test_state, ptr %20, i32 0, i32 5
  %22 = getelementptr inbounds %struct.jc_test_stats, ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !17
  %24 = add nsw i32 %23, %19
  store i32 %24, ptr %22, align 8, !tbaa !17
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.jc_test_fixture, ptr %25, i32 0, i32 8
  %27 = getelementptr inbounds %struct.jc_test_stats, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !18
  %29 = load ptr, ptr %1, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jc_test_state, ptr %29, i32 0, i32 5
  %31 = getelementptr inbounds %struct.jc_test_stats, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !19
  %33 = add nsw i32 %32, %28
  store i32 %33, ptr %31, align 8, !tbaa !19
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.jc_test_fixture, ptr %34, i32 0, i32 8
  %36 = getelementptr inbounds %struct.jc_test_stats, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4
  %38 = shl i32 %37, 16
  %39 = ashr i32 %38, 16
  %40 = load ptr, ptr %1, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.jc_test_state, ptr %40, i32 0, i32 5
  %42 = getelementptr inbounds %struct.jc_test_stats, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4
  %44 = shl i32 %43, 16
  %45 = ashr i32 %44, 16
  %46 = add nsw i32 %45, %39
  %47 = load i32, ptr %42, align 4
  %48 = and i32 %46, 65535
  %49 = and i32 %47, -65536
  %50 = or i32 %49, %48
  store i32 %50, ptr %42, align 4
  %51 = shl i32 %48, 16
  %52 = ashr i32 %51, 16
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.jc_test_fixture, ptr %53, i32 0, i32 8
  %55 = getelementptr inbounds %struct.jc_test_stats, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4
  %57 = ashr i32 %56, 16
  %58 = load ptr, ptr %1, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.jc_test_state, ptr %58, i32 0, i32 5
  %60 = getelementptr inbounds %struct.jc_test_stats, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4
  %62 = ashr i32 %61, 16
  %63 = add nsw i32 %62, %57
  %64 = load i32, ptr %60, align 4
  %65 = and i32 %63, 65535
  %66 = shl i32 %65, 16
  %67 = and i32 %64, 65535
  %68 = or i32 %67, %66
  store i32 %68, ptr %60, align 4
  %69 = shl i32 %65, 16
  %70 = ashr i32 %69, 16
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.jc_test_fixture, ptr %71, i32 0, i32 8
  %73 = getelementptr inbounds %struct.jc_test_stats, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !20
  %75 = load ptr, ptr %1, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.jc_test_state, ptr %75, i32 0, i32 5
  %77 = getelementptr inbounds %struct.jc_test_stats, ptr %76, i32 0, i32 3
  %78 = load i32, ptr %77, align 4, !tbaa !21
  %79 = add nsw i32 %78, %74
  store i32 %79, ptr %77, align 4, !tbaa !21
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.jc_test_fixture, ptr %80, i32 0, i32 8
  %82 = getelementptr inbounds %struct.jc_test_stats, ptr %81, i32 0, i32 4
  %83 = load i64, ptr %82, align 8, !tbaa !22
  %84 = load ptr, ptr %1, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.jc_test_state, ptr %84, i32 0, i32 5
  %86 = getelementptr inbounds %struct.jc_test_stats, ptr %85, i32 0, i32 4
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = add i64 %87, %83
  store i64 %88, ptr %86, align 8, !tbaa !9
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.jc_test_fixture, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !23
  store ptr %91, ptr %2, align 8, !tbaa !5
  br label %11, !llvm.loop !24

92:                                               ; preds = %11
  %93 = load ptr, ptr %1, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.jc_test_state, ptr %93, i32 0, i32 5
  call void (ptr, ptr, ptr, i32, ptr, ...) @_Z12jc_test_logfPK15jc_test_fixturePK13jc_test_entryPK13jc_test_statsiPKcz(ptr noundef null, ptr noundef null, ptr noundef %94, i32 noundef 5, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %95 = load ptr, ptr %1, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.jc_test_state, ptr %95, i32 0, i32 5
  %97 = getelementptr inbounds %struct.jc_test_stats, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4
  %99 = shl i32 %98, 16
  %100 = ashr i32 %99, 16
  store i32 %100, ptr %3, align 4, !tbaa !26
  call void @_Z12jc_test_exitv()
  %101 = load i32, ptr %3, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret i32 %101
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19jc_test_run_fixtureP15jc_test_fixture(ptr noundef) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !13, i64 248}
!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 = !{!10, !6, i64 224}
!15 = !{!16, !12, i64 72}
!16 = !{!"_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}
!17 = !{!10, !12, i64 240}
!18 = !{!16, !12, i64 64}
!19 = !{!10, !12, i64 232}
!20 = !{!16, !12, i64 76}
!21 = !{!10, !12, i64 244}
!22 = !{!16, !13, i64 80}
!23 = !{!16, !6, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!12, !12, i64 0}


; 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 void @_Z12jc_test_logfPK15jc_test_fixturePK13jc_test_entryPK13jc_test_statsiPKcz(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12jc_test_exitv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -32768, 32768) i32 @_Z15jc_test_run_allv() local_unnamed_addr #0 {
  %1 = tail call noundef ptr @_Z17jc_test_get_statev()
  %2 = getelementptr inbounds i8, ptr %1, i64 232
  %3 = getelementptr inbounds i8, ptr %1, i64 248
  store i64 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 224
  %.019 = load ptr, ptr %4, align 8, !tbaa !13
  %.not20 = icmp eq ptr %.019, null
  br i1 %.not20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %5 = getelementptr inbounds i8, ptr %1, i64 240
  %6 = getelementptr inbounds i8, ptr %1, i64 236
  %7 = getelementptr inbounds i8, ptr %1, i64 244
  br label %8

8:                                                ; preds = %.lr.ph, %8
  %.021 = phi ptr [ %.019, %.lr.ph ], [ %.0, %8 ]
  tail call void @_ZL19jc_test_run_fixtureP15jc_test_fixture(ptr noundef nonnull %.021)
  %9 = getelementptr inbounds i8, ptr %.021, i64 64
  %10 = getelementptr inbounds i8, ptr %.021, i64 72
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = load i32, ptr %5, align 8, !tbaa !16
  %13 = add nsw i32 %12, %11
  store i32 %13, ptr %5, align 8, !tbaa !16
  %14 = load i32, ptr %9, align 8, !tbaa !17
  %15 = load i32, ptr %2, align 8, !tbaa !18
  %16 = add nsw i32 %15, %14
  store i32 %16, ptr %2, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %.021, i64 68
  %18 = load i32, ptr %17, align 4
  %19 = load i32, ptr %6, align 4
  %20 = add i32 %19, %18
  %21 = and i32 %20, 65535
  %22 = and i32 %19, -65536
  %23 = or disjoint i32 %21, %22
  store i32 %23, ptr %6, align 4
  %24 = load i32, ptr %17, align 4
  %25 = add i32 %24, %22
  %26 = and i32 %25, -65536
  %27 = or disjoint i32 %26, %21
  store i32 %27, ptr %6, align 4
  %28 = getelementptr inbounds i8, ptr %.021, i64 76
  %29 = load i32, ptr %28, align 4, !tbaa !19
  %30 = load i32, ptr %7, align 4, !tbaa !20
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr %7, align 4, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %.021, i64 80
  %33 = load i64, ptr %32, align 8, !tbaa !21
  %34 = load i64, ptr %3, align 8, !tbaa !5
  %35 = add i64 %34, %33
  store i64 %35, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %.021, i64 8
  %.0 = load ptr, ptr %36, align 8, !tbaa !13
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %8, !llvm.loop !22

._crit_edge:                                      ; preds = %8, %0
  tail call void (ptr, ptr, ptr, i32, ptr, ...) @_Z12jc_test_logfPK15jc_test_fixturePK13jc_test_entryPK13jc_test_statsiPKcz(ptr noundef null, ptr noundef null, ptr noundef nonnull %2, i32 noundef 5, ptr noundef null)
  %37 = getelementptr inbounds i8, ptr %1, i64 236
  %38 = load i32, ptr %37, align 4
  %39 = shl i32 %38, 16
  %40 = ashr exact i32 %39, 16
  tail call void @_Z12jc_test_exitv()
  ret i32 %40
}

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

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

!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, !12, i64 248}
!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 = !{!9, !9, i64 0}
!14 = !{!15, !11, i64 72}
!15 = !{!"_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}
!16 = !{!6, !11, i64 240}
!17 = !{!15, !11, i64 64}
!18 = !{!6, !11, i64 232}
!19 = !{!15, !11, i64 76}
!20 = !{!6, !11, i64 244}
!21 = !{!15, !12, i64 80}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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