; 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.func_list_t = type { ptr, ptr }
%struct.func = type { %struct.var, [8 x %struct.var], i32, i32, i32, ptr, ptr, %struct.symbol_list_t, i32, i32, ptr }
%struct.var = type { [32 x i8], [32 x i8], i32, i8, i8, i32, i32, i32, i32, i32, ptr, i32, [64 x ptr], i32, %struct.rename_t, %struct.ref_block_list, ptr, ptr, ptr, i32, i8, i8, i8 }
%struct.rename_t = type { i32, [64 x i32], i32 }
%struct.ref_block_list = type { ptr, ptr }
%struct.symbol_list_t = type { ptr, ptr }
%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.insn = type { ptr, ptr, i32, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, [64 x i8] }

@FUNC_LIST = external dso_local global %struct.func_list_t, align 8

; 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
declare dso_local void @build_r_idom() #1

; Function Attrs: nounwind uwtable
declare dso_local void @build_rdom() #1

; Function Attrs: nounwind uwtable
declare dso_local void @build_rdf() #1

; Function Attrs: nounwind uwtable
declare dso_local void @use_chain_build() #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cse(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @const_folding(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @dce_insn(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @dce_sweep() #1

; Function Attrs: nounwind uwtable
define dso_local void @optimize() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @build_reversed_rpo()
  call void @build_r_idom()
  call void @build_rdom()
  call void @build_rdf()
  call void @use_chain_build()
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  %7 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  store ptr %7, ptr %1, align 8, !tbaa !10
  br label %8

8:                                                ; preds = %60, %0
  %9 = load ptr, ptr %1, align 8, !tbaa !10
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  br label %64

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

16:                                               ; preds = %55, %12
  %17 = load ptr, ptr %3, align 8, !tbaa !10
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  br label %59

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %21 = load ptr, ptr %3, align 8, !tbaa !10
  %22 = getelementptr inbounds %struct.basic_block, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.insn_list_t, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !18
  store ptr %24, ptr %4, align 8, !tbaa !10
  br label %25

25:                                               ; preds = %50, %20
  %26 = load ptr, ptr %4, align 8, !tbaa !10
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %54

29:                                               ; preds = %25
  %30 = load ptr, ptr %4, align 8, !tbaa !10
  %31 = getelementptr inbounds %struct.insn, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %40

34:                                               ; preds = %29
  %35 = load ptr, ptr %4, align 8, !tbaa !10
  %36 = load ptr, ptr %4, align 8, !tbaa !10
  %37 = getelementptr inbounds %struct.insn, ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds %struct.var, ptr %38, i32 0, i32 18
  store ptr %35, ptr %39, align 8, !tbaa !22
  br label %40

40:                                               ; preds = %34, %29
  %41 = load ptr, ptr %4, align 8, !tbaa !10
  %42 = load ptr, ptr %3, align 8, !tbaa !10
  %43 = call zeroext i1 @cse(ptr noundef %41, ptr noundef %42)
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  br label %50

45:                                               ; preds = %40
  %46 = load ptr, ptr %4, align 8, !tbaa !10
  %47 = call zeroext i1 @const_folding(ptr noundef %46)
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  br label %50

49:                                               ; preds = %45
  br label %50

50:                                               ; preds = %49, %48, %44
  %51 = load ptr, ptr %4, align 8, !tbaa !10
  %52 = getelementptr inbounds %struct.insn, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  store ptr %53, ptr %4, align 8, !tbaa !10
  br label %25, !llvm.loop !24

54:                                               ; preds = %28
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %3, align 8, !tbaa !10
  %57 = getelementptr inbounds %struct.basic_block, ptr %56, i32 0, i32 8
  %58 = load ptr, ptr %57, align 8, !tbaa !26
  store ptr %58, ptr %3, align 8, !tbaa !10
  br label %16, !llvm.loop !27

59:                                               ; preds = %19
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %1, align 8, !tbaa !10
  %62 = getelementptr inbounds %struct.func, ptr %61, i32 0, i32 10
  %63 = load ptr, ptr %62, align 8, !tbaa !28
  store ptr %63, ptr %1, align 8, !tbaa !10
  br label %8, !llvm.loop !29

64:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %65 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  store ptr %65, ptr %5, align 8, !tbaa !10
  br label %66

66:                                               ; preds = %85, %64
  %67 = load ptr, ptr %5, align 8, !tbaa !10
  %68 = icmp ne ptr %67, null
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 11, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %89

70:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %71 = load ptr, ptr %5, align 8, !tbaa !10
  %72 = getelementptr inbounds %struct.func, ptr %71, i32 0, i32 5
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  store ptr %73, ptr %6, align 8, !tbaa !10
  br label %74

74:                                               ; preds = %80, %70
  %75 = load ptr, ptr %6, align 8, !tbaa !10
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  store i32 14, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %84

78:                                               ; preds = %74
  %79 = load ptr, ptr %6, align 8, !tbaa !10
  call void @dce_insn(ptr noundef %79)
  br label %80

80:                                               ; preds = %78
  %81 = load ptr, ptr %6, align 8, !tbaa !10
  %82 = getelementptr inbounds %struct.basic_block, ptr %81, i32 0, i32 8
  %83 = load ptr, ptr %82, align 8, !tbaa !26
  store ptr %83, ptr %6, align 8, !tbaa !10
  br label %74, !llvm.loop !30

84:                                               ; preds = %77
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %5, align 8, !tbaa !10
  %87 = getelementptr inbounds %struct.func, ptr %86, i32 0, i32 10
  %88 = load ptr, ptr %87, align 8, !tbaa !28
  store ptr %88, ptr %5, align 8, !tbaa !10
  br label %66, !llvm.loop !31

89:                                               ; preds = %69
  call void @dce_sweep()
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @build_reversed_rpo() #1

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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !7, i64 8512}
!12 = !{!"func", !13, i64 0, !8, i64 944, !14, i64 8496, !14, i64 8500, !14, i64 8504, !7, i64 8512, !7, i64 8520, !6, i64 8528, !14, i64 8544, !14, i64 8548, !7, i64 8552}
!13 = !{!"var", !8, i64 0, !8, i64 32, !14, i64 64, !15, i64 68, !15, i64 69, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !7, i64 96, !14, i64 104, !8, i64 112, !14, i64 624, !16, i64 628, !17, i64 896, !7, i64 912, !7, i64 920, !7, i64 928, !14, i64 936, !15, i64 940, !15, i64 941, !15, i64 942}
!14 = !{!"int", !8, i64 0}
!15 = !{!"_Bool", !8, i64 0}
!16 = !{!"", !14, i64 0, !8, i64 4, !14, i64 260}
!17 = !{!"ref_block_list", !7, i64 0, !7, i64 8}
!18 = !{!19, !7, i64 0}
!19 = !{!"basic_block", !6, i64 0, !6, 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, !14, i64 8536, !8, i64 8544, !14, i64 14944, !8, i64 14952, !14, i64 21352, !8, i64 21360, !14, i64 27760, !14, i64 27764, !14, i64 27768, !8, i64 27776, !8, i64 28288, !14, i64 28800, !14, i64 28804, !14, i64 28808, !15, i64 28812, !8, i64 28816, !7, i64 29328, !8, i64 29336, !7, i64 31384, !7, i64 31392, !7, i64 31400, !6, i64 31408, !14, i64 31424}
!20 = !{!21, !7, i64 24}
!21 = !{!"insn", !7, i64 0, !7, i64 8, !14, i64 16, !14, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !14, i64 48, !15, i64 52, !7, i64 56, !7, i64 64, !8, i64 72}
!22 = !{!13, !7, i64 928}
!23 = !{!21, !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!19, !7, i64 2120}
!27 = distinct !{!27, !25}
!28 = !{!12, !7, i64 8552}
!29 = distinct !{!29, !25}
!30 = distinct !{!30, !25}
!31 = distinct !{!31, !25}


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

@FUNC_LIST = external dso_local local_unnamed_addr global %struct.func_list_t, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @build_r_idom() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @build_rdom() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @build_rdf() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @use_chain_build() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @cse(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @const_folding(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @dce_sweep() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @optimize() local_unnamed_addr #0 {
  tail call void @build_reversed_rpo()
  tail call void @build_r_idom()
  tail call void @build_rdom()
  tail call void @build_rdf()
  tail call void @use_chain_build()
  %.02338 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  %.not39 = icmp eq ptr %.02338, null
  br i1 %.not39, label %._crit_edge53, label %.lr.ph42

.preheader:                                       ; preds = %._crit_edge37
  %.02049.pre = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  %.not2550 = icmp eq ptr %.02049.pre, null
  br i1 %.not2550, label %._crit_edge53, label %.lr.ph52

.lr.ph42:                                         ; preds = %0, %._crit_edge37
  %.02340 = phi ptr [ %.023, %._crit_edge37 ], [ %.02338, %0 ]
  %1 = getelementptr inbounds i8, ptr %.02340, i64 8512
  %.02234 = load ptr, ptr %1, align 8, !tbaa !5
  %.not2735 = icmp eq ptr %.02234, null
  br i1 %.not2735, label %._crit_edge37, label %.preheader30

.preheader30:                                     ; preds = %.lr.ph42, %._crit_edge
  %.02236 = phi ptr [ %.022, %._crit_edge ], [ %.02234, %.lr.ph42 ]
  %.02131 = load ptr, ptr %.02236, align 8, !tbaa !5
  %.not2832 = icmp eq ptr %.02131, null
  br i1 %.not2832, label %._crit_edge, label %.lr.ph

._crit_edge37:                                    ; preds = %._crit_edge, %.lr.ph42
  %2 = getelementptr inbounds i8, ptr %.02340, i64 8552
  %.023 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %.023, null
  br i1 %.not, label %.preheader, label %.lr.ph42, !llvm.loop !9

._crit_edge:                                      ; preds = %12, %.preheader30
  %3 = getelementptr inbounds i8, ptr %.02236, i64 2120
  %.022 = load ptr, ptr %3, align 8, !tbaa !5
  %.not27 = icmp eq ptr %.022, null
  br i1 %.not27, label %._crit_edge37, label %.preheader30, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader30, %12
  %.02133 = phi ptr [ %.021, %12 ], [ %.02131, %.preheader30 ]
  %4 = getelementptr inbounds i8, ptr %.02133, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %.not29 = icmp eq ptr %5, null
  br i1 %.not29, label %8, label %6

6:                                                ; preds = %.lr.ph
  %7 = getelementptr inbounds i8, ptr %5, i64 928
  store ptr %.02133, ptr %7, align 8, !tbaa !16
  br label %8

8:                                                ; preds = %6, %.lr.ph
  %9 = tail call zeroext i1 @cse(ptr noundef nonnull %.02133, ptr noundef nonnull %.02236)
  br i1 %9, label %12, label %10

10:                                               ; preds = %8
  %11 = tail call zeroext i1 @const_folding(ptr noundef nonnull %.02133)
  br label %12

12:                                               ; preds = %10, %8
  %.021 = load ptr, ptr %.02133, align 8, !tbaa !5
  %.not28 = icmp eq ptr %.021, null
  br i1 %.not28, label %._crit_edge, label %.lr.ph, !llvm.loop !20

._crit_edge53:                                    ; preds = %._crit_edge48, %0, %.preheader
  tail call void @dce_sweep()
  ret void

.lr.ph52:                                         ; preds = %.preheader, %._crit_edge48
  %.02051 = phi ptr [ %.020, %._crit_edge48 ], [ %.02049.pre, %.preheader ]
  %13 = getelementptr inbounds i8, ptr %.02051, i64 8512
  %.043 = load ptr, ptr %13, align 8, !tbaa !5
  %.not2644 = icmp eq ptr %.043, null
  br i1 %.not2644, label %._crit_edge48, label %.lr.ph47

._crit_edge48:                                    ; preds = %.lr.ph47, %.lr.ph52
  %14 = getelementptr inbounds i8, ptr %.02051, i64 8552
  %.020 = load ptr, ptr %14, align 8, !tbaa !5
  %.not25 = icmp eq ptr %.020, null
  br i1 %.not25, label %._crit_edge53, label %.lr.ph52, !llvm.loop !21

.lr.ph47:                                         ; preds = %.lr.ph52, %.lr.ph47
  %.045 = phi ptr [ %.0, %.lr.ph47 ], [ %.043, %.lr.ph52 ]
  tail call void @dce_insn(ptr noundef nonnull %.045)
  %15 = getelementptr inbounds i8, ptr %.045, i64 2120
  %.0 = load ptr, ptr %15, align 8, !tbaa !5
  %.not26 = icmp eq ptr %.0, null
  br i1 %.not26, label %._crit_edge48, label %.lr.ph47, !llvm.loop !22
}

; Function Attrs: nounwind uwtable
declare dso_local void @build_reversed_rpo() local_unnamed_addr #0

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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !6, i64 24}
!13 = !{!"insn", !6, i64 0, !6, i64 8, !14, i64 16, !14, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !15, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!17, !6, i64 928}
!17 = !{!"var", !7, i64 0, !7, i64 32, !14, i64 64, !15, i64 68, !15, i64 69, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !6, i64 96, !14, i64 104, !7, i64 112, !14, i64 624, !18, i64 628, !19, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !14, i64 936, !15, i64 940, !15, i64 941, !15, i64 942}
!18 = !{!"", !14, i64 0, !7, i64 4, !14, i64 260}
!19 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


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