; 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
@NIL = external dso_local global i64, align 8
@cell = external dso_local global ptr, align 8
@nil = external dso_local global double, align 8

; Function Attrs: nounwind uwtable
declare dso_local i64 @ord(double 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 @cons(double noundef, double 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
declare dso_local void @var(i32 noundef, ...) #0

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

; Function Attrs: nounwind uwtable
define dso_local double @evlis(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
  %8 = 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) #2
  %9 = load double, ptr @nil, align 8, !tbaa !9
  store double %9, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %10 = load double, ptr @nil, align 8, !tbaa !9
  store double %10, ptr %6, align 8, !tbaa !9
  call void (i32, ...) @var(i32 noundef 2, ptr noundef %5, ptr noundef %6)
  br label %11

11:                                               ; preds = %38, %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = lshr i64 %13, 48
  %15 = load i64, ptr @CONS, align 8, !tbaa !11
  %16 = icmp eq i64 %14, %15
  br i1 %16, label %17, label %43

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = call double @car(double noundef %19)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call double @eval(double noundef %20, ptr noundef %21)
  %23 = load double, ptr @nil, align 8, !tbaa !9
  %24 = call double @cons(double noundef %22, double noundef %23)
  store double %24, ptr %7, align 8, !tbaa !9
  %25 = load double, ptr %7, align 8, !tbaa !9
  %26 = load i64, ptr %6, align 8, !tbaa !11
  %27 = lshr i64 %26, 48
  %28 = load i64, ptr @CONS, align 8, !tbaa !11
  %29 = icmp eq i64 %27, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %17
  %31 = load ptr, ptr @cell, align 8, !tbaa !5
  %32 = load double, ptr %6, align 8, !tbaa !9
  %33 = call i64 @ord(double noundef %32)
  %34 = getelementptr inbounds double, ptr %31, i64 %33
  br label %36

35:                                               ; preds = %17
  br label %36

36:                                               ; preds = %35, %30
  %37 = phi ptr [ %34, %30 ], [ %5, %35 ]
  store double %25, ptr %37, align 8, !tbaa !9
  store double %25, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %38

38:                                               ; preds = %36
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = call double @cdr(double noundef %40)
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  store double %41, ptr %42, align 8, !tbaa !9
  br label %11, !llvm.loop !13

43:                                               ; preds = %11
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = lshr i64 %45, 48
  %47 = load i64, ptr @NIL, align 8, !tbaa !11
  %48 = icmp ne i64 %46, %47
  br i1 %48, label %49, label %67

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call double @eval(double noundef %51, ptr noundef %52)
  store double %53, ptr %8, align 8, !tbaa !9
  %54 = load double, ptr %8, align 8, !tbaa !9
  %55 = load i64, ptr %6, align 8, !tbaa !11
  %56 = lshr i64 %55, 48
  %57 = load i64, ptr @CONS, align 8, !tbaa !11
  %58 = icmp eq i64 %56, %57
  br i1 %58, label %59, label %64

59:                                               ; preds = %49
  %60 = load ptr, ptr @cell, align 8, !tbaa !5
  %61 = load double, ptr %6, align 8, !tbaa !9
  %62 = call i64 @ord(double noundef %61)
  %63 = getelementptr inbounds double, ptr %60, i64 %62
  br label %65

64:                                               ; preds = %49
  br label %65

65:                                               ; preds = %64, %59
  %66 = phi ptr [ %63, %59 ], [ %5, %64 ]
  store double %54, ptr %66, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %67

67:                                               ; preds = %65, %43
  %68 = load double, ptr %5, align 8, !tbaa !9
  %69 = call double @ret(i32 noundef 2, double noundef %68)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret double %69
}

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

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 }

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

@CONS = external dso_local local_unnamed_addr global i64, align 8
@NIL = external dso_local local_unnamed_addr global i64, align 8
@cell = external dso_local local_unnamed_addr global ptr, align 8
@nil = external dso_local local_unnamed_addr global double, align 8

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

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

; Function Attrs: mustprogress 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 @cons(double noundef, double 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
declare dso_local void @var(i32 noundef, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local double @evlis(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %5 = load double, ptr @nil, align 8, !tbaa !5
  store double %5, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  store double %5, ptr %4, align 8, !tbaa !5
  call void (i32, ...) @var(i32 noundef 2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %6 = load i64, ptr %0, align 8
  %7 = lshr i64 %6, 48
  %8 = load i64, ptr @CONS, align 8, !tbaa !9
  %9 = icmp eq i64 %7, %8
  %10 = bitcast i64 %6 to double
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %25
  %11 = phi double [ %28, %25 ], [ %10, %2 ]
  %12 = call double @car(double noundef %11)
  %13 = call double @eval(double noundef %12, ptr noundef %1)
  %14 = load double, ptr @nil, align 8, !tbaa !5
  %15 = call double @cons(double noundef %13, double noundef %14)
  %16 = load i64, ptr %4, align 8
  %17 = lshr i64 %16, 48
  %18 = load i64, ptr @CONS, align 8, !tbaa !9
  %19 = icmp eq i64 %17, %18
  br i1 %19, label %20, label %25

20:                                               ; preds = %.lr.ph
  %21 = bitcast i64 %16 to double
  %22 = load ptr, ptr @cell, align 8, !tbaa !11
  %23 = call i64 @ord(double noundef %21)
  %24 = getelementptr inbounds double, ptr %22, i64 %23
  br label %25

25:                                               ; preds = %.lr.ph, %20
  %26 = phi ptr [ %24, %20 ], [ %3, %.lr.ph ]
  store double %15, ptr %26, align 8, !tbaa !5
  store double %15, ptr %4, align 8, !tbaa !5
  %27 = load double, ptr %0, align 8, !tbaa !5
  %28 = call double @cdr(double noundef %27)
  store double %28, ptr %0, align 8, !tbaa !5
  %.cast = bitcast double %28 to i64
  %29 = lshr i64 %.cast, 48
  %30 = load i64, ptr @CONS, align 8, !tbaa !9
  %31 = icmp eq i64 %29, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %25, %2
  %32 = phi double [ %10, %2 ], [ %28, %25 ]
  %.lcssa = phi i64 [ %7, %2 ], [ %29, %25 ]
  %33 = load i64, ptr @NIL, align 8, !tbaa !9
  %.not = icmp eq i64 %.lcssa, %33
  br i1 %.not, label %47, label %34

34:                                               ; preds = %._crit_edge
  %35 = call double @eval(double noundef %32, ptr noundef %1)
  %36 = load i64, ptr %4, align 8
  %37 = lshr i64 %36, 48
  %38 = load i64, ptr @CONS, align 8, !tbaa !9
  %39 = icmp eq i64 %37, %38
  br i1 %39, label %40, label %45

40:                                               ; preds = %34
  %41 = bitcast i64 %36 to double
  %42 = load ptr, ptr @cell, align 8, !tbaa !11
  %43 = call i64 @ord(double noundef %41)
  %44 = getelementptr inbounds double, ptr %42, i64 %43
  br label %45

45:                                               ; preds = %34, %40
  %46 = phi ptr [ %44, %40 ], [ %3, %34 ]
  store double %35, ptr %46, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %45, %._crit_edge
  %48 = load double, ptr %3, align 8, !tbaa !5
  %49 = call double @ret(i32 noundef 2, double noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret double %49
}

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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