; 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.ref_block = 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: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; 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 @var_add_killed_bb(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.var, ptr %8, i32 0, i32 15
  %10 = getelementptr inbounds %struct.ref_block_list, 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 = %23, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %27

15:                                               ; preds = %12
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ref_block, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp eq ptr %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %15
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %27

22:                                               ; preds = %15
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ref_block, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  store ptr %26, ptr %6, align 8, !tbaa !5
  br label %12, !llvm.loop !19

27:                                               ; preds = %21, %12
  %28 = load i8, ptr %5, align 1, !tbaa !9, !range !21, !noundef !22
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i32 1, ptr %7, align 4
  br label %58

31:                                               ; preds = %27
  %32 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 16) #4
  store ptr %32, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ref_block, ptr %34, i32 0, i32 0
  store ptr %33, ptr %35, align 8, !tbaa !16
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.var, ptr %36, i32 0, i32 15
  %38 = getelementptr inbounds %struct.ref_block_list, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = icmp ne ptr %39, null
  br i1 %40, label %46, label %41

41:                                               ; preds = %31
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.var, ptr %43, i32 0, i32 15
  %45 = getelementptr inbounds %struct.ref_block_list, ptr %44, i32 0, i32 0
  store ptr %42, ptr %45, align 8, !tbaa !11
  br label %53

46:                                               ; preds = %31
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.var, ptr %48, i32 0, i32 15
  %50 = getelementptr inbounds %struct.ref_block_list, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !23
  %52 = getelementptr inbounds %struct.ref_block, ptr %51, i32 0, i32 1
  store ptr %47, ptr %52, align 8, !tbaa !18
  br label %53

53:                                               ; preds = %46, %41
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.var, ptr %55, i32 0, i32 15
  %57 = getelementptr inbounds %struct.ref_block_list, ptr %56, i32 0, i32 1
  store ptr %54, ptr %57, align 8, !tbaa !23
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %53, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %61 [
    i32 0, label %60
    i32 1, label %60
  ]

60:                                               ; preds = %58, %58
  ret void

61:                                               ; preds = %58
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,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 }
attributes #4 = { nounwind allocsize(0,1) }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !6, i64 896}
!12 = !{!"var", !7, i64 0, !7, i64 32, !13, i64 64, !10, i64 68, !10, i64 69, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !13, i64 88, !6, i64 96, !13, i64 104, !7, i64 112, !13, i64 624, !14, i64 628, !15, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !13, i64 936, !10, i64 940, !10, i64 941, !10, i64 942}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !7, i64 4, !13, i64 260}
!15 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!16 = !{!17, !6, i64 0}
!17 = !{!"ref_block", !6, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!12, !6, i64 904}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @var_add_killed_bb(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 896
  %.015 = load ptr, ptr %3, align 8, !tbaa !5
  %.not.not16 = icmp eq ptr %.015, null
  br i1 %.not.not16, label %.critedge.thread, label %.lr.ph

.critedge.thread:                                 ; preds = %2
  %4 = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 1, i64 noundef 16) #2
  store ptr %1, ptr %4, align 8, !tbaa !9
  br label %10

5:                                                ; preds = %.lr.ph
  %6 = getelementptr inbounds i8, ptr %.017, i64 8
  %.0 = load ptr, ptr %6, align 8, !tbaa !5
  %.not.not = icmp eq ptr %.0, null
  br i1 %.not.not, label %.critedge, label %.lr.ph, !llvm.loop !11

.lr.ph:                                           ; preds = %2, %5
  %.017 = phi ptr [ %.0, %5 ], [ %.015, %2 ]
  %7 = load ptr, ptr %.017, align 8, !tbaa !9
  %8 = icmp eq ptr %7, %1
  br i1 %8, label %.loopexit, label %5

.critedge:                                        ; preds = %5
  %9 = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 1, i64 noundef 16) #2
  store ptr %1, ptr %9, align 8, !tbaa !9
  br i1 %.not.not16, label %10, label %12

10:                                               ; preds = %.critedge.thread, %.critedge
  %11 = phi ptr [ %4, %.critedge.thread ], [ %9, %.critedge ]
  store ptr %11, ptr %3, align 8, !tbaa !13
  br label %16

12:                                               ; preds = %.critedge
  %13 = getelementptr inbounds i8, ptr %0, i64 904
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store ptr %9, ptr %15, align 8, !tbaa !20
  br label %16

16:                                               ; preds = %12, %10
  %17 = phi ptr [ %9, %12 ], [ %11, %10 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 904
  store ptr %17, ptr %18, align 8, !tbaa !19
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %16
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #1 = { nofree 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 allocsize(0,1) }

!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 0}
!10 = !{!"ref_block", !6, i64 0, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 896}
!14 = !{!"var", !7, i64 0, !7, i64 32, !15, i64 64, !16, i64 68, !16, i64 69, !15, i64 72, !15, i64 76, !15, i64 80, !15, i64 84, !15, i64 88, !6, i64 96, !15, i64 104, !7, i64 112, !15, i64 624, !17, i64 628, !18, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !15, i64 936, !16, i64 940, !16, i64 941, !16, i64 942}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"", !15, i64 0, !7, i64 4, !15, i64 260}
!18 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!19 = !{!14, !6, i64 904}
!20 = !{!10, !6, i64 8}


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