; LLVM IR from Robert-van-Engelen/lisp :: src (lisp-pr)

; 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 i32, align 4
@STRG = external dso_local global i32, align 4
@cell = external dso_local global [10240 x double], align 16
@nil = external dso_local global double, align 8
@tru = external dso_local global double, align 8

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ord(double noundef) #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) #1

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

; Function Attrs: nounwind uwtable
define dso_local double @f_lt(double noundef %0, ptr noundef %1) #1 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load double, ptr %3, align 8, !tbaa !5
  %8 = call double @car(double noundef %7)
  store double %8, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %9 = load double, ptr %3, align 8, !tbaa !5
  %10 = call double @cdr(double noundef %9)
  %11 = call double @car(double noundef %10)
  store double %11, ptr %6, align 8, !tbaa !5
  %12 = load i64, ptr %5, align 8, !tbaa !11
  %13 = lshr i64 %12, 48
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = lshr i64 %14, 48
  %16 = icmp eq i64 %13, %15
  br i1 %16, label %17, label %40

17:                                               ; preds = %2
  %18 = load i64, ptr %5, align 8, !tbaa !11
  %19 = lshr i64 %18, 48
  %20 = load i32, ptr @ATOM, align 4, !tbaa !13
  %21 = load i32, ptr @STRG, align 4, !tbaa !13
  %22 = xor i32 %20, %21
  %23 = xor i32 %22, -1
  %24 = zext i32 %23 to i64
  %25 = and i64 %19, %24
  %26 = load i32, ptr @ATOM, align 4, !tbaa !13
  %27 = zext i32 %26 to i64
  %28 = icmp eq i64 %25, %27
  br i1 %28, label %29, label %40

29:                                               ; preds = %17
  %30 = load double, ptr %5, align 8, !tbaa !5
  %31 = call i32 @ord(double noundef %30)
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr @cell, i64 %32
  %34 = load double, ptr %6, align 8, !tbaa !5
  %35 = call i32 @ord(double noundef %34)
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr @cell, i64 %36
  %38 = call i32 @strcmp(ptr noundef %33, ptr noundef %37) #4
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %56, label %58

40:                                               ; preds = %17, %2
  %41 = load double, ptr %5, align 8, !tbaa !5
  %42 = load double, ptr %5, align 8, !tbaa !5
  %43 = fcmp oeq double %41, %42
  br i1 %43, label %44, label %52

44:                                               ; preds = %40
  %45 = load double, ptr %6, align 8, !tbaa !5
  %46 = load double, ptr %6, align 8, !tbaa !5
  %47 = fcmp oeq double %45, %46
  br i1 %47, label %48, label %52

48:                                               ; preds = %44
  %49 = load double, ptr %5, align 8, !tbaa !5
  %50 = load double, ptr %6, align 8, !tbaa !5
  %51 = fcmp olt double %49, %50
  br i1 %51, label %56, label %58

52:                                               ; preds = %44, %40
  %53 = load i64, ptr %5, align 8, !tbaa !11
  %54 = load i64, ptr %6, align 8, !tbaa !11
  %55 = icmp slt i64 %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %52, %48, %29
  %57 = load double, ptr @tru, align 8, !tbaa !5
  br label %60

58:                                               ; preds = %52, %48, %29
  %59 = load double, ptr @nil, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %58, %56
  %61 = phi double [ %57, %56 ], [ %59, %58 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %61
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"double", !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 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !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 i32, align 4
@STRG = external dso_local local_unnamed_addr global i32, align 4
@cell = external dso_local global [10240 x double], align 16
@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 i32 @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
define dso_local double @f_lt(double noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call double @car(double noundef %0)
  %4 = tail call double @cdr(double noundef %0)
  %5 = tail call double @car(double noundef %4)
  %6 = bitcast double %3 to i64
  %7 = lshr i64 %6, 48
  %8 = bitcast double %5 to i64
  %9 = lshr i64 %8, 48
  %10 = icmp eq i64 %7, %9
  br i1 %10, label %11, label %29

11:                                               ; preds = %2
  %12 = load i32, ptr @ATOM, align 4, !tbaa !5
  %13 = load i32, ptr @STRG, align 4, !tbaa !5
  %14 = xor i32 %12, %13
  %15 = xor i32 %14, -1
  %16 = zext i32 %15 to i64
  %17 = and i64 %7, %16
  %18 = zext i32 %12 to i64
  %19 = icmp eq i64 %17, %18
  br i1 %19, label %20, label %29

20:                                               ; preds = %11
  %21 = tail call i32 @ord(double noundef %3)
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr @cell, i64 %22
  %24 = tail call i32 @ord(double noundef %5)
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr @cell, i64 %25
  %27 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %23, ptr noundef nonnull dereferenceable(1) %26) #2
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %35, label %34

29:                                               ; preds = %11, %2
  %or.cond = fcmp ord double %3, %5
  br i1 %or.cond, label %30, label %32

30:                                               ; preds = %29
  %31 = fcmp olt double %3, %5
  br i1 %31, label %35, label %34

32:                                               ; preds = %29
  %33 = icmp slt i64 %6, %8
  br i1 %33, label %35, label %34

34:                                               ; preds = %32, %30, %20
  br label %35

35:                                               ; preds = %20, %30, %32, %34
  %.in = phi ptr [ @nil, %34 ], [ @tru, %32 ], [ @tru, %30 ], [ @tru, %20 ]
  %36 = load double, ptr %.in, align 8, !tbaa !9
  ret double %36
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


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