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

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

; Function Attrs: nounwind uwtable
define dso_local void @compute_live_in(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.basic_block, ptr %5, i32 0, i32 15
  store i32 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %7

7:                                                ; preds = %32, %1
  %8 = load i32, ptr %3, align 4, !tbaa !14
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.basic_block, ptr %9, i32 0, i32 17
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = icmp slt i32 %8, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %35

14:                                               ; preds = %7
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.basic_block, ptr %15, i32 0, i32 16
  %17 = load i32, ptr %3, align 4, !tbaa !14
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [800 x ptr], ptr %16, i64 0, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call zeroext i1 @var_check_killed(ptr noundef %20, ptr noundef %21)
  br i1 %22, label %23, label %24

23:                                               ; preds = %14
  br label %32

24:                                               ; preds = %14
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.basic_block, ptr %26, i32 0, i32 16
  %28 = load i32, ptr %3, align 4, !tbaa !14
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [800 x ptr], ptr %27, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  call void @add_live_in(ptr noundef %25, ptr noundef %31)
  br label %32

32:                                               ; preds = %24, %23
  %33 = load i32, ptr %3, align 4, !tbaa !14
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !14
  br label %7, !llvm.loop !16

35:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %36

36:                                               ; preds = %51, %35
  %37 = load i32, ptr %4, align 4, !tbaa !14
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.basic_block, ptr %38, i32 0, i32 11
  %40 = load i32, ptr %39, align 8, !tbaa !18
  %41 = icmp slt i32 %37, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %54

43:                                               ; preds = %36
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.basic_block, ptr %45, i32 0, i32 10
  %47 = load i32, ptr %4, align 4, !tbaa !14
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [800 x ptr], ptr %46, i64 0, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  call void @add_live_in(ptr noundef %44, ptr noundef %50)
  br label %51

51:                                               ; preds = %43
  %52 = load i32, ptr %4, align 4, !tbaa !14
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %4, align 4, !tbaa !14
  br label %36, !llvm.loop !19

54:                                               ; preds = %42
  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, !12, i64 21352}
!10 = !{!"basic_block", !11, i64 0, !11, 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, !11, i64 31408, !12, i64 31424}
!11 = !{!"", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !12, i64 27760}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !12, i64 8536}
!19 = distinct !{!19, !17}


; 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 @add_live_in(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @compute_live_in(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 21352
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 27760
  %4 = load i32, ptr %3, align 8, !tbaa !13
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 21360
  br label %11

.preheader:                                       ; preds = %17, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 8536
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph18, label %._crit_edge

.lr.ph18:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 2136
  br label %21

11:                                               ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %12 = getelementptr inbounds [800 x ptr], ptr %6, i64 0, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = tail call zeroext i1 @var_check_killed(ptr noundef %13, ptr noundef nonnull %0)
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %12, align 8, !tbaa !15
  tail call void @add_live_in(ptr noundef nonnull %0, ptr noundef %16)
  br label %17

17:                                               ; preds = %11, %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %3, align 8, !tbaa !13
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %11, label %.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %21, %.preheader
  ret void

21:                                               ; preds = %.lr.ph18, %21
  %indvars.iv20 = phi i64 [ 0, %.lr.ph18 ], [ %indvars.iv.next21, %21 ]
  %22 = getelementptr inbounds [800 x ptr], ptr %10, i64 0, i64 %indvars.iv20
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  tail call void @add_live_in(ptr noundef nonnull %0, ptr noundef %23)
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %24 = load i32, ptr %7, align 8, !tbaa !14
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next21, %25
  br i1 %26, label %21, label %._crit_edge, !llvm.loop !18
}

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, !11, i64 21352}
!6 = !{!"basic_block", !7, i64 0, !7, i64 16, !9, i64 32, !8, i64 2080, !8, i64 2088, !8, i64 2096, !8, i64 2104, !8, i64 2112, !8, i64 2120, !8, i64 2128, !9, i64 2136, !11, i64 8536, !9, i64 8544, !11, i64 14944, !9, i64 14952, !11, i64 21352, !9, i64 21360, !11, i64 27760, !11, i64 27764, !11, i64 27768, !9, i64 27776, !9, i64 28288, !11, i64 28800, !11, i64 28804, !11, i64 28808, !12, i64 28812, !9, i64 28816, !8, i64 29328, !9, i64 29336, !8, i64 31384, !8, i64 31392, !8, i64 31400, !7, i64 31408, !11, i64 31424}
!7 = !{!"", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_Bool", !9, i64 0}
!13 = !{!6, !11, i64 27760}
!14 = !{!6, !11, i64 8536}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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