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

; 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_rpo(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.func, ptr %8, i32 0, i32 5
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr %10, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %52

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.func, ptr %15, i32 0, i32 5
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.basic_block, ptr %18, i32 0, i32 8
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  store ptr %20, ptr %6, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %42, %14
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %46

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.basic_block, ptr %25, i32 0, i32 18
  %27 = load i32, ptr %26, align 4, !tbaa !19
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.basic_block, ptr %28, i32 0, i32 18
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = icmp slt i32 %27, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %24
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %33, ptr %5, align 8, !tbaa !5
  br label %42

34:                                               ; preds = %24
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.basic_block, ptr %36, i32 0, i32 8
  store ptr %35, ptr %37, align 8, !tbaa !17
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.basic_block, ptr %39, i32 0, i32 8
  store ptr %38, ptr %40, align 8, !tbaa !17
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %41, ptr %5, align 8, !tbaa !5
  store i32 1, ptr %7, align 4
  br label %50

42:                                               ; preds = %32
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.basic_block, ptr %43, i32 0, i32 8
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  store ptr %45, ptr %6, align 8, !tbaa !5
  br label %21, !llvm.loop !20

46:                                               ; preds = %21
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.basic_block, ptr %48, i32 0, i32 8
  store ptr %47, ptr %49, align 8, !tbaa !17
  store i32 0, ptr %7, align 4
  br label %50

50:                                               ; preds = %46, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  %51 = load i32, ptr %7, align 4
  switch i32 %51, label %53 [
    i32 0, label %52
    i32 1, label %52
  ]

52:                                               ; preds = %50, %50, %13
  ret void

53:                                               ; preds = %50
  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, !6, i64 8512}
!10 = !{!"func", !11, i64 0, !7, i64 944, !12, i64 8496, !12, i64 8500, !12, i64 8504, !6, i64 8512, !6, i64 8520, !16, i64 8528, !12, i64 8544, !12, i64 8548, !6, i64 8552}
!11 = !{!"var", !7, i64 0, !7, i64 32, !12, i64 64, !13, i64 68, !13, i64 69, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !6, i64 96, !12, i64 104, !7, i64 112, !12, i64 624, !14, i64 628, !15, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !12, i64 936, !13, i64 940, !13, i64 941, !13, i64 942}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !12, i64 0, !7, i64 4, !12, i64 260}
!15 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!16 = !{!"", !6, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 2120}
!18 = !{!"basic_block", !16, i64 0, !16, 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, !16, i64 31408, !12, i64 31424}
!19 = !{!18, !12, i64 27764}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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(readwrite, inaccessiblemem: none) uwtable
define dso_local void @bb_build_rpo(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8512
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, %1
  br i1 %5, label %15, label %.preheader

.preheader:                                       ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 27764
  br label %7

7:                                                ; preds = %.preheader, %8
  %.016 = phi ptr [ %.0, %8 ], [ %4, %.preheader ]
  %.0.in = getelementptr inbounds i8, ptr %.016, i64 2120
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !16
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.sink.split, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %.0, i64 27764
  %10 = load i32, ptr %9, align 4, !tbaa !18
  %11 = load i32, ptr %6, align 4, !tbaa !18
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %7, label %13, !llvm.loop !19

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %1, i64 2120
  store ptr %.0, ptr %14, align 8, !tbaa !16
  br label %.sink.split

.sink.split:                                      ; preds = %7, %13
  %.0.in.le.sink = getelementptr inbounds i8, ptr %.016, i64 2120
  store ptr %1, ptr %.0.in.le.sink, align 8, !tbaa !16
  br label %15

15:                                               ; preds = %.sink.split, %2
  ret void
}

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

!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 8512}
!6 = !{!"func", !7, i64 0, !8, i64 944, !10, i64 8496, !10, i64 8500, !10, i64 8504, !12, i64 8512, !12, i64 8520, !15, i64 8528, !10, i64 8544, !10, i64 8548, !12, i64 8552}
!7 = !{!"var", !8, i64 0, !8, i64 32, !10, i64 64, !11, i64 68, !11, i64 69, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !12, i64 96, !10, i64 104, !8, i64 112, !10, i64 624, !13, i64 628, !14, i64 896, !12, i64 912, !12, i64 920, !12, i64 928, !10, i64 936, !11, i64 940, !11, i64 941, !11, i64 942}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"", !10, i64 0, !8, i64 4, !10, i64 260}
!14 = !{!"ref_block_list", !12, i64 0, !12, i64 8}
!15 = !{!"", !12, i64 0, !12, i64 8}
!16 = !{!17, !12, i64 2120}
!17 = !{!"basic_block", !15, i64 0, !15, i64 16, !8, i64 32, !12, i64 2080, !12, i64 2088, !12, i64 2096, !12, i64 2104, !12, i64 2112, !12, i64 2120, !12, 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, !11, i64 28812, !8, i64 28816, !12, i64 29328, !8, i64 29336, !12, i64 31384, !12, i64 31392, !12, i64 31400, !15, i64 31408, !10, i64 31424}
!18 = !{!17, !10, i64 27764}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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