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

@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 uwtable
declare dso_local i32 @equ(double noundef, 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_eq(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 i32, ptr @STRG, align 4, !tbaa !13
  %15 = zext i32 %14 to i64
  %16 = icmp eq i64 %13, %15
  br i1 %16, label %17, label %35

17:                                               ; preds = %2
  %18 = load i64, ptr %6, align 8, !tbaa !11
  %19 = lshr i64 %18, 48
  %20 = load i32, ptr @STRG, align 4, !tbaa !13
  %21 = zext i32 %20 to i64
  %22 = icmp eq i64 %19, %21
  br i1 %22, label %23, label %35

23:                                               ; preds = %17
  %24 = load double, ptr %5, align 8, !tbaa !5
  %25 = call i32 @ord(double noundef %24)
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr @cell, i64 %26
  %28 = load double, ptr %6, align 8, !tbaa !5
  %29 = call i32 @ord(double noundef %28)
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr @cell, i64 %30
  %32 = call i32 @strcmp(ptr noundef %27, ptr noundef %31) #4
  %33 = icmp ne i32 %32, 0
  %34 = xor i1 %33, true
  br i1 %34, label %40, label %42

35:                                               ; preds = %17, %2
  %36 = load double, ptr %5, align 8, !tbaa !5
  %37 = load double, ptr %6, align 8, !tbaa !5
  %38 = call i32 @equ(double noundef %36, double noundef %37)
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %35, %23
  %41 = load double, ptr @tru, align 8, !tbaa !5
  br label %44

42:                                               ; preds = %35, %23
  %43 = load double, ptr @nil, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %42, %40
  %45 = phi double [ %41, %40 ], [ %43, %42 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %45
}

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"

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

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

15:                                               ; preds = %11
  %16 = tail call i32 @ord(double noundef %3)
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds i8, ptr @cell, i64 %17
  %19 = tail call i32 @ord(double noundef %5)
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr @cell, i64 %20
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %21) #2
  %.not7 = icmp eq i32 %22, 0
  br i1 %.not7, label %26, label %25

23:                                               ; preds = %11, %2
  %24 = tail call i32 @equ(double noundef %3, double noundef %5)
  %.not = icmp eq i32 %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 !9
  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 = !{!"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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass