; LLVM IR from sysprog21/shecc :: src (ssa)

; 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.basic_block = type { %struct.insn_list_t, %struct.ph2_ir_list_t, [128 x %struct.bb_connection_t], ptr, ptr, ptr, ptr, ptr, ptr, ptr, [800 x ptr], i32, [800 x ptr], i32, [800 x ptr], i32, [800 x ptr], i32, i32, i32, [64 x ptr], [64 x ptr], i32, i32, i32, i8, [64 x ptr], ptr, [256 x ptr], ptr, ptr, ptr, %struct.symbol_list_t, i32 }
%struct.insn_list_t = type { ptr, ptr }
%struct.ph2_ir_list_t = type { ptr, ptr }
%struct.bb_connection_t = type { ptr, i32 }
%struct.symbol_list_t = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @intersect(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %35, %2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr %6, %7
  br i1 %8, label %9, label %36

9:                                                ; preds = %5
  br label %10

10:                                               ; preds = %18, %9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.basic_block, ptr %11, i32 0, i32 18
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.basic_block, ptr %14, i32 0, i32 18
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = icmp sgt i32 %13, %16
  br i1 %17, label %18, label %22

18:                                               ; preds = %10
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.basic_block, ptr %19, i32 0, i32 6
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  store ptr %21, ptr %3, align 8, !tbaa !5
  br label %10, !llvm.loop !15

22:                                               ; preds = %10
  br label %23

23:                                               ; preds = %31, %22
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.basic_block, ptr %24, i32 0, i32 18
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.basic_block, ptr %27, i32 0, i32 18
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = icmp sgt i32 %26, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %23
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.basic_block, ptr %32, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  store ptr %34, ptr %4, align 8, !tbaa !5
  br label %23, !llvm.loop !17

35:                                               ; preds = %23
  br label %5, !llvm.loop !18

36:                                               ; preds = %5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  ret ptr %37
}

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

!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, !12, i64 27764}
!10 = !{!"basic_block", !11, i64 0, !11, i64 16, !7, i64 32, !6, i64 2080, !6, i64 2088, !6, i64 2096, !6, i64 2104, !6, i64 2112, !6, i64 2120, !6, i64 2128, !7, i64 2136, !12, i64 8536, !7, i64 8544, !12, i64 14944, !7, i64 14952, !12, i64 21352, !7, i64 21360, !12, i64 27760, !12, i64 27764, !12, i64 27768, !7, i64 27776, !7, i64 28288, !12, i64 28800, !12, i64 28804, !12, i64 28808, !13, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !11, i64 31408, !12, i64 31424}
!11 = !{!"", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!10, !6, i64 2104}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @intersect(ptr noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %.not17 = icmp eq ptr %0, %1
  br i1 %.not17, label %._crit_edge, label %.preheader11

.loopexit:                                        ; preds = %.lr.ph15, %.preheader
  %.1.lcssa = phi ptr [ %.019, %.preheader ], [ %15, %.lr.ph15 ]
  %.not = icmp eq ptr %.110.lcssa, %.1.lcssa
  br i1 %.not, label %._crit_edge, label %.preheader11, !llvm.loop !5

.preheader11:                                     ; preds = %2, %.loopexit
  %.019 = phi ptr [ %.1.lcssa, %.loopexit ], [ %1, %2 ]
  %.0918 = phi ptr [ %.110.lcssa, %.loopexit ], [ %0, %2 ]
  %3 = getelementptr inbounds i8, ptr %.019, i64 27764
  %4 = load i32, ptr %3, align 4, !tbaa !7
  %5 = getelementptr inbounds i8, ptr %.0918, i64 27764
  %6 = load i32, ptr %5, align 4, !tbaa !7
  %7 = icmp sgt i32 %6, %4
  br i1 %7, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader11
  %.110.lcssa = phi ptr [ %.0918, %.preheader11 ], [ %10, %.lr.ph ]
  %.lcssa = phi i32 [ %6, %.preheader11 ], [ %12, %.lr.ph ]
  %8 = icmp sgt i32 %4, %.lcssa
  br i1 %8, label %.lr.ph15, label %.loopexit

.lr.ph:                                           ; preds = %.preheader11, %.lr.ph
  %.11012 = phi ptr [ %10, %.lr.ph ], [ %.0918, %.preheader11 ]
  %9 = getelementptr inbounds i8, ptr %.11012, i64 2104
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %10, i64 27764
  %12 = load i32, ptr %11, align 4, !tbaa !7
  %13 = icmp sgt i32 %12, %4
  br i1 %13, label %.lr.ph, label %.preheader, !llvm.loop !16

.lr.ph15:                                         ; preds = %.preheader, %.lr.ph15
  %.114 = phi ptr [ %15, %.lr.ph15 ], [ %.019, %.preheader ]
  %14 = getelementptr inbounds i8, ptr %.114, i64 2104
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %15, i64 27764
  %17 = load i32, ptr %16, align 4, !tbaa !7
  %18 = icmp sgt i32 %17, %.lcssa
  br i1 %18, label %.lr.ph15, label %.loopexit, !llvm.loop !17

._crit_edge:                                      ; preds = %.loopexit, %2
  %.09.lcssa = phi ptr [ %0, %2 ], [ %.110.lcssa, %.loopexit ]
  ret ptr %.09.lcssa
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !13, i64 27764}
!8 = !{!"basic_block", !9, i64 0, !9, i64 16, !11, i64 32, !10, i64 2080, !10, i64 2088, !10, i64 2096, !10, i64 2104, !10, i64 2112, !10, i64 2120, !10, i64 2128, !11, i64 2136, !13, i64 8536, !11, i64 8544, !13, i64 14944, !11, i64 14952, !13, i64 21352, !11, i64 21360, !13, i64 27760, !13, i64 27764, !13, i64 27768, !11, i64 27776, !11, i64 28288, !13, i64 28800, !13, i64 28804, !13, i64 28808, !14, i64 28812, !11, i64 28816, !10, i64 29328, !11, i64 29336, !10, i64 31384, !10, i64 31392, !10, i64 31400, !9, i64 31408, !13, i64 31424}
!9 = !{!"", !10, i64 0, !10, i64 8}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C/C++ TBAA"}
!13 = !{!"int", !11, i64 0}
!14 = !{!"_Bool", !11, i64 0}
!15 = !{!8, !10, i64 2104}
!16 = distinct !{!16, !6}
!17 = distinct !{!17, !6}


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