; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

11:                                               ; preds = %28, %2
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 128
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %31

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.basic_block, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %17, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.bb_connection_t, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %27

24:                                               ; preds = %15
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %24, %15
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !13

31:                                               ; preds = %14
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  store i32 1, ptr %7, align 4
  br label %84

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %80, %35
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 128
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %83

40:                                               ; preds = %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.basic_block, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %42, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.bb_connection_t, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %79

49:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.basic_block, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %51, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.bb_connection_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  store ptr %56, ptr %9, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %74, %49
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.basic_block, ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = icmp ne ptr %58, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %57
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %78

64:                                               ; preds = %57
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.basic_block, ptr %66, i32 0, i32 20
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.basic_block, ptr %68, i32 0, i32 22
  %70 = load i32, ptr %69, align 8, !tbaa !19
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %69, align 8, !tbaa !19
  %72 = sext i32 %70 to i64
  %73 = getelementptr inbounds [64 x ptr], ptr %67, i64 0, i64 %72
  store ptr %65, ptr %73, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %64
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.basic_block, ptr %75, i32 0, i32 6
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  store ptr %77, ptr %9, align 8, !tbaa !5
  br label %57, !llvm.loop !20

78:                                               ; preds = %63
  br label %79

79:                                               ; preds = %78, %40
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !9
  br label %36, !llvm.loop !21

83:                                               ; preds = %39
  store i32 0, ptr %7, align 4
  br label %84

84:                                               ; preds = %83, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %85 = load i32, ptr %7, align 4
  switch i32 %85, label %87 [
    i32 0, label %86
    i32 1, label %86
  ]

86:                                               ; preds = %84, %84
  ret void

87:                                               ; preds = %84
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !10, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 2104}
!16 = !{!"basic_block", !17, i64 0, !17, 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, !10, i64 8536, !7, i64 8544, !10, i64 14944, !7, i64 14952, !10, i64 21352, !7, i64 21360, !10, i64 27760, !10, i64 27764, !10, i64 27768, !7, i64 27776, !7, i64 28288, !10, i64 28800, !10, i64 28804, !10, i64 28808, !18, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !17, i64 31408, !10, i64 31424}
!17 = !{!"", !6, i64 0, !6, i64 8}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!16, !10, i64 28800}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}


; 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.bb_connection_t = type { ptr, i32 }

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @bb_build_df(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #0 {
vector.ph:
  %2 = getelementptr inbounds i8, ptr %1, i64 32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i32> [ zeroinitializer, %vector.ph ], [ %22, %vector.body ]
  %vec.phi36 = phi <2 x i32> [ zeroinitializer, %vector.ph ], [ %23, %vector.body ]
  %3 = or disjoint i64 %index, 1
  %4 = or disjoint i64 %index, 2
  %5 = or disjoint i64 %index, 3
  %6 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %2, i64 0, i64 %index
  %7 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %2, i64 0, i64 %3
  %8 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %2, i64 0, i64 %4
  %9 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %2, i64 0, i64 %5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = insertelement <2 x ptr> poison, ptr %10, i64 0
  %13 = insertelement <2 x ptr> %12, ptr %11, i64 1
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = insertelement <2 x ptr> poison, ptr %14, i64 0
  %17 = insertelement <2 x ptr> %16, ptr %15, i64 1
  %18 = icmp ne <2 x ptr> %13, zeroinitializer
  %19 = icmp ne <2 x ptr> %17, zeroinitializer
  %20 = zext <2 x i1> %18 to <2 x i32>
  %21 = zext <2 x i1> %19 to <2 x i32>
  %22 = add <2 x i32> %vec.phi, %20
  %23 = add <2 x i32> %vec.phi36, %21
  %index.next = add nuw i64 %index, 4
  %24 = icmp eq i64 %index.next, 124
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !11

.preheader24:                                     ; preds = %middle.block
  %25 = getelementptr inbounds i8, ptr %1, i64 2104
  br label %41

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i32> %23, %22
  %26 = tail call i32 @llvm.vector.reduce.add.v2i32(<2 x i32> %bin.rdx)
  %27 = getelementptr inbounds i8, ptr %1, i64 2016
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %.not23 = icmp ne ptr %28, null
  %29 = zext i1 %.not23 to i32
  %spec.select = add nuw nsw i32 %26, %29
  %30 = getelementptr inbounds i8, ptr %1, i64 2032
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %.not23.1 = icmp ne ptr %31, null
  %32 = zext i1 %.not23.1 to i32
  %spec.select.1 = add nuw nsw i32 %spec.select, %32
  %33 = getelementptr inbounds i8, ptr %1, i64 2048
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %.not23.2 = icmp ne ptr %34, null
  %35 = zext i1 %.not23.2 to i32
  %spec.select.2 = add nuw nsw i32 %spec.select.1, %35
  %36 = getelementptr inbounds i8, ptr %1, i64 2064
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %.not23.3 = icmp ne ptr %37, null
  %38 = zext i1 %.not23.3 to i32
  %39 = or i32 %spec.select.2, %38
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %.loopexit25, label %.preheader24

41:                                               ; preds = %.preheader24, %.loopexit
  %indvars.iv32 = phi i64 [ 0, %.preheader24 ], [ %indvars.iv.next33, %.loopexit ]
  %42 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %2, i64 0, i64 %indvars.iv32
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %.not = icmp eq ptr %43, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %41
  %44 = load ptr, ptr %25, align 8, !tbaa !15
  %.not2228 = icmp eq ptr %43, %44
  br i1 %.not2228, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.029 = phi ptr [ %52, %.lr.ph ], [ %43, %.preheader ]
  %45 = getelementptr inbounds i8, ptr %.029, i64 27776
  %46 = getelementptr inbounds i8, ptr %.029, i64 28800
  %47 = load i32, ptr %46, align 8, !tbaa !19
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %46, align 8, !tbaa !19
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds [64 x ptr], ptr %45, i64 0, i64 %49
  store ptr %1, ptr %50, align 8, !tbaa !20
  %51 = getelementptr inbounds i8, ptr %.029, i64 2104
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load ptr, ptr %25, align 8, !tbaa !15
  %.not22 = icmp eq ptr %52, %53
  br i1 %.not22, label %.loopexit, label %.lr.ph, !llvm.loop !21

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %41
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next33, 128
  br i1 %exitcond35.not, label %.loopexit25, label %41, !llvm.loop !22

.loopexit25:                                      ; preds = %.loopexit, %middle.block
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v2i32(<2 x i32>) #1

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, 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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = !{!16, !7, i64 2104}
!16 = !{!"basic_block", !17, i64 0, !17, i64 16, !8, i64 32, !7, i64 2080, !7, i64 2088, !7, i64 2096, !7, i64 2104, !7, i64 2112, !7, i64 2120, !7, i64 2128, !8, i64 2136, !10, i64 8536, !8, i64 8544, !10, i64 14944, !8, i64 14952, !10, i64 21352, !8, i64 21360, !10, i64 27760, !10, i64 27764, !10, i64 27768, !8, i64 27776, !8, i64 28288, !10, i64 28800, !10, i64 28804, !10, i64 28808, !18, i64 28812, !8, i64 28816, !7, i64 29328, !8, i64 29336, !7, i64 31384, !7, i64 31392, !7, i64 31400, !17, i64 31408, !10, i64 31424}
!17 = !{!"", !7, i64 0, !7, i64 8}
!18 = !{!"_Bool", !8, i64 0}
!19 = !{!16, !10, i64 28800}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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