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

; 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
@CONS = external dso_local global i32, align 4
@cell = external dso_local global [10240 x float], align 16
@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1

; 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(float noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @equ(float noundef, float noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local float @err(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local float @car(float noundef) #1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local float @eval(float noundef, float noundef) #1

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

18:                                               ; preds = %33, %2
  %19 = load i32, ptr %7, align 4, !tbaa !11
  %20 = lshr i32 %19, 20
  %21 = load i32, ptr @CONS, align 4, !tbaa !11
  %22 = icmp eq i32 %20, %21
  br i1 %22, label %23, label %31

23:                                               ; preds = %18
  %24 = load float, ptr %6, align 4, !tbaa !5
  %25 = load float, ptr %7, align 4, !tbaa !5
  %26 = call float @car(float noundef %25)
  %27 = call float @car(float noundef %26)
  %28 = call i32 @equ(float noundef %24, float noundef %27)
  %29 = icmp ne i32 %28, 0
  %30 = xor i1 %29, true
  br label %31

31:                                               ; preds = %23, %18
  %32 = phi i1 [ false, %18 ], [ %30, %23 ]
  br i1 %32, label %33, label %36

33:                                               ; preds = %31
  %34 = load float, ptr %7, align 4, !tbaa !5
  %35 = call float @cdr(float noundef %34)
  store float %35, ptr %7, align 4, !tbaa !5
  br label %18, !llvm.loop !13

36:                                               ; preds = %31
  %37 = load i32, ptr %7, align 4, !tbaa !11
  %38 = lshr i32 %37, 20
  %39 = load i32, ptr @CONS, align 4, !tbaa !11
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %49

41:                                               ; preds = %36
  %42 = load float, ptr %5, align 4, !tbaa !5
  %43 = load float, ptr %7, align 4, !tbaa !5
  %44 = call float @car(float noundef %43)
  %45 = call i32 @ord(float noundef %44)
  %46 = add i32 %45, 1
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %47
  store float %42, ptr %48, align 4, !tbaa !5
  br label %66

49:                                               ; preds = %36
  %50 = load i32, ptr %6, align 4, !tbaa !11
  %51 = lshr i32 %50, 20
  %52 = load i32, ptr @ATOM, align 4, !tbaa !11
  %53 = icmp eq i32 %51, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %49
  %55 = load ptr, ptr @stderr, align 8, !tbaa !9
  %56 = load float, ptr %6, align 4, !tbaa !5
  %57 = call i32 @ord(float noundef %56)
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr @cell, i64 %58
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.9, ptr noundef %59) #3
  %61 = call float @err(i32 noundef 3)
  br label %64

62:                                               ; preds = %49
  %63 = call float @err(i32 noundef 3)
  br label %64

64:                                               ; preds = %62, %54
  %65 = phi float [ %61, %54 ], [ %63, %62 ]
  br label %66

66:                                               ; preds = %64, %41
  %67 = phi float [ %42, %41 ], [ %65, %64 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %67
}

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

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


; 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
@CONS = external dso_local local_unnamed_addr global i32, align 4
@cell = external dso_local global [10240 x float], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ord(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @equ(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @err(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @car(float noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local float @eval(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @f_setq(float noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call float @cdr(float noundef %0)
  %4 = tail call float @car(float noundef %3)
  %5 = load float, ptr %1, align 4, !tbaa !5
  %6 = tail call float @eval(float noundef %4, float noundef %5)
  %7 = tail call float @car(float noundef %0)
  %8 = load float, ptr %1, align 4, !tbaa !5
  %9 = bitcast float %8 to i32
  %10 = lshr i32 %9, 20
  %11 = load i32, ptr @CONS, align 4, !tbaa !9
  %12 = icmp eq i32 %10, %11
  br i1 %12, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %2
  %13 = tail call float @car(float noundef %8)
  %14 = tail call float @car(float noundef %13)
  %15 = tail call i32 @equ(float noundef %7, float noundef %14)
  %.not30 = icmp eq i32 %15, 0
  br i1 %.not30, label %.lr.ph32, label %.lr.ph..critedge.loopexit_crit_edge

.lr.ph:                                           ; preds = %.lr.ph32
  %16 = tail call float @car(float noundef %19)
  %17 = tail call float @car(float noundef %16)
  %18 = tail call i32 @equ(float noundef %7, float noundef %17)
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %.lr.ph32, label %.lr.ph..critedge.loopexit_crit_edge, !llvm.loop !11

.lr.ph..critedge.loopexit_crit_edge:              ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa25 = phi i32 [ %10, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %.012.lcssa = phi float [ %8, %.lr.ph.preheader ], [ %19, %.lr.ph ]
  %.pre.pre = load i32, ptr @CONS, align 4, !tbaa !9
  br label %.critedge

.lr.ph32:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.01231 = phi float [ %19, %.lr.ph ], [ %8, %.lr.ph.preheader ]
  %19 = tail call float @cdr(float noundef %.01231)
  %20 = bitcast float %19 to i32
  %21 = lshr i32 %20, 20
  %22 = load i32, ptr @CONS, align 4, !tbaa !9
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %.lr.ph, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %.lr.ph32, %.lr.ph..critedge.loopexit_crit_edge, %2
  %24 = phi i32 [ %11, %2 ], [ %.pre.pre, %.lr.ph..critedge.loopexit_crit_edge ], [ %22, %.lr.ph32 ]
  %.0.lcssa = phi float [ %8, %2 ], [ %.012.lcssa, %.lr.ph..critedge.loopexit_crit_edge ], [ %19, %.lr.ph32 ]
  %.lcssa = phi i32 [ %10, %2 ], [ %.lcssa25, %.lr.ph..critedge.loopexit_crit_edge ], [ %21, %.lr.ph32 ]
  %25 = icmp eq i32 %.lcssa, %24
  br i1 %25, label %26, label %32

26:                                               ; preds = %.critedge
  %27 = tail call float @car(float noundef %.0.lcssa)
  %28 = tail call i32 @ord(float noundef %27)
  %29 = add i32 %28, 1
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %30
  store float %6, ptr %31, align 4, !tbaa !5
  br label %46

32:                                               ; preds = %.critedge
  %33 = bitcast float %7 to i32
  %34 = lshr i32 %33, 20
  %35 = load i32, ptr @ATOM, align 4, !tbaa !9
  %36 = icmp eq i32 %34, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %32
  %38 = load ptr, ptr @stderr, align 8, !tbaa !13
  %39 = tail call i32 @ord(float noundef %7)
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr @cell, i64 %40
  %42 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str.9, ptr noundef nonnull %41) #2
  %43 = tail call float @err(i32 noundef 3)
  br label %46

44:                                               ; preds = %32
  %45 = tail call float @err(i32 noundef 3)
  br label %46

46:                                               ; preds = %37, %44, %26
  %47 = phi float [ %6, %26 ], [ %43, %37 ], [ %45, %44 ]
  ret float %47
}

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 = { nofree nounwind "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 = { cold 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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