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

@ATOM = external dso_local global i64, align 8
@CONS = external dso_local global i64, align 8
@cell = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

; 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
define dso_local double @assoc(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
  br label %5

5:                                                ; preds = %20, %2
  %6 = load i64, ptr %4, align 8, !tbaa !9
  %7 = lshr i64 %6, 48
  %8 = load i64, ptr @CONS, align 8, !tbaa !9
  %9 = icmp eq i64 %7, %8
  br i1 %9, label %10, label %18

10:                                               ; preds = %5
  %11 = load double, ptr %3, align 8, !tbaa !5
  %12 = load double, ptr %4, align 8, !tbaa !5
  %13 = call double @car(double noundef %12)
  %14 = call double @car(double noundef %13)
  %15 = call i64 @equ(double noundef %11, double noundef %14)
  %16 = icmp ne i64 %15, 0
  %17 = xor i1 %16, true
  br label %18

18:                                               ; preds = %10, %5
  %19 = phi i1 [ false, %5 ], [ %17, %10 ]
  br i1 %19, label %20, label %23

20:                                               ; preds = %18
  %21 = load double, ptr %4, align 8, !tbaa !5
  %22 = call double @cdr(double noundef %21)
  store double %22, ptr %4, align 8, !tbaa !5
  br label %5, !llvm.loop !11

23:                                               ; preds = %18
  %24 = load i64, ptr %4, align 8, !tbaa !9
  %25 = lshr i64 %24, 48
  %26 = load i64, ptr @CONS, align 8, !tbaa !9
  %27 = icmp eq i64 %25, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %23
  %29 = load double, ptr %4, align 8, !tbaa !5
  %30 = call double @car(double noundef %29)
  %31 = call double @cdr(double noundef %30)
  br label %49

32:                                               ; preds = %23
  %33 = load i64, ptr %3, align 8, !tbaa !9
  %34 = lshr i64 %33, 48
  %35 = load i64, ptr @ATOM, align 8, !tbaa !9
  %36 = icmp eq i64 %34, %35
  br i1 %36, label %37, label %45

37:                                               ; preds = %32
  %38 = load ptr, ptr @stderr, align 8, !tbaa !13
  %39 = load ptr, ptr @cell, align 8, !tbaa !13
  %40 = load double, ptr %3, align 8, !tbaa !5
  %41 = call i64 @ord(double noundef %40)
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.9, ptr noundef %42) #2
  %44 = call double @err(i32 noundef 3)
  br label %47

45:                                               ; preds = %32
  %46 = call double @err(i32 noundef 3)
  br label %47

47:                                               ; preds = %45, %37
  %48 = phi double [ %44, %37 ], [ %46, %45 ]
  br label %49

49:                                               ; preds = %47, %28
  %50 = phi double [ %31, %28 ], [ %48, %47 ]
  ret double %50
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

!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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !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"

@ATOM = external dso_local local_unnamed_addr global i64, align 8
@CONS = external dso_local local_unnamed_addr global i64, align 8
@cell = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

; 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
define dso_local double @assoc(double noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = bitcast double %1 to i64
  %4 = lshr i64 %3, 48
  %5 = load i64, ptr @CONS, align 8, !tbaa !5
  %6 = icmp eq i64 %4, %5
  br i1 %6, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %2
  %7 = tail call double @car(double noundef %1)
  %8 = tail call double @car(double noundef %7)
  %9 = tail call i64 @equ(double noundef %0, double noundef %8)
  %.not25 = icmp eq i64 %9, 0
  br i1 %.not25, label %.lr.ph27, label %.lr.ph..critedge.loopexit_crit_edge

.lr.ph:                                           ; preds = %.lr.ph27
  %10 = tail call double @car(double noundef %13)
  %11 = tail call double @car(double noundef %10)
  %12 = tail call i64 @equ(double noundef %0, double noundef %11)
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %.lr.ph27, label %.lr.ph..critedge.loopexit_crit_edge, !llvm.loop !9

.lr.ph..critedge.loopexit_crit_edge:              ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa20 = phi i64 [ %4, %.lr.ph.preheader ], [ %15, %.lr.ph ]
  %.07.lcssa = phi double [ %1, %.lr.ph.preheader ], [ %13, %.lr.ph ]
  %.pre.pre = load i64, ptr @CONS, align 8, !tbaa !5
  br label %.critedge

.lr.ph27:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0726 = phi double [ %13, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  %13 = tail call double @cdr(double noundef %.0726)
  %14 = bitcast double %13 to i64
  %15 = lshr i64 %14, 48
  %16 = load i64, ptr @CONS, align 8, !tbaa !5
  %17 = icmp eq i64 %15, %16
  br i1 %17, label %.lr.ph, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph27, %.lr.ph..critedge.loopexit_crit_edge, %2
  %18 = phi i64 [ %5, %2 ], [ %.pre.pre, %.lr.ph..critedge.loopexit_crit_edge ], [ %16, %.lr.ph27 ]
  %.0.lcssa = phi double [ %1, %2 ], [ %.07.lcssa, %.lr.ph..critedge.loopexit_crit_edge ], [ %13, %.lr.ph27 ]
  %.lcssa = phi i64 [ %4, %2 ], [ %.lcssa20, %.lr.ph..critedge.loopexit_crit_edge ], [ %15, %.lr.ph27 ]
  %19 = icmp eq i64 %.lcssa, %18
  br i1 %19, label %20, label %23

20:                                               ; preds = %.critedge
  %21 = tail call double @car(double noundef %.0.lcssa)
  %22 = tail call double @cdr(double noundef %21)
  br label %37

23:                                               ; preds = %.critedge
  %24 = bitcast double %0 to i64
  %25 = lshr i64 %24, 48
  %26 = load i64, ptr @ATOM, align 8, !tbaa !5
  %27 = icmp eq i64 %25, %26
  br i1 %27, label %28, label %35

28:                                               ; preds = %23
  %29 = load ptr, ptr @stderr, align 8, !tbaa !11
  %30 = load ptr, ptr @cell, align 8, !tbaa !11
  %31 = tail call i64 @ord(double noundef %0)
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.9, ptr noundef %32) #2
  %34 = tail call double @err(i32 noundef 3)
  br label %37

35:                                               ; preds = %23
  %36 = tail call double @err(i32 noundef 3)
  br label %37

37:                                               ; preds = %28, %35, %20
  %38 = phi double [ %22, %20 ], [ %34, %28 ], [ %36, %35 ]
  ret double %38
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass