; 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
@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 @car(double noundef) #0

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

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

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

11:                                               ; preds = %23, %2
  %12 = load double, ptr %5, align 8, !tbaa !9
  %13 = call i32 @more(double noundef %12)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %26

15:                                               ; preds = %11
  %16 = load double, ptr %5, align 8, !tbaa !9
  %17 = call double @car(double noundef %16)
  %18 = call double @car(double noundef %17)
  %19 = load double, ptr @nil, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call double @pair(double noundef %18, double noundef %19, ptr noundef %20)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  store double %21, ptr %22, align 8, !tbaa !9
  br label %23

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

26:                                               ; preds = %11
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !9
  store double %28, ptr %5, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %49, %26
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = call i32 @more(double noundef %31)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %56

34:                                               ; preds = %29
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = call double @car(double noundef %36)
  %38 = call double @cdr(double noundef %37)
  store double %38, ptr %6, align 8, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call double @f_begin(ptr noundef %6, ptr noundef %39)
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call double @eval(double noundef %40, ptr noundef %41)
  store double %42, ptr %6, align 8, !tbaa !9
  %43 = load double, ptr %6, align 8, !tbaa !9
  %44 = load ptr, ptr @cell, align 8, !tbaa !5
  %45 = load double, ptr %5, align 8, !tbaa !9
  %46 = call double @car(double noundef %45)
  %47 = call i64 @ord(double noundef %46)
  %48 = getelementptr inbounds double, ptr %44, i64 %47
  store double %43, ptr %48, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %34
  %50 = load double, ptr %5, align 8, !tbaa !9
  %51 = call double @cdr(double noundef %50)
  store double %51, ptr %5, align 8, !tbaa !9
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = call double @cdr(double noundef %53)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  store double %54, ptr %55, align 8, !tbaa !9
  br label %29, !llvm.loop !13

56:                                               ; preds = %29
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load i64, ptr %57, align 8, !tbaa !14
  %59 = lshr i64 %58, 48
  %60 = load i64, ptr @NIL, align 8, !tbaa !14
  %61 = icmp eq i64 %59, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %56
  %63 = load double, ptr @nil, align 8, !tbaa !9
  br label %68

64:                                               ; preds = %56
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = call double @car(double noundef %66)
  br label %68

68:                                               ; preds = %64, %62
  %69 = phi double [ %63, %62 ], [ %67, %64 ]
  %70 = call double @ret(i32 noundef 2, double noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret double %70
}

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

@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 @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 double @pair(double noundef, double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @more(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
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_letrec(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 double, ptr %0, align 8, !tbaa !5
  store double %6, ptr %3, align 8, !tbaa !5
  %7 = call i32 @more(double noundef %6)
  %.not13 = icmp eq i32 %7, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = call double @car(double noundef %8)
  %10 = call double @car(double noundef %9)
  %11 = load double, ptr @nil, align 8, !tbaa !5
  %12 = call double @pair(double noundef %10, double noundef %11, ptr noundef %1)
  store double %12, ptr %1, align 8, !tbaa !5
  %13 = load double, ptr %3, align 8, !tbaa !5
  %14 = call double @cdr(double noundef %13)
  store double %14, ptr %3, align 8, !tbaa !5
  %15 = call i32 @more(double noundef %14)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %2
  %16 = load double, ptr %1, align 8, !tbaa !5
  store double %16, ptr %3, align 8, !tbaa !5
  %17 = load double, ptr %0, align 8, !tbaa !5
  %18 = call i32 @more(double noundef %17)
  %.not1214 = icmp eq i32 %18, 0
  br i1 %.not1214, label %._crit_edge17, label %.lr.ph16

.lr.ph16:                                         ; preds = %._crit_edge, %.lr.ph16
  %19 = load double, ptr %0, align 8, !tbaa !5
  %20 = call double @car(double noundef %19)
  %21 = call double @cdr(double noundef %20)
  store double %21, ptr %4, align 8, !tbaa !5
  %22 = call double @f_begin(ptr noundef nonnull %4, ptr noundef nonnull %1)
  %23 = call double @eval(double noundef %22, ptr noundef nonnull %1)
  store double %23, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr @cell, align 8, !tbaa !11
  %25 = load double, ptr %3, align 8, !tbaa !5
  %26 = call double @car(double noundef %25)
  %27 = call i64 @ord(double noundef %26)
  %28 = getelementptr inbounds double, ptr %24, i64 %27
  store double %23, ptr %28, align 8, !tbaa !5
  %29 = load double, ptr %3, align 8, !tbaa !5
  %30 = call double @cdr(double noundef %29)
  store double %30, ptr %3, align 8, !tbaa !5
  %31 = load double, ptr %0, align 8, !tbaa !5
  %32 = call double @cdr(double noundef %31)
  store double %32, ptr %0, align 8, !tbaa !5
  %33 = call i32 @more(double noundef %32)
  %.not12 = icmp eq i32 %33, 0
  br i1 %.not12, label %._crit_edge17, label %.lr.ph16, !llvm.loop !13

._crit_edge17:                                    ; preds = %.lr.ph16, %._crit_edge
  %34 = load i64, ptr %0, align 8
  %35 = lshr i64 %34, 48
  %36 = load i64, ptr @NIL, align 8, !tbaa !14
  %37 = icmp eq i64 %35, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %._crit_edge17
  %39 = load double, ptr @nil, align 8, !tbaa !5
  br label %43

40:                                               ; preds = %._crit_edge17
  %41 = bitcast i64 %34 to double
  %42 = call double @car(double noundef %41)
  br label %43

43:                                               ; preds = %40, %38
  %44 = phi double [ %39, %38 ], [ %42, %40 ]
  %45 = call double @ret(i32 noundef 2, double noundef %44)
  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 %45
}

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


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