; LLVM IR from PaulBatchelor/sndkit :: lil (lil)

; 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._lil_t = type { ptr, ptr, i64, i64, i32, ptr, i64, i64, %struct._hashmap_t, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i64, ptr, [8 x ptr], i64, ptr, ptr, i64 }
%struct._hashmap_t = type { [256 x %struct.hashcell_t] }
%struct.hashcell_t = type { ptr, i64 }
%struct._lil_env_t = type { ptr, ptr, ptr, ptr, i64, %struct._hashmap_t, ptr, i32, i32 }
%struct._lil_func_t = type { ptr, ptr, 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
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 @lil_free_value(ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden void @hm_destroy(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @lil_free(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  store i32 1, ptr %4, align 4
  br label %98

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._lil_t, ptr %10, i32 0, i32 18
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  call void @free(ptr noundef %12) #3
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._lil_t, ptr %13, i32 0, i32 15
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  call void @lil_free_value(ptr noundef %15)
  br label %16

16:                                               ; preds = %21, %9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._lil_t, ptr %17, i32 0, i32 12
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %33

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._lil_t, ptr %22, i32 0, i32 12
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct._lil_env_t, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._lil_t, ptr %27, i32 0, i32 12
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  call void @lil_free_env(ptr noundef %29)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._lil_t, ptr %31, i32 0, i32 12
  store ptr %30, ptr %32, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %16, !llvm.loop !18

33:                                               ; preds = %16
  store i64 0, ptr %3, align 8, !tbaa !20
  br label %34

34:                                               ; preds = %82, %33
  %35 = load i64, ptr %3, align 8, !tbaa !20
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._lil_t, ptr %36, i32 0, i32 6
  %38 = load i64, ptr %37, align 8, !tbaa !21
  %39 = icmp ult i64 %35, %38
  br i1 %39, label %40, label %85

40:                                               ; preds = %34
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._lil_t, ptr %41, i32 0, i32 5
  %43 = load ptr, ptr %42, align 8, !tbaa !22
  %44 = load i64, ptr %3, align 8, !tbaa !20
  %45 = getelementptr inbounds ptr, ptr %43, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._lil_func_t, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !23
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %59

50:                                               ; preds = %40
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._lil_t, ptr %51, i32 0, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  %54 = load i64, ptr %3, align 8, !tbaa !20
  %55 = getelementptr inbounds ptr, ptr %53, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._lil_func_t, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !23
  call void @lil_free_list(ptr noundef %58)
  br label %59

59:                                               ; preds = %50, %40
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._lil_t, ptr %60, i32 0, i32 5
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = load i64, ptr %3, align 8, !tbaa !20
  %64 = getelementptr inbounds ptr, ptr %62, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._lil_func_t, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !25
  call void @lil_free_value(ptr noundef %67)
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._lil_t, ptr %68, i32 0, i32 5
  %70 = load ptr, ptr %69, align 8, !tbaa !22
  %71 = load i64, ptr %3, align 8, !tbaa !20
  %72 = getelementptr inbounds ptr, ptr %70, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._lil_func_t, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !26
  call void @free(ptr noundef %75) #3
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._lil_t, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %77, align 8, !tbaa !22
  %79 = load i64, ptr %3, align 8, !tbaa !20
  %80 = getelementptr inbounds ptr, ptr %78, i64 %79
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  call void @free(ptr noundef %81) #3
  br label %82

82:                                               ; preds = %59
  %83 = load i64, ptr %3, align 8, !tbaa !20
  %84 = add i64 %83, 1
  store i64 %84, ptr %3, align 8, !tbaa !20
  br label %34, !llvm.loop !27

85:                                               ; preds = %34
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._lil_t, ptr %86, i32 0, i32 8
  call void @hm_destroy(ptr noundef %87)
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._lil_t, ptr %88, i32 0, i32 5
  %90 = load ptr, ptr %89, align 8, !tbaa !22
  call void @free(ptr noundef %90) #3
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._lil_t, ptr %91, i32 0, i32 11
  %93 = load ptr, ptr %92, align 8, !tbaa !28
  call void @free(ptr noundef %93) #3
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._lil_t, ptr %94, i32 0, i32 9
  %96 = load ptr, ptr %95, align 8, !tbaa !29
  call void @free(ptr noundef %96) #3
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %97) #3
  store i32 0, ptr %4, align 4
  br label %98

98:                                               ; preds = %85, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %99 = load i32, ptr %4, align 4
  switch i32 %99, label %101 [
    i32 0, label %100
    i32 1, label %100
  ]

100:                                              ; preds = %98, %98
  ret void

101:                                              ; preds = %98
  unreachable
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 4232}
!10 = !{!"_lil_t", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !6, i64 40, !11, i64 48, !11, i64 56, !13, i64 64, !6, i64 4160, !12, i64 4168, !6, i64 4176, !6, i64 4184, !6, i64 4192, !6, i64 4200, !6, i64 4208, !12, i64 4216, !11, i64 4224, !6, i64 4232, !7, i64 4240, !11, i64 4304, !6, i64 4312, !6, i64 4320, !11, i64 4328}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_hashmap_t", !7, i64 0}
!14 = !{!10, !6, i64 4208}
!15 = !{!10, !6, i64 4184}
!16 = !{!17, !6, i64 0}
!17 = !{!"_lil_env_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !13, i64 40, !6, i64 4136, !12, i64 4144, !12, i64 4148}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 48}
!22 = !{!10, !6, i64 40}
!23 = !{!24, !6, i64 16}
!24 = !{!"_lil_func_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!24, !6, i64 8}
!26 = !{!24, !6, i64 0}
!27 = distinct !{!27, !19}
!28 = !{!10, !6, i64 4176}
!29 = !{!10, !6, i64 4160}


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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @lil_free(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %42, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 4232
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @free(ptr noundef %4) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 4208
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  tail call void @lil_free_value(ptr noundef %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 4184
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %.not2830 = icmp eq ptr %8, null
  br i1 %.not2830, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %2
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load i64, ptr %9, align 8, !tbaa !15
  %.not33 = icmp eq i64 %10, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph32

.lr.ph32:                                         ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  br label %14

.lr.ph:                                           ; preds = %2, %.lr.ph
  %12 = phi ptr [ %13, %.lr.ph ], [ %8, %2 ]
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  tail call void @lil_free_env(ptr noundef nonnull %12)
  store ptr %13, ptr %7, align 8, !tbaa !14
  %.not28 = icmp eq ptr %13, null
  br i1 %.not28, label %.preheader, label %.lr.ph, !llvm.loop !18

14:                                               ; preds = %.lr.ph32, %21
  %.031 = phi i64 [ 0, %.lr.ph32 ], [ %32, %21 ]
  %15 = load ptr, ptr %11, align 8, !tbaa !20
  %16 = getelementptr inbounds ptr, ptr %15, i64 %.031
  %17 = load ptr, ptr %16, align 8, !tbaa !21
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !22
  %.not29 = icmp eq ptr %19, null
  br i1 %.not29, label %21, label %20

20:                                               ; preds = %14
  tail call void @lil_free_list(ptr noundef nonnull %19)
  %.pre = load ptr, ptr %11, align 8, !tbaa !20
  %.phi.trans.insert = getelementptr inbounds ptr, ptr %.pre, i64 %.031
  %.pre34 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !21
  br label %21

21:                                               ; preds = %20, %14
  %22 = phi ptr [ %.pre34, %20 ], [ %17, %14 ]
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !24
  tail call void @lil_free_value(ptr noundef %24)
  %25 = load ptr, ptr %11, align 8, !tbaa !20
  %26 = getelementptr inbounds ptr, ptr %25, i64 %.031
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = load ptr, ptr %27, align 8, !tbaa !25
  tail call void @free(ptr noundef %28) #2
  %29 = load ptr, ptr %11, align 8, !tbaa !20
  %30 = getelementptr inbounds ptr, ptr %29, i64 %.031
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  tail call void @free(ptr noundef %31) #2
  %32 = add nuw i64 %.031, 1
  %33 = load i64, ptr %9, align 8, !tbaa !15
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %14, label %._crit_edge, !llvm.loop !26

._crit_edge:                                      ; preds = %21, %.preheader
  %35 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @hm_destroy(ptr noundef nonnull %35)
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  tail call void @free(ptr noundef %37) #2
  %38 = getelementptr inbounds i8, ptr %0, i64 4176
  %39 = load ptr, ptr %38, align 8, !tbaa !27
  tail call void @free(ptr noundef %39) #2
  %40 = getelementptr inbounds i8, ptr %0, i64 4160
  %41 = load ptr, ptr %40, align 8, !tbaa !28
  tail call void @free(ptr noundef %41) #2
  tail call void @free(ptr noundef nonnull %0) #2
  br label %42

42:                                               ; preds = %1, %._crit_edge
  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 4232}
!6 = !{!"_lil_t", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !12, i64 64, !7, i64 4160, !11, i64 4168, !7, i64 4176, !7, i64 4184, !7, i64 4192, !7, i64 4200, !7, i64 4208, !11, i64 4216, !10, i64 4224, !7, i64 4232, !8, i64 4240, !10, i64 4304, !7, i64 4312, !7, i64 4320, !10, i64 4328}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_hashmap_t", !8, i64 0}
!13 = !{!6, !7, i64 4208}
!14 = !{!6, !7, i64 4184}
!15 = !{!6, !10, i64 48}
!16 = !{!17, !7, i64 0}
!17 = !{!"_lil_env_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !12, i64 40, !7, i64 4136, !11, i64 4144, !11, i64 4148}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!6, !7, i64 40}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !7, i64 16}
!23 = !{!"_lil_func_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!24 = !{!23, !7, i64 8}
!25 = !{!23, !7, i64 0}
!26 = distinct !{!26, !19}
!27 = !{!6, !7, i64 4176}
!28 = !{!6, !7, i64 4160}


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