; LLVM IR from Robert-van-Engelen/lisp-cheney :: src (lisp-cheney)

; 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"

@CONS = external dso_local global i64, align 8
@sp = external dso_local global i64, align 8
@cell = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local double @box(i64 noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @gc(double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local double @cons(double noundef %0, double noundef %1) #0 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !5
  %5 = load double, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr @cell, align 8, !tbaa !9
  %7 = load i64, ptr @sp, align 8, !tbaa !11
  %8 = add i64 %7, -1
  store i64 %8, ptr @sp, align 8, !tbaa !11
  %9 = getelementptr inbounds double, ptr %6, i64 %8
  store double %5, ptr %9, align 8, !tbaa !5
  %10 = load double, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr @cell, align 8, !tbaa !9
  %12 = load i64, ptr @sp, align 8, !tbaa !11
  %13 = add i64 %12, -1
  store i64 %13, ptr @sp, align 8, !tbaa !11
  %14 = getelementptr inbounds double, ptr %11, i64 %13
  store double %10, ptr %14, align 8, !tbaa !5
  %15 = load i64, ptr @CONS, align 8, !tbaa !11
  %16 = load i64, ptr @sp, align 8, !tbaa !11
  %17 = call double @box(i64 noundef %15, i64 noundef %16)
  %18 = call double @gc(double noundef %17)
  ret double %18
}

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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; 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"

@CONS = external dso_local local_unnamed_addr global i64, align 8
@sp = external dso_local local_unnamed_addr global i64, align 8
@cell = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local double @box(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @gc(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @cons(double noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr @cell, align 8, !tbaa !5
  %4 = load i64, ptr @sp, align 8, !tbaa !9
  %5 = getelementptr double, ptr %3, i64 %4
  %6 = getelementptr i8, ptr %5, i64 -8
  store double %0, ptr %6, align 8, !tbaa !11
  %7 = add i64 %4, -2
  store i64 %7, ptr @sp, align 8, !tbaa !9
  %8 = getelementptr inbounds double, ptr %3, i64 %7
  store double %1, ptr %8, align 8, !tbaa !11
  %9 = load i64, ptr @CONS, align 8, !tbaa !9
  %10 = tail call double @box(i64 noundef %9, i64 noundef %7)
  %11 = tail call double @gc(double noundef %10)
  ret double %11
}

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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}


; Effective O3 passes: DSEPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass