; 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.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.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
define dso_local void @add_live_gen(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.var, ptr %7, i32 0, i32 4
  %9 = load i8, ptr %8, align 1, !tbaa !9, !range !15, !noundef !16
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %46

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

13:                                               ; preds = %31, %12
  %14 = load i32, ptr %5, align 4, !tbaa !17
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.basic_block, ptr %15, i32 0, i32 11
  %17 = load i32, ptr %16, align 8, !tbaa !18
  %18 = icmp slt i32 %14, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  store i32 2, ptr %6, align 4
  br label %34

20:                                               ; preds = %13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.basic_block, ptr %21, i32 0, i32 10
  %23 = load i32, ptr %5, align 4, !tbaa !17
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [800 x ptr], ptr %22, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  store i32 1, ptr %6, align 4
  br label %34

30:                                               ; preds = %20
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %5, align 4, !tbaa !17
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !17
  br label %13, !llvm.loop !21

34:                                               ; preds = %29, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %35 = load i32, ptr %6, align 4
  switch i32 %35, label %47 [
    i32 2, label %36
    i32 1, label %46
  ]

36:                                               ; preds = %34
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.basic_block, ptr %38, i32 0, i32 10
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.basic_block, ptr %40, i32 0, i32 11
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 8, !tbaa !18
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [800 x ptr], ptr %39, i64 0, i64 %44
  store ptr %37, ptr %45, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %36, %34, %11
  ret void

47:                                               ; preds = %34
  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, !12, i64 69}
!10 = !{!"var", !7, i64 0, !7, i64 32, !11, i64 64, !12, i64 68, !12, i64 69, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !11, i64 104, !7, i64 112, !11, i64 624, !13, i64 628, !14, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !11, i64 936, !12, i64 940, !12, i64 941, !12, i64 942}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"", !11, i64 0, !7, i64 4, !11, i64 260}
!14 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !11, i64 8536}
!19 = !{!"basic_block", !20, i64 0, !20, 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, !11, i64 8536, !7, i64 8544, !11, i64 14944, !7, i64 14952, !11, i64 21352, !7, i64 21360, !11, i64 27760, !11, i64 27764, !11, i64 27768, !7, i64 27776, !7, i64 28288, !11, i64 28800, !11, i64 28804, !11, i64 28808, !12, i64 28812, !7, i64 28816, !6, i64 29328, !7, i64 29336, !6, i64 31384, !6, i64 31392, !6, i64 31400, !20, i64 31408, !11, i64 31424}
!20 = !{!"", !6, i64 0, !6, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"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(argmem: readwrite) uwtable
define dso_local void @add_live_gen(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 69
  %4 = load i8, ptr %3, align 1, !tbaa !5, !range !14, !noundef !15
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 8536
  %7 = load i32, ptr %6, align 8, !tbaa !16
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %0, i64 2136
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %11

10:                                               ; preds = %11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %11, !llvm.loop !19

11:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %12 = getelementptr inbounds [800 x ptr], ptr %9, i64 0, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !21
  %14 = icmp eq ptr %13, %1
  br i1 %14, label %.loopexit, label %10

._crit_edge:                                      ; preds = %10, %.preheader
  %15 = getelementptr inbounds i8, ptr %0, i64 2136
  %16 = add nsw i32 %7, 1
  store i32 %16, ptr %6, align 8, !tbaa !16
  %17 = sext i32 %7 to i64
  %18 = getelementptr inbounds [800 x ptr], ptr %15, i64 0, i64 %17
  store ptr %1, ptr %18, align 8, !tbaa !21
  br label %.loopexit

.loopexit:                                        ; preds = %11, %2, %._crit_edge
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !10, i64 69}
!6 = !{!"var", !7, i64 0, !7, i64 32, !9, i64 64, !10, i64 68, !10, i64 69, !9, i64 72, !9, i64 76, !9, i64 80, !9, i64 84, !9, i64 88, !11, i64 96, !9, i64 104, !7, i64 112, !9, i64 624, !12, i64 628, !13, i64 896, !11, i64 912, !11, i64 920, !11, i64 928, !9, i64 936, !10, i64 940, !10, i64 941, !10, i64 942}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"", !9, i64 0, !7, i64 4, !9, i64 260}
!13 = !{!"ref_block_list", !11, i64 0, !11, i64 8}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !9, i64 8536}
!17 = !{!"basic_block", !18, i64 0, !18, i64 16, !7, i64 32, !11, i64 2080, !11, i64 2088, !11, i64 2096, !11, i64 2104, !11, i64 2112, !11, i64 2120, !11, i64 2128, !7, i64 2136, !9, i64 8536, !7, i64 8544, !9, i64 14944, !7, i64 14952, !9, i64 21352, !7, i64 21360, !9, i64 27760, !9, i64 27764, !9, i64 27768, !7, i64 27776, !7, i64 28288, !9, i64 28800, !9, i64 28804, !9, i64 28808, !10, i64 28812, !7, i64 28816, !11, i64 29328, !7, i64 29336, !11, i64 31384, !11, i64 31392, !11, i64 31400, !18, i64 31408, !9, i64 31424}
!18 = !{!"", !11, i64 0, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass