; 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 }
%struct.insn = type { ptr, ptr, i32, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, [64 x i8] }

; 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 zeroext i1 @var_check_killed(ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @bb_solve_locals(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = 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 8, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.basic_block, ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds %struct.insn_list_t, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  store ptr %11, ptr %6, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %79, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %83

16:                                               ; preds = %12
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %5, align 4, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.insn, ptr %19, i32 0, i32 2
  store i32 %17, ptr %20, align 8, !tbaa !15
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.insn, ptr %21, i32 0, i32 5
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %41

25:                                               ; preds = %16
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.insn, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call zeroext i1 @var_check_killed(ptr noundef %28, ptr noundef %29)
  br i1 %30, label %36, label %31

31:                                               ; preds = %25
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.insn, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  call void @add_live_gen(ptr noundef %32, ptr noundef %35)
  br label %36

36:                                               ; preds = %31, %25
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.insn, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  call void @update_consumed(ptr noundef %37, ptr noundef %40)
  br label %41

41:                                               ; preds = %36, %16
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.insn, ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %62

46:                                               ; preds = %41
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.insn, ptr %47, i32 0, i32 6
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call zeroext i1 @var_check_killed(ptr noundef %49, ptr noundef %50)
  br i1 %51, label %57, label %52

52:                                               ; preds = %46
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.insn, ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  call void @add_live_gen(ptr noundef %53, ptr noundef %56)
  br label %57

57:                                               ; preds = %52, %46
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.insn, ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  call void @update_consumed(ptr noundef %58, ptr noundef %61)
  br label %62

62:                                               ; preds = %57, %41
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.insn, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %78

67:                                               ; preds = %62
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.insn, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !20
  %71 = icmp ne i32 %70, 2
  br i1 %71, label %72, label %77

72:                                               ; preds = %67
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.insn, ptr %74, i32 0, i32 4
  %76 = load ptr, ptr %75, align 8, !tbaa !19
  call void @bb_add_killed_var(ptr noundef %73, ptr noundef %76)
  br label %77

77:                                               ; preds = %72, %67
  br label %78

78:                                               ; preds = %77, %62
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.insn, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !21
  store ptr %82, ptr %6, align 8, !tbaa !5
  br label %12, !llvm.loop !22

83:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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 = !{!"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, !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, !14, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !13, i64 31408, !10, i64 31424}
!13 = !{!"", !6, i64 0, !6, i64 8}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !10, i64 16}
!16 = !{!"insn", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !14, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!17 = !{!16, !6, i64 32}
!18 = !{!16, !6, i64 40}
!19 = !{!16, !6, i64 24}
!20 = !{!16, !10, i64 20}
!21 = !{!16, !6, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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: nounwind uwtable
declare dso_local zeroext i1 @var_check_killed(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @bb_solve_locals(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #0 {
  %.031 = load ptr, ptr %1, align 8, !tbaa !5
  %.not32 = icmp eq ptr %.031, null
  br i1 %.not32, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %29, %2
  ret void

.lr.ph:                                           ; preds = %2, %29
  %.034 = phi ptr [ %.0, %29 ], [ %.031, %2 ]
  %.02333 = phi i32 [ %3, %29 ], [ 0, %2 ]
  %3 = add nuw nsw i32 %.02333, 1
  %4 = getelementptr inbounds i8, ptr %.034, i64 16
  store i32 %.02333, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %.034, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %.not27 = icmp eq ptr %6, null
  br i1 %.not27, label %13, label %7

7:                                                ; preds = %.lr.ph
  %8 = tail call zeroext i1 @var_check_killed(ptr noundef nonnull %6, ptr noundef nonnull %1)
  br i1 %8, label %11, label %9

9:                                                ; preds = %7
  %10 = load ptr, ptr %5, align 8, !tbaa !13
  tail call void @add_live_gen(ptr noundef nonnull %1, ptr noundef %10)
  br label %11

11:                                               ; preds = %9, %7
  %12 = load ptr, ptr %5, align 8, !tbaa !13
  tail call void @update_consumed(ptr noundef nonnull %.034, ptr noundef %12)
  br label %13

13:                                               ; preds = %11, %.lr.ph
  %14 = getelementptr inbounds i8, ptr %.034, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %.not28 = icmp eq ptr %15, null
  br i1 %.not28, label %22, label %16

16:                                               ; preds = %13
  %17 = tail call zeroext i1 @var_check_killed(ptr noundef nonnull %15, ptr noundef nonnull %1)
  br i1 %17, label %20, label %18

18:                                               ; preds = %16
  %19 = load ptr, ptr %14, align 8, !tbaa !14
  tail call void @add_live_gen(ptr noundef nonnull %1, ptr noundef %19)
  br label %20

20:                                               ; preds = %18, %16
  %21 = load ptr, ptr %14, align 8, !tbaa !14
  tail call void @update_consumed(ptr noundef nonnull %.034, ptr noundef %21)
  br label %22

22:                                               ; preds = %20, %13
  %23 = getelementptr inbounds i8, ptr %.034, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %.not29 = icmp eq ptr %24, null
  br i1 %.not29, label %29, label %25

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %.034, i64 20
  %27 = load i32, ptr %26, align 4, !tbaa !16
  %.not30 = icmp eq i32 %27, 2
  br i1 %.not30, label %29, label %28

28:                                               ; preds = %25
  tail call void @bb_add_killed_var(ptr noundef nonnull %1, ptr noundef nonnull %24)
  br label %29

29:                                               ; preds = %22, %28, %25
  %.0 = load ptr, ptr %.034, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17
}

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 = !{!10, !11, i64 16}
!10 = !{!"insn", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !7, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !6, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 20}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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