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

@CONS = external dso_local global i32, align 4
@NIL = external dso_local global i32, align 4
@out = external dso_local global ptr, align 8
@.str.66 = external hidden unnamed_addr constant [4 x i8], align 1

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @print(double noundef) #0

declare i32 @putc(i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @printlist(double noundef %0) #0 {
  %2 = alloca double, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr @out, align 8, !tbaa !9
  %4 = call i32 @putc(i32 noundef 40, ptr noundef %3)
  br label %5

5:                                                ; preds = %26, %1
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = call double @car(double noundef %6)
  call void @print(double noundef %7)
  %8 = load double, ptr %2, align 8, !tbaa !5
  %9 = call double @cdr(double noundef %8)
  store double %9, ptr %2, align 8, !tbaa !5
  %10 = load i64, ptr %2, align 8, !tbaa !11
  %11 = lshr i64 %10, 48
  %12 = load i32, ptr @NIL, align 4, !tbaa !13
  %13 = zext i32 %12 to i64
  %14 = icmp eq i64 %11, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %5
  br label %29

16:                                               ; preds = %5
  %17 = load i64, ptr %2, align 8, !tbaa !11
  %18 = lshr i64 %17, 48
  %19 = load i32, ptr @CONS, align 4, !tbaa !13
  %20 = zext i32 %19 to i64
  %21 = icmp ne i64 %18, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %16
  %23 = load ptr, ptr @out, align 8, !tbaa !9
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.66) #3
  %25 = load double, ptr %2, align 8, !tbaa !5
  call void @print(double noundef %25)
  br label %29

26:                                               ; preds = %16
  %27 = load ptr, ptr @out, align 8, !tbaa !9
  %28 = call i32 @putc(i32 noundef 32, ptr noundef %27)
  br label %5

29:                                               ; preds = %22, %15
  %30 = load ptr, ptr @out, align 8, !tbaa !9
  %31 = call i32 @putc(i32 noundef 41, ptr noundef %30)
  ret void
}

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 = { 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 = { "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 = !{!"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"

@CONS = external dso_local local_unnamed_addr global i32, align 4
@NIL = external dso_local local_unnamed_addr global i32, align 4
@out = external dso_local local_unnamed_addr global ptr, align 8
@.str.66 = external hidden unnamed_addr constant [4 x i8], align 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @print(double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @printlist(double noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @out, align 8, !tbaa !5
  %3 = tail call i32 @putc(i32 noundef 40, ptr noundef %2)
  %4 = tail call double @car(double noundef %0)
  tail call void @print(double noundef %4)
  %5 = tail call double @cdr(double noundef %0)
  %6 = bitcast double %5 to i64
  %7 = lshr i64 %6, 48
  %8 = load i32, ptr @NIL, align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = icmp eq i64 %7, %9
  br i1 %10, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %18
  %11 = phi i64 [ %23, %18 ], [ %7, %1 ]
  %12 = phi double [ %21, %18 ], [ %5, %1 ]
  %13 = load i32, ptr @CONS, align 4, !tbaa !9
  %14 = zext i32 %13 to i64
  %.not = icmp eq i64 %11, %14
  %15 = load ptr, ptr @out, align 8, !tbaa !5
  br i1 %.not, label %18, label %16

16:                                               ; preds = %.lr.ph
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.66) #2
  tail call void @print(double noundef %12)
  br label %.loopexit

18:                                               ; preds = %.lr.ph
  %19 = tail call i32 @putc(i32 noundef 32, ptr noundef %15)
  %20 = tail call double @car(double noundef %12)
  tail call void @print(double noundef %20)
  %21 = tail call double @cdr(double noundef %12)
  %22 = bitcast double %21 to i64
  %23 = lshr i64 %22, 48
  %24 = load i32, ptr @NIL, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = icmp eq i64 %23, %25
  br i1 %26, label %.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %18, %1, %16
  %27 = load ptr, ptr @out, align 8, !tbaa !5
  %28 = tail call i32 @putc(i32 noundef 41, ptr noundef %27)
  ret void
}

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


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