; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
define dso_local double @f_setq(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, 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) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = call double @cdr(double noundef %9)
  %11 = call double @car(double noundef %10)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call double @eval(double noundef %11, ptr noundef %12)
  store double %13, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = call double @car(double noundef %15)
  store double %16, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load double, ptr %17, align 8, !tbaa !9
  store double %18, ptr %7, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %35, %2
  %20 = load i64, ptr %7, align 8, !tbaa !11
  %21 = lshr i64 %20, 48
  %22 = load i64, ptr @CONS, align 8, !tbaa !11
  %23 = icmp eq i64 %21, %22
  br i1 %23, label %24, label %32

24:                                               ; preds = %19
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = load double, ptr %7, align 8, !tbaa !9
  %27 = call double @car(double noundef %26)
  %28 = call double @car(double noundef %27)
  %29 = call i64 @equ(double noundef %25, double noundef %28)
  %30 = icmp ne i64 %29, 0
  %31 = xor i1 %30, true
  br label %32

32:                                               ; preds = %24, %19
  %33 = phi i1 [ false, %19 ], [ %31, %24 ]
  br i1 %33, label %34, label %38

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = call double @cdr(double noundef %36)
  store double %37, ptr %7, align 8, !tbaa !9
  br label %19, !llvm.loop !13

38:                                               ; preds = %32
  %39 = load i64, ptr %7, align 8, !tbaa !11
  %40 = lshr i64 %39, 48
  %41 = load i64, ptr @CONS, align 8, !tbaa !11
  %42 = icmp eq i64 %40, %41
  br i1 %42, label %43, label %50

43:                                               ; preds = %38
  %44 = load double, ptr %5, align 8, !tbaa !9
  %45 = load ptr, ptr @cell, align 8, !tbaa !5
  %46 = load double, ptr %7, align 8, !tbaa !9
  %47 = call double @car(double noundef %46)
  %48 = call i64 @ord(double noundef %47)
  %49 = getelementptr inbounds double, ptr %45, i64 %48
  store double %44, ptr %49, align 8, !tbaa !9
  br label %67

50:                                               ; preds = %38
  %51 = load i64, ptr %6, align 8, !tbaa !11
  %52 = lshr i64 %51, 48
  %53 = load i64, ptr @ATOM, align 8, !tbaa !11
  %54 = icmp eq i64 %52, %53
  br i1 %54, label %55, label %63

55:                                               ; preds = %50
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = load ptr, ptr @cell, align 8, !tbaa !5
  %58 = load double, ptr %6, align 8, !tbaa !9
  %59 = call i64 @ord(double noundef %58)
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.9, ptr noundef %60) #3
  %62 = call double @err(i32 noundef 3)
  br label %65

63:                                               ; preds = %50
  %64 = call double @err(i32 noundef 3)
  br label %65

65:                                               ; preds = %63, %55
  %66 = phi double [ %62, %55 ], [ %64, %63 ]
  br label %67

67:                                               ; preds = %65, %43
  %68 = phi double [ %44, %43 ], [ %66, %65 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %68
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

@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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local double @f_setq(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = tail call double @cdr(double noundef %3)
  %5 = tail call double @car(double noundef %4)
  %6 = tail call double @eval(double noundef %5, ptr noundef %1)
  %7 = load double, ptr %0, align 8, !tbaa !5
  %8 = tail call double @car(double noundef %7)
  %9 = load double, ptr %1, align 8, !tbaa !5
  %10 = bitcast double %9 to i64
  %11 = lshr i64 %10, 48
  %12 = load i64, ptr @CONS, align 8, !tbaa !9
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %2
  %14 = tail call double @car(double noundef %9)
  %15 = tail call double @car(double noundef %14)
  %16 = tail call i64 @equ(double noundef %8, double noundef %15)
  %.not30 = icmp eq i64 %16, 0
  br i1 %.not30, label %.lr.ph32, label %.lr.ph..critedge.loopexit_crit_edge

.lr.ph:                                           ; preds = %.lr.ph32
  %17 = tail call double @car(double noundef %20)
  %18 = tail call double @car(double noundef %17)
  %19 = tail call i64 @equ(double noundef %8, double noundef %18)
  %.not = icmp eq i64 %19, 0
  br i1 %.not, label %.lr.ph32, label %.lr.ph..critedge.loopexit_crit_edge, !llvm.loop !11

.lr.ph..critedge.loopexit_crit_edge:              ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa25 = phi i64 [ %11, %.lr.ph.preheader ], [ %22, %.lr.ph ]
  %.012.lcssa = phi double [ %9, %.lr.ph.preheader ], [ %20, %.lr.ph ]
  %.pre.pre = load i64, ptr @CONS, align 8, !tbaa !9
  br label %.critedge

.lr.ph32:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.01231 = phi double [ %20, %.lr.ph ], [ %9, %.lr.ph.preheader ]
  %20 = tail call double @cdr(double noundef %.01231)
  %21 = bitcast double %20 to i64
  %22 = lshr i64 %21, 48
  %23 = load i64, ptr @CONS, align 8, !tbaa !9
  %24 = icmp eq i64 %22, %23
  br i1 %24, label %.lr.ph, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %.lr.ph32, %.lr.ph..critedge.loopexit_crit_edge, %2
  %25 = phi i64 [ %12, %2 ], [ %.pre.pre, %.lr.ph..critedge.loopexit_crit_edge ], [ %23, %.lr.ph32 ]
  %.0.lcssa = phi double [ %9, %2 ], [ %.012.lcssa, %.lr.ph..critedge.loopexit_crit_edge ], [ %20, %.lr.ph32 ]
  %.lcssa = phi i64 [ %11, %2 ], [ %.lcssa25, %.lr.ph..critedge.loopexit_crit_edge ], [ %22, %.lr.ph32 ]
  %26 = icmp eq i64 %.lcssa, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %.critedge
  %28 = load ptr, ptr @cell, align 8, !tbaa !13
  %29 = tail call double @car(double noundef %.0.lcssa)
  %30 = tail call i64 @ord(double noundef %29)
  %31 = getelementptr inbounds double, ptr %28, i64 %30
  store double %6, ptr %31, align 8, !tbaa !5
  br label %46

32:                                               ; preds = %.critedge
  %33 = bitcast double %8 to i64
  %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 %44

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

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

46:                                               ; preds = %37, %44, %27
  %47 = phi double [ %6, %27 ], [ %43, %37 ], [ %45, %44 ]
  ret double %47
}

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 = !{!"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}


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