; 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_value_t = type { i64, 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 ptr @lil_alloc_list() #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @lil_to_string(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @lil_subst_to_list(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  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 8, ptr %5) #2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._lil_t, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._lil_t, ptr %13, i32 0, i32 2
  %15 = load i64, ptr %14, align 8, !tbaa !14
  store i64 %15, ptr %6, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._lil_t, ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !16
  store i64 %18, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._lil_t, ptr %19, i32 0, i32 4
  %21 = load i32, ptr %20, align 8, !tbaa !17
  store i32 %21, ptr %8, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call ptr @lil_to_string(ptr noundef %22)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._lil_t, ptr %24, i32 0, i32 0
  store ptr %23, ptr %25, align 8, !tbaa !9
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._lil_value_t, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !19
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._lil_t, ptr %29, i32 0, i32 2
  store i64 %28, ptr %30, align 8, !tbaa !14
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._lil_t, ptr %31, i32 0, i32 3
  store i64 0, ptr %32, align 8, !tbaa !16
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._lil_t, ptr %33, i32 0, i32 4
  store i32 1, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = call ptr @substitute(ptr noundef %35)
  store ptr %36, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %41, label %39

39:                                               ; preds = %2
  %40 = call ptr @lil_alloc_list()
  store ptr %40, ptr %9, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %39, %2
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._lil_t, ptr %43, i32 0, i32 0
  store ptr %42, ptr %44, align 8, !tbaa !9
  %45 = load i64, ptr %6, align 8, !tbaa !15
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._lil_t, ptr %46, i32 0, i32 2
  store i64 %45, ptr %47, align 8, !tbaa !14
  %48 = load i64, ptr %7, align 8, !tbaa !15
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._lil_t, ptr %49, i32 0, i32 3
  store i64 %48, ptr %50, align 8, !tbaa !16
  %51 = load i32, ptr %8, align 4, !tbaa !18
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._lil_t, ptr %52, i32 0, i32 4
  store i32 %51, ptr %53, align 8, !tbaa !17
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret ptr %54
}

; Function Attrs: nounwind uwtable
declare hidden ptr @substitute(ptr noundef) #1

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, !6, i64 0}
!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, !11, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !12, i64 32}
!18 = !{!12, !12, i64 0}
!19 = !{!20, !11, i64 0}
!20 = !{!"_lil_value_t", !11, i64 0, !6, i64 8}


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

; Function Attrs: nounwind uwtable
declare dso_local ptr @lil_to_string(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @lil_subst_to_list(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load <2 x i64>, ptr %4, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = tail call ptr @lil_to_string(ptr noundef %1)
  store ptr %9, ptr %0, align 8, !tbaa !5
  %10 = load i64, ptr %1, align 8, !tbaa !15
  store i64 %10, ptr %4, align 8, !tbaa !17
  store i64 0, ptr %5, align 8, !tbaa !18
  store i32 1, ptr %7, align 8, !tbaa !14
  %11 = tail call ptr @substitute(ptr noundef nonnull %0)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %14

12:                                               ; preds = %2
  %13 = tail call ptr @lil_alloc_list()
  br label %14

14:                                               ; preds = %12, %2
  %.0 = phi ptr [ %11, %2 ], [ %13, %12 ]
  store ptr %3, ptr %0, align 8, !tbaa !5
  store <2 x i64> %6, ptr %4, align 8, !tbaa !13
  store i32 %8, ptr %7, align 8, !tbaa !14
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @substitute(ptr noundef) local_unnamed_addr #0

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, !7, i64 0}
!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 = !{!10, !10, i64 0}
!14 = !{!6, !11, i64 32}
!15 = !{!16, !10, i64 0}
!16 = !{!"_lil_value_t", !10, i64 0, !7, i64 8}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass