; 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
@STRG = external dso_local global i64, align 8
@cell = external dso_local global ptr, align 8
@nil = external dso_local global double, align 8
@tru = 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 willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

; 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 @evlis(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local double @f_lt(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 ptr, ptr %4, align 8, !tbaa !5
  %10 = call double @evlis(ptr noundef %8, ptr noundef %9)
  store double %10, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = load double, ptr %5, align 8, !tbaa !9
  %12 = call double @car(double noundef %11)
  store double %12, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load double, ptr %5, align 8, !tbaa !9
  %14 = call double @cdr(double noundef %13)
  %15 = call double @car(double noundef %14)
  store double %15, ptr %7, align 8, !tbaa !9
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = lshr i64 %16, 48
  %18 = load i64, ptr %7, align 8, !tbaa !11
  %19 = lshr i64 %18, 48
  %20 = icmp eq i64 %17, %19
  br i1 %20, label %21, label %42

21:                                               ; preds = %2
  %22 = load i64, ptr %6, align 8, !tbaa !11
  %23 = lshr i64 %22, 48
  %24 = load i64, ptr @ATOM, align 8, !tbaa !11
  %25 = load i64, ptr @STRG, align 8, !tbaa !11
  %26 = xor i64 %24, %25
  %27 = xor i64 %26, -1
  %28 = and i64 %23, %27
  %29 = load i64, ptr @ATOM, align 8, !tbaa !11
  %30 = icmp eq i64 %28, %29
  br i1 %30, label %31, label %42

31:                                               ; preds = %21
  %32 = load ptr, ptr @cell, align 8, !tbaa !5
  %33 = load double, ptr %6, align 8, !tbaa !9
  %34 = call i64 @ord(double noundef %33)
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  %36 = load ptr, ptr @cell, align 8, !tbaa !5
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = call i64 @ord(double noundef %37)
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = call i32 @strcmp(ptr noundef %35, ptr noundef %39) #4
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %60, label %62

42:                                               ; preds = %21, %2
  %43 = load double, ptr %6, align 8, !tbaa !9
  %44 = load double, ptr %6, align 8, !tbaa !9
  %45 = fcmp oeq double %43, %44
  br i1 %45, label %46, label %54

46:                                               ; preds = %42
  %47 = load double, ptr %7, align 8, !tbaa !9
  %48 = load double, ptr %7, align 8, !tbaa !9
  %49 = fcmp oeq double %47, %48
  br i1 %49, label %50, label %54

50:                                               ; preds = %46
  %51 = load double, ptr %6, align 8, !tbaa !9
  %52 = load double, ptr %7, align 8, !tbaa !9
  %53 = fcmp olt double %51, %52
  br i1 %53, label %60, label %62

54:                                               ; preds = %46, %42
  %55 = load i64, ptr %6, align 8, !tbaa !11
  %56 = lshr i64 %55, 48
  %57 = load i64, ptr %7, align 8, !tbaa !11
  %58 = lshr i64 %57, 48
  %59 = icmp ult i64 %56, %58
  br i1 %59, label %60, label %62

60:                                               ; preds = %54, %50, %31
  %61 = load double, ptr @tru, align 8, !tbaa !9
  br label %64

62:                                               ; preds = %54, %50, %31
  %63 = load double, ptr @nil, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %62, %60
  %65 = phi double [ %61, %60 ], [ %63, %62 ]
  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 %65
}

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 willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

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


; 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
@STRG = 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
@tru = 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 nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #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 @evlis(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @f_lt(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call double @evlis(ptr noundef %0, ptr noundef %1)
  %4 = tail call double @car(double noundef %3)
  %5 = tail call double @cdr(double noundef %3)
  %6 = tail call double @car(double noundef %5)
  %7 = bitcast double %4 to i64
  %8 = lshr i64 %7, 48
  %9 = bitcast double %6 to i64
  %10 = lshr i64 %9, 48
  %11 = icmp eq i64 %8, %10
  br i1 %11, label %12, label %28

12:                                               ; preds = %2
  %13 = load i64, ptr @ATOM, align 8, !tbaa !5
  %14 = load i64, ptr @STRG, align 8, !tbaa !5
  %15 = xor i64 %13, %14
  %16 = xor i64 %15, -1
  %17 = and i64 %8, %16
  %18 = icmp eq i64 %17, %13
  br i1 %18, label %19, label %28

19:                                               ; preds = %12
  %20 = load ptr, ptr @cell, align 8, !tbaa !9
  %21 = tail call i64 @ord(double noundef %4)
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = load ptr, ptr @cell, align 8, !tbaa !9
  %24 = tail call i64 @ord(double noundef %6)
  %25 = getelementptr inbounds i8, ptr %23, i64 %24
  %26 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %22, ptr noundef nonnull dereferenceable(1) %25) #2
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %34, label %33

28:                                               ; preds = %12, %2
  %or.cond = fcmp ord double %4, %6
  br i1 %or.cond, label %29, label %31

29:                                               ; preds = %28
  %30 = fcmp olt double %4, %6
  br i1 %30, label %34, label %33

31:                                               ; preds = %28
  %32 = icmp ult i64 %8, %10
  br i1 %32, label %34, label %33

33:                                               ; preds = %31, %29, %19
  br label %34

34:                                               ; preds = %19, %29, %31, %33
  %.in = phi ptr [ @nil, %33 ], [ @tru, %31 ], [ @tru, %29 ], [ @tru, %19 ]
  %35 = load double, ptr %.in, align 8, !tbaa !11
  ret double %35
}

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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass