; 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.block_list_t = type { ptr, ptr }
%struct.block = type { [1600 x %struct.var], i32, ptr, ptr, ptr, 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 }

@TYPES = external dso_local global ptr, align 8
@GLOBAL_IR = external dso_local global ptr, align 8
@PH1_IR = external dso_local global ptr, align 8
@PH2_IR_FLATTEN = external dso_local global ptr, align 8
@BB_ARENA = external dso_local global ptr, align 8
@BLOCKS = external dso_local global %struct.block_list_t, align 8
@ALIASES_MAP = external dso_local global ptr, align 8
@MACROS = external dso_local global ptr, align 8
@CONSTANTS_MAP = external dso_local global ptr, align 8
@FUNC_MAP = external dso_local global ptr, align 8
@INSN_ARENA = external dso_local global ptr, align 8
@SOURCE = external dso_local global ptr, align 8
@INCLUSION_MAP = external dso_local global ptr, align 8
@elf_code = external dso_local global ptr, align 8
@elf_data = external dso_local global ptr, align 8
@elf_header = external dso_local global ptr, align 8
@elf_symtab = external dso_local global ptr, align 8
@elf_strtab = external dso_local global ptr, align 8
@elf_section = external dso_local global ptr, 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: nounwind
declare void @free(ptr 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
declare dso_local void @arena_free(ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @global_release() #2 {
  %1 = alloca ptr, align 8
  br label %2

2:                                                ; preds = %5, %0
  %3 = load ptr, ptr @BLOCKS, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  br i1 %4, label %5, label %11

5:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %6 = load ptr, ptr @BLOCKS, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.block, ptr %6, i32 0, i32 6
  %8 = load ptr, ptr %7, align 8, !tbaa !10
  store ptr %8, ptr %1, align 8, !tbaa !13
  %9 = load ptr, ptr @BLOCKS, align 8, !tbaa !5
  call void @free(ptr noundef %9) #3
  %10 = load ptr, ptr %1, align 8, !tbaa !13
  store ptr %10, ptr @BLOCKS, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  br label %2, !llvm.loop !14

11:                                               ; preds = %2
  %12 = load ptr, ptr @MACROS, align 8, !tbaa !13
  call void @free(ptr noundef %12) #3
  %13 = load ptr, ptr @FUNC_MAP, align 8, !tbaa !13
  call void @hashmap_free(ptr noundef %13)
  %14 = load ptr, ptr @TYPES, align 8, !tbaa !13
  call void @free(ptr noundef %14) #3
  %15 = load ptr, ptr @GLOBAL_IR, align 8, !tbaa !13
  call void @free(ptr noundef %15) #3
  %16 = load ptr, ptr @PH1_IR, align 8, !tbaa !13
  call void @free(ptr noundef %16) #3
  %17 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !13
  call void @arena_free(ptr noundef %17)
  %18 = load ptr, ptr @BB_ARENA, align 8, !tbaa !13
  call void @arena_free(ptr noundef %18)
  %19 = load ptr, ptr @PH2_IR_FLATTEN, align 8, !tbaa !13
  call void @free(ptr noundef %19) #3
  %20 = load ptr, ptr @SOURCE, align 8, !tbaa !13
  call void @source_free(ptr noundef %20)
  %21 = load ptr, ptr @INCLUSION_MAP, align 8, !tbaa !13
  call void @hashmap_free(ptr noundef %21)
  %22 = load ptr, ptr @ALIASES_MAP, align 8, !tbaa !13
  call void @hashmap_free(ptr noundef %22)
  %23 = load ptr, ptr @CONSTANTS_MAP, align 8, !tbaa !13
  call void @hashmap_free(ptr noundef %23)
  %24 = load ptr, ptr @elf_code, align 8, !tbaa !13
  call void @free(ptr noundef %24) #3
  %25 = load ptr, ptr @elf_data, align 8, !tbaa !13
  call void @free(ptr noundef %25) #3
  %26 = load ptr, ptr @elf_header, align 8, !tbaa !13
  call void @free(ptr noundef %26) #3
  %27 = load ptr, ptr @elf_symtab, align 8, !tbaa !13
  call void @free(ptr noundef %27) #3
  %28 = load ptr, ptr @elf_strtab, align 8, !tbaa !13
  call void @free(ptr noundef %28) #3
  %29 = load ptr, ptr @elf_section, align 8, !tbaa !13
  call void @free(ptr noundef %29) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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, !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 = !{!11, !7, i64 1510440}
!11 = !{!"block", !8, i64 0, !12, i64 1510400, !7, i64 1510408, !7, i64 1510416, !7, i64 1510424, !12, i64 1510432, !7, i64 1510440}
!12 = !{!"int", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.block_list_t = type { ptr, ptr }

@TYPES = external dso_local local_unnamed_addr global ptr, align 8
@GLOBAL_IR = external dso_local local_unnamed_addr global ptr, align 8
@PH1_IR = external dso_local local_unnamed_addr global ptr, align 8
@PH2_IR_FLATTEN = external dso_local local_unnamed_addr global ptr, align 8
@BB_ARENA = external dso_local local_unnamed_addr global ptr, align 8
@BLOCKS = external dso_local local_unnamed_addr global %struct.block_list_t, align 8
@ALIASES_MAP = external dso_local local_unnamed_addr global ptr, align 8
@MACROS = external dso_local local_unnamed_addr global ptr, align 8
@CONSTANTS_MAP = external dso_local local_unnamed_addr global ptr, align 8
@FUNC_MAP = external dso_local local_unnamed_addr global ptr, align 8
@INSN_ARENA = external dso_local local_unnamed_addr global ptr, align 8
@SOURCE = external dso_local local_unnamed_addr global ptr, align 8
@INCLUSION_MAP = external dso_local local_unnamed_addr global ptr, align 8
@elf_code = external dso_local local_unnamed_addr global ptr, align 8
@elf_data = external dso_local local_unnamed_addr global ptr, align 8
@elf_header = external dso_local local_unnamed_addr global ptr, align 8
@elf_symtab = external dso_local local_unnamed_addr global ptr, align 8
@elf_strtab = external dso_local local_unnamed_addr global ptr, align 8
@elf_section = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @global_release() local_unnamed_addr #1 {
  %.pr = load ptr, ptr @BLOCKS, align 8, !tbaa !5
  %.not1 = icmp eq ptr %.pr, null
  br i1 %.not1, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %1 = phi ptr [ %3, %.lr.ph ], [ %.pr, %0 ]
  %2 = getelementptr inbounds i8, ptr %1, i64 1510440
  %3 = load ptr, ptr %2, align 8, !tbaa !10
  tail call void @free(ptr noundef nonnull %1) #2
  store ptr %3, ptr @BLOCKS, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %0
  %4 = load ptr, ptr @MACROS, align 8, !tbaa !15
  tail call void @free(ptr noundef %4) #2
  %5 = load ptr, ptr @FUNC_MAP, align 8, !tbaa !15
  tail call void @hashmap_free(ptr noundef %5)
  %6 = load ptr, ptr @TYPES, align 8, !tbaa !15
  tail call void @free(ptr noundef %6) #2
  %7 = load ptr, ptr @GLOBAL_IR, align 8, !tbaa !15
  tail call void @free(ptr noundef %7) #2
  %8 = load ptr, ptr @PH1_IR, align 8, !tbaa !15
  tail call void @free(ptr noundef %8) #2
  %9 = load ptr, ptr @INSN_ARENA, align 8, !tbaa !15
  tail call void @arena_free(ptr noundef %9)
  %10 = load ptr, ptr @BB_ARENA, align 8, !tbaa !15
  tail call void @arena_free(ptr noundef %10)
  %11 = load ptr, ptr @PH2_IR_FLATTEN, align 8, !tbaa !15
  tail call void @free(ptr noundef %11) #2
  %12 = load ptr, ptr @SOURCE, align 8, !tbaa !15
  tail call void @source_free(ptr noundef %12)
  %13 = load ptr, ptr @INCLUSION_MAP, align 8, !tbaa !15
  tail call void @hashmap_free(ptr noundef %13)
  %14 = load ptr, ptr @ALIASES_MAP, align 8, !tbaa !15
  tail call void @hashmap_free(ptr noundef %14)
  %15 = load ptr, ptr @CONSTANTS_MAP, align 8, !tbaa !15
  tail call void @hashmap_free(ptr noundef %15)
  %16 = load ptr, ptr @elf_code, align 8, !tbaa !15
  tail call void @free(ptr noundef %16) #2
  %17 = load ptr, ptr @elf_data, align 8, !tbaa !15
  tail call void @free(ptr noundef %17) #2
  %18 = load ptr, ptr @elf_header, align 8, !tbaa !15
  tail call void @free(ptr noundef %18) #2
  %19 = load ptr, ptr @elf_symtab, align 8, !tbaa !15
  tail call void @free(ptr noundef %19) #2
  %20 = load ptr, ptr @elf_strtab, align 8, !tbaa !15
  tail call void @free(ptr noundef %20) #2
  %21 = load ptr, ptr @elf_section, align 8, !tbaa !15
  tail call void @free(ptr noundef %21) #2
  ret void
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { 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, !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 = !{!11, !7, i64 1510440}
!11 = !{!"block", !8, i64 0, !12, i64 1510400, !7, i64 1510408, !7, i64 1510416, !7, i64 1510424, !12, i64 1510432, !7, i64 1510440}
!12 = !{!"int", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!7, !7, i64 0}


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