; 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._expreval_t = type { ptr, i64, i64, i64, double, i32, i32 }
%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 }

@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @lil_eval_expr(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct._expreval_t, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call ptr @lil_subst_to_value(ptr noundef %8, ptr noundef %9)
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._lil_t, ptr %11, i32 0, i32 16
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %64

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call ptr @lil_to_string(ptr noundef %17)
  %19 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 0
  store ptr %18, ptr %19, align 8, !tbaa !14
  %20 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %21, i64 0
  %23 = load i8, ptr %22, align 1, !tbaa !17
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %28, label %25

25:                                               ; preds = %16
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @lil_free_value(ptr noundef %26)
  %27 = call ptr @lil_alloc_integer(i64 noundef 0)
  store ptr %27, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %64

28:                                               ; preds = %16
  %29 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 2
  store i64 0, ptr %29, align 8, !tbaa !18
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._lil_value_t, ptr %30, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !19
  %33 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 1
  store i64 %32, ptr %33, align 8, !tbaa !21
  %34 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 3
  store i64 0, ptr %34, align 8, !tbaa !22
  %35 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 4
  store double 0.000000e+00, ptr %35, align 8, !tbaa !23
  %36 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 5
  store i32 0, ptr %36, align 8, !tbaa !24
  %37 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 6
  store i32 0, ptr %37, align 4, !tbaa !25
  call void @ee_expr(ptr noundef %6)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @lil_free_value(ptr noundef %38)
  %39 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 6
  %40 = load i32, ptr %39, align 4, !tbaa !25
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %52

42:                                               ; preds = %28
  %43 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 6
  %44 = load i32, ptr %43, align 4, !tbaa !25
  switch i32 %44, label %51 [
    i32 3, label %45
    i32 2, label %47
    i32 1, label %49
  ]

45:                                               ; preds = %42
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  call void @lil_set_error(ptr noundef %46, ptr noundef @.str.7)
  br label %51

47:                                               ; preds = %42
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  call void @lil_set_error(ptr noundef %48, ptr noundef @.str.8)
  br label %51

49:                                               ; preds = %42
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  call void @lil_set_error(ptr noundef %50, ptr noundef @.str.9)
  br label %51

51:                                               ; preds = %49, %47, %45, %42
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %64

52:                                               ; preds = %28
  %53 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 5
  %54 = load i32, ptr %53, align 8, !tbaa !24
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %60

56:                                               ; preds = %52
  %57 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !22
  %59 = call ptr @lil_alloc_integer(i64 noundef %58)
  store ptr %59, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %64

60:                                               ; preds = %52
  %61 = getelementptr inbounds %struct._expreval_t, ptr %6, i32 0, i32 4
  %62 = load double, ptr %61, align 8, !tbaa !23
  %63 = call ptr @lil_alloc_double(double noundef %62)
  store ptr %63, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %64

64:                                               ; preds = %60, %56, %51, %25, %15
  call void @llvm.lifetime.end.p0(i64 48, ptr %6) #2
  %65 = load ptr, ptr %3, align 8
  ret ptr %65
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @lil_alloc_double(double 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, !12, i64 4216}
!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 = !{!15, !6, i64 0}
!15 = !{!"_expreval_t", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !16, i64 32, !12, i64 40, !12, i64 44}
!16 = !{!"double", !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!15, !11, i64 16}
!19 = !{!20, !11, i64 0}
!20 = !{!"_lil_value_t", !11, i64 0, !6, i64 8}
!21 = !{!15, !11, i64 8}
!22 = !{!15, !11, i64 24}
!23 = !{!15, !16, i64 32}
!24 = !{!15, !12, i64 40}
!25 = !{!15, !12, i64 44}


; 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._expreval_t = type { ptr, i64, i64, i64, double, i32, i32 }

@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @lil_eval_expr(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %struct._expreval_t, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #3
  %4 = tail call ptr @lil_subst_to_value(ptr noundef %0, ptr noundef %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 4216
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %33

7:                                                ; preds = %2
  %8 = tail call ptr @lil_to_string(ptr noundef %4)
  store ptr %8, ptr %3, align 8, !tbaa !13
  %9 = load i8, ptr %8, align 1, !tbaa !16
  %.not12 = icmp eq i8 %9, 0
  br i1 %.not12, label %10, label %12

10:                                               ; preds = %7
  tail call void @lil_free_value(ptr noundef %4)
  %11 = tail call ptr @lil_alloc_integer(i64 noundef 0)
  br label %33

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 0, ptr %13, align 8, !tbaa !17
  %14 = load i64, ptr %4, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 %14, ptr %15, align 8, !tbaa !20
  %16 = getelementptr inbounds i8, ptr %3, i64 24
  %17 = getelementptr inbounds i8, ptr %3, i64 32
  %18 = getelementptr inbounds i8, ptr %3, i64 44
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %16, i8 0, i64 24, i1 false)
  call void @ee_expr(ptr noundef nonnull %3)
  call void @lil_free_value(ptr noundef nonnull %4)
  %19 = load i32, ptr %18, align 4, !tbaa !21
  switch i32 %19, label %33 [
    i32 0, label %23
    i32 3, label %20
    i32 2, label %21
    i32 1, label %22
  ]

20:                                               ; preds = %12
  call void @lil_set_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.7)
  br label %33

21:                                               ; preds = %12
  call void @lil_set_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.8)
  br label %33

22:                                               ; preds = %12
  call void @lil_set_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.9)
  br label %33

23:                                               ; preds = %12
  %24 = getelementptr inbounds i8, ptr %3, i64 40
  %25 = load i32, ptr %24, align 8, !tbaa !22
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load i64, ptr %16, align 8, !tbaa !23
  %29 = call ptr @lil_alloc_integer(i64 noundef %28)
  br label %33

30:                                               ; preds = %23
  %31 = load double, ptr %17, align 8, !tbaa !24
  %32 = call ptr @lil_alloc_double(double noundef %31)
  br label %33

33:                                               ; preds = %20, %21, %22, %12, %2, %30, %27, %10
  %.0 = phi ptr [ %29, %27 ], [ %32, %30 ], [ %11, %10 ], [ null, %2 ], [ null, %12 ], [ null, %22 ], [ null, %21 ], [ null, %20 ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #3
  ret ptr %.0
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 4216}
!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 = !{!14, !7, i64 0}
!14 = !{!"_expreval_t", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !15, i64 32, !11, i64 40, !11, i64 44}
!15 = !{!"double", !8, i64 0}
!16 = !{!8, !8, i64 0}
!17 = !{!14, !10, i64 16}
!18 = !{!19, !10, i64 0}
!19 = !{!"_lil_value_t", !10, i64 0, !7, i64 8}
!20 = !{!14, !10, i64 8}
!21 = !{!14, !11, i64 44}
!22 = !{!14, !11, i64 40}
!23 = !{!14, !10, i64 24}
!24 = !{!14, !15, i64 32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass