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

@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: nounwind uwtable
declare dso_local i64 @equ(double noundef, 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_eq(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 @STRG, align 8, !tbaa !11
  %19 = icmp eq i64 %17, %18
  br i1 %19, label %20, label %40

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

25:                                               ; preds = %20
  %26 = load ptr, ptr @cell, align 8, !tbaa !5
  %27 = load double, ptr %6, align 8, !tbaa !9
  %28 = call i64 @ord(double noundef %27)
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load ptr, ptr @cell, align 8, !tbaa !5
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = call i64 @ord(double noundef %31)
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = call i32 @strcmp(ptr noundef %29, ptr noundef %33) #4
  %35 = icmp ne i32 %34, 0
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = icmp ne i64 %38, 0
  br i1 %39, label %45, label %47

40:                                               ; preds = %20, %2
  %41 = load double, ptr %6, align 8, !tbaa !9
  %42 = load double, ptr %7, align 8, !tbaa !9
  %43 = call i64 @equ(double noundef %41, double noundef %42)
  %44 = icmp ne i64 %43, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %40, %25
  %46 = load double, ptr @tru, align 8, !tbaa !9
  br label %49

47:                                               ; preds = %40, %25
  %48 = load double, ptr @nil, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %47, %45
  %50 = phi double [ %46, %45 ], [ %48, %47 ]
  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 %50
}

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"

@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: nounwind uwtable
declare dso_local i64 @equ(double noundef, 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_eq(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 = load i64, ptr @STRG, align 8, !tbaa !5
  %10 = icmp eq i64 %8, %9
  br i1 %10, label %11, label %23

11:                                               ; preds = %2
  %12 = bitcast double %6 to i64
  %13 = lshr i64 %12, 48
  %14 = icmp eq i64 %13, %8
  br i1 %14, label %15, label %23

15:                                               ; preds = %11
  %16 = load ptr, ptr @cell, align 8, !tbaa !9
  %17 = tail call i64 @ord(double noundef %4)
  %18 = getelementptr inbounds i8, ptr %16, i64 %17
  %19 = load ptr, ptr @cell, align 8, !tbaa !9
  %20 = tail call i64 @ord(double noundef %6)
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %21) #2
  %.not9 = icmp eq i32 %22, 0
  br i1 %.not9, label %26, label %25

23:                                               ; preds = %11, %2
  %24 = tail call i64 @equ(double noundef %4, double noundef %6)
  %.not = icmp eq i64 %24, 0
  br i1 %.not, label %25, label %26

25:                                               ; preds = %23, %15
  br label %26

26:                                               ; preds = %15, %23, %25
  %.in = phi ptr [ @nil, %25 ], [ @tru, %23 ], [ @tru, %15 ]
  %27 = load double, ptr %.in, align 8, !tbaa !11
  ret double %27
}

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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass