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

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @bb_backward_traversal(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %struct.bb_traversal_args_t, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.basic_block, ptr %7, i32 0, i32 24
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr %8, align 8, !tbaa !11
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %25

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  call void %18(ptr noundef %21, ptr noundef %24)
  br label %25

25:                                               ; preds = %15, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !18
  br label %26

26:                                               ; preds = %73, %25
  %27 = load i32, ptr %3, align 4, !tbaa !18
  %28 = icmp slt i32 %27, 128
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %76

30:                                               ; preds = %26
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.basic_block, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %3, align 4, !tbaa !18
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %34, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.bb_connection_t, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %30
  br label %73

42:                                               ; preds = %30
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.basic_block, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %3, align 4, !tbaa !18
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %46, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.bb_connection_t, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  %52 = getelementptr inbounds %struct.basic_block, ptr %51, i32 0, i32 24
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = getelementptr inbounds %struct.func, ptr %56, i32 0, i32 9
  %58 = load i32, ptr %57, align 4, !tbaa !21
  %59 = icmp slt i32 %53, %58
  br i1 %59, label %60, label %72

60:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #3
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %61, i64 32, i1 false)
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.basic_block, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %3, align 4, !tbaa !18
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %65, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.bb_connection_t, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %4, i32 0, i32 1
  store ptr %70, ptr %71, align 8, !tbaa !9
  call void @bb_backward_traversal(ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #3
  br label %72

72:                                               ; preds = %60, %42
  br label %73

73:                                               ; preds = %72, %41
  %74 = load i32, ptr %3, align 4, !tbaa !18
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %3, align 4, !tbaa !18
  br label %26, !llvm.loop !26

76:                                               ; preds = %29
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !28
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %91

81:                                               ; preds = %76
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !28
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.bb_traversal_args_t, ptr %88, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  call void %84(ptr noundef %87, ptr noundef %90)
  br label %91

91:                                               ; preds = %81, %76
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 8}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!12, !14, i64 28808}
!12 = !{!"basic_block", !13, i64 0, !13, 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, !14, i64 8536, !7, i64 8544, !14, i64 14944, !7, i64 14952, !14, i64 21352, !7, i64 21360, !14, i64 27760, !14, i64 27764, !14, i64 27768, !7, i64 27776, !7, i64 28288, !14, i64 28800, !14, i64 28804, !14, i64 28808, !15, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !13, i64 31408, !14, i64 31424}
!13 = !{!"", !6, i64 0, !6, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 0}
!18 = !{!14, !14, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"", !6, i64 0, !14, i64 8}
!21 = !{!22, !14, i64 8548}
!22 = !{!"func", !23, i64 0, !7, i64 944, !14, i64 8496, !14, i64 8500, !14, i64 8504, !6, i64 8512, !6, i64 8520, !13, i64 8528, !14, i64 8544, !14, i64 8548, !6, i64 8552}
!23 = !{!"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, !24, i64 628, !25, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !14, i64 936, !15, i64 940, !15, i64 941, !15, i64 942}
!24 = !{!"", !14, i64 0, !7, i64 4, !14, i64 260}
!25 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!10, !6, i64 24}


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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @bb_backward_traversal(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca %struct.bb_traversal_args_t, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 28808
  %6 = load i32, ptr %5, align 8, !tbaa !10
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr %5, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !15
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %12, label %10

10:                                               ; preds = %1
  %11 = load ptr, ptr %0, align 8, !tbaa !16
  tail call void %9(ptr noundef %11, ptr noundef nonnull %4) #3
  br label %12

12:                                               ; preds = %10, %1
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  br label %17

14:                                               ; preds = %30
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %.not21 = icmp eq ptr %16, null
  br i1 %.not21, label %34, label %31

17:                                               ; preds = %12, %30
  %indvars.iv = phi i64 [ 0, %12 ], [ %indvars.iv.next, %30 ]
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 32
  %20 = getelementptr inbounds [128 x %struct.bb_connection_t], ptr %19, i64 0, i64 %indvars.iv
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %.not22 = icmp eq ptr %21, null
  br i1 %.not22, label %30, label %22

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %21, i64 28808
  %24 = load i32, ptr %23, align 8, !tbaa !10
  %25 = load ptr, ptr %0, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %25, i64 8548
  %27 = load i32, ptr %26, align 4, !tbaa !20
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %0, i64 32, i1 false)
  store ptr %21, ptr %13, align 8, !tbaa !5
  call void @bb_backward_traversal(ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #3
  br label %30

30:                                               ; preds = %22, %29, %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 128
  br i1 %exitcond.not, label %14, label %17, !llvm.loop !25

31:                                               ; preds = %14
  %32 = load ptr, ptr %0, align 8, !tbaa !16
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void %16(ptr noundef %32, ptr noundef %33) #3
  br label %34

34:                                               ; preds = %31, %14
  ret void
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass