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

@NIL = external dso_local global i64, align 8

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @f_cond(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %22, %2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = lshr i64 %7, 48
  %9 = load i64, ptr @NIL, align 8, !tbaa !9
  %10 = icmp ne i64 %8, %9
  br i1 %10, label %11, label %20

11:                                               ; preds = %5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = call double @car(double noundef %13)
  %15 = call double @car(double noundef %14)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call double @eval(double noundef %15, ptr noundef %16)
  %18 = call i32 @not(double noundef %17)
  %19 = icmp ne i32 %18, 0
  br label %20

20:                                               ; preds = %11, %5
  %21 = phi i1 [ false, %5 ], [ %19, %11 ]
  br i1 %21, label %22, label %27

22:                                               ; preds = %20
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = call double @cdr(double noundef %24)
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  store double %25, ptr %26, align 8, !tbaa !11
  br label %5, !llvm.loop !13

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = lshr i64 %29, 48
  %31 = load i64, ptr @NIL, align 8, !tbaa !9
  %32 = icmp ne i64 %30, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %27
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = call double @car(double noundef %35)
  %37 = call double @cdr(double noundef %36)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  store double %37, ptr %38, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %33, %27
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call double @f_begin(ptr noundef %40, ptr noundef %41)
  ret double %42
}

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}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@NIL = external dso_local local_unnamed_addr global i64, align 8

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @f_cond(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i64, ptr %0, align 8
  %4 = lshr i64 %3, 48
  %5 = load i64, ptr @NIL, align 8, !tbaa !5
  %.not12 = icmp eq i64 %4, %5
  br i1 %.not12, label %.critedge.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %6 = bitcast i64 %3 to double
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %12
  %7 = phi double [ %14, %12 ], [ %6, %.lr.ph.preheader ]
  %8 = tail call double @car(double noundef %7)
  %9 = tail call double @car(double noundef %8)
  %10 = tail call double @eval(double noundef %9, ptr noundef %1)
  %11 = tail call i32 @not(double noundef %10)
  %.not10 = icmp eq i32 %11, 0
  br i1 %.not10, label %.critedge, label %12

12:                                               ; preds = %.lr.ph
  %13 = load double, ptr %0, align 8, !tbaa !9
  %14 = tail call double @cdr(double noundef %13)
  store double %14, ptr %0, align 8, !tbaa !9
  %.cast = bitcast double %14 to i64
  %15 = lshr i64 %.cast, 48
  %16 = load i64, ptr @NIL, align 8, !tbaa !5
  %.not = icmp eq i64 %15, %16
  br i1 %.not, label %.critedge.thread, label %.lr.ph, !llvm.loop !11

.critedge:                                        ; preds = %.lr.ph
  %.pre.pre = load i64, ptr %0, align 8
  %.pre14.pre = load i64, ptr @NIL, align 8, !tbaa !5
  %.pre18 = lshr i64 %.pre.pre, 48
  %.not11 = icmp eq i64 %.pre18, %.pre14.pre
  br i1 %.not11, label %.critedge.thread, label %17

17:                                               ; preds = %.critedge
  %18 = bitcast i64 %.pre.pre to double
  %19 = tail call double @car(double noundef %18)
  %20 = tail call double @cdr(double noundef %19)
  store double %20, ptr %0, align 8, !tbaa !9
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %12, %2, %17, %.critedge
  %21 = tail call double @f_begin(ptr noundef nonnull %0, ptr noundef %1)
  ret double %21
}

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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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