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

@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: 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

declare ptr @require_var(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @bb_solve_phi_params(ptr noundef) #3

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

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

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

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %62, %11
  %13 = load i32, ptr %3, align 4, !tbaa !11
  %14 = load ptr, ptr %1, align 8, !tbaa !10
  %15 = getelementptr inbounds %struct.func, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %20 = load ptr, ptr %1, align 8, !tbaa !10
  %21 = getelementptr inbounds %struct.func, ptr %20, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = getelementptr inbounds %struct.basic_block, ptr %22, i32 0, i32 31
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = call ptr @require_var(ptr noundef %24)
  store ptr %25, ptr %4, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %26 = load ptr, ptr %1, align 8, !tbaa !10
  %27 = getelementptr inbounds %struct.func, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %3, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [8 x %struct.var], ptr %27, i64 0, i64 %29
  store ptr %30, ptr %5, align 8, !tbaa !10
  %31 = load ptr, ptr %4, align 8, !tbaa !10
  %32 = load ptr, ptr %5, align 8, !tbaa !10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 8 %32, i64 944, i1 false)
  %33 = load ptr, ptr %5, align 8, !tbaa !10
  %34 = load ptr, ptr %4, align 8, !tbaa !10
  %35 = getelementptr inbounds %struct.var, ptr %34, i32 0, i32 10
  store ptr %33, ptr %35, align 8, !tbaa !22
  %36 = load ptr, ptr %4, align 8, !tbaa !10
  %37 = getelementptr inbounds %struct.var, ptr %36, i32 0, i32 11
  store i32 0, ptr %37, align 8, !tbaa !23
  %38 = load ptr, ptr %5, align 8, !tbaa !10
  %39 = getelementptr inbounds %struct.var, ptr %38, i32 0, i32 14
  %40 = getelementptr inbounds %struct.rename_t, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !24
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !24
  %43 = load ptr, ptr %5, align 8, !tbaa !10
  %44 = getelementptr inbounds %struct.var, ptr %43, i32 0, i32 14
  %45 = getelementptr inbounds %struct.rename_t, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %5, align 8, !tbaa !10
  %47 = getelementptr inbounds %struct.var, ptr %46, i32 0, i32 14
  %48 = getelementptr inbounds %struct.rename_t, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !25
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %48, align 4, !tbaa !25
  %51 = sext i32 %49 to i64
  %52 = getelementptr inbounds [64 x i32], ptr %45, i64 0, i64 %51
  store i32 %41, ptr %52, align 4, !tbaa !11
  %53 = load ptr, ptr %4, align 8, !tbaa !10
  %54 = load ptr, ptr %5, align 8, !tbaa !10
  %55 = getelementptr inbounds %struct.var, ptr %54, i32 0, i32 12
  %56 = load ptr, ptr %5, align 8, !tbaa !10
  %57 = getelementptr inbounds %struct.var, ptr %56, i32 0, i32 13
  %58 = load i32, ptr %57, align 8, !tbaa !26
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 8, !tbaa !26
  %60 = sext i32 %58 to i64
  %61 = getelementptr inbounds [64 x ptr], ptr %55, i64 0, i64 %60
  store ptr %53, ptr %61, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %62

62:                                               ; preds = %19
  %63 = load i32, ptr %3, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !11
  br label %12, !llvm.loop !27

65:                                               ; preds = %18
  %66 = load ptr, ptr %1, align 8, !tbaa !10
  %67 = getelementptr inbounds %struct.func, ptr %66, i32 0, i32 5
  %68 = load ptr, ptr %67, align 8, !tbaa !19
  call void @bb_solve_phi_params(ptr noundef %68)
  br label %69

69:                                               ; preds = %65
  %70 = load ptr, ptr %1, align 8, !tbaa !10
  %71 = getelementptr inbounds %struct.func, ptr %70, i32 0, i32 10
  %72 = load ptr, ptr %71, align 8, !tbaa !29
  store ptr %72, ptr %1, align 8, !tbaa !10
  br label %7, !llvm.loop !30

73:                                               ; preds = %10
  ret void
}

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


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

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

; 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) #0

declare ptr @require_var(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @solve_phi_params() local_unnamed_addr #2 {
  %.021 = load ptr, ptr @FUNC_LIST, align 8, !tbaa !5
  %.not22 = icmp eq ptr %.021, null
  br i1 %.not22, label %._crit_edge24, label %.preheader

.preheader:                                       ; preds = %0, %._crit_edge
  %.023 = phi ptr [ %.0, %._crit_edge ], [ %.021, %0 ]
  %1 = getelementptr inbounds i8, ptr %.023, i64 8496
  %2 = load i32, ptr %1, align 8, !tbaa !9
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %4 = getelementptr inbounds i8, ptr %.023, i64 8512
  %5 = getelementptr inbounds i8, ptr %.023, i64 944
  br label %9

._crit_edge24:                                    ; preds = %._crit_edge, %0
  ret void

._crit_edge:                                      ; preds = %9, %.preheader
  %6 = getelementptr inbounds i8, ptr %.023, i64 8512
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  tail call void @bb_solve_phi_params(ptr noundef %7)
  %8 = getelementptr inbounds i8, ptr %.023, i64 8552
  %.0 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge24, label %.preheader, !llvm.loop !18

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %10 = load ptr, ptr %4, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %10, i64 31400
  %12 = load ptr, ptr %11, align 8, !tbaa !20
  %13 = tail call ptr @require_var(ptr noundef %12) #3
  %14 = getelementptr inbounds [8 x %struct.var], ptr %5, i64 0, i64 %indvars.iv
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(944) %13, ptr noundef nonnull align 8 dereferenceable(944) %14, i64 944, i1 false)
  %15 = getelementptr inbounds i8, ptr %13, i64 96
  store ptr %14, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds i8, ptr %13, i64 104
  store i32 0, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %14, i64 628
  %18 = load i32, ptr %17, align 4, !tbaa !24
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !24
  %20 = getelementptr inbounds i8, ptr %14, i64 632
  %21 = getelementptr inbounds i8, ptr %14, i64 888
  %22 = load i32, ptr %21, align 4, !tbaa !25
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %21, align 4, !tbaa !25
  %24 = sext i32 %22 to i64
  %25 = getelementptr inbounds [64 x i32], ptr %20, i64 0, i64 %24
  store i32 %18, ptr %25, align 4, !tbaa !26
  %26 = getelementptr inbounds i8, ptr %14, i64 112
  %27 = getelementptr inbounds i8, ptr %14, i64 624
  %28 = load i32, ptr %27, align 8, !tbaa !27
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 8, !tbaa !27
  %30 = sext i32 %28 to i64
  %31 = getelementptr inbounds [64 x ptr], ptr %26, i64 0, i64 %30
  store ptr %13, ptr %31, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr %1, align 8, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %9, label %._crit_edge, !llvm.loop !28
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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, !12, i64 8496}
!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 = !{!10, !6, i64 8512}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 31400}
!21 = !{!"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}
!22 = !{!11, !6, i64 96}
!23 = !{!11, !12, i64 104}
!24 = !{!11, !12, i64 628}
!25 = !{!11, !12, i64 888}
!26 = !{!12, !12, i64 0}
!27 = !{!11, !12, i64 624}
!28 = distinct !{!28, !19}


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