; LLVM IR from Robert-van-Engelen/tinylisp :: src (tinylisp-opt)

; 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
@.str.21 = 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 uwtable
declare dso_local i32 @not(double noundef) #0

; 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 = call i32 @putchar(i32 noundef 40)
  br label %4

4:                                                ; preds = %22, %1
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = call double @car(double noundef %5)
  call void @print(double noundef %6)
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = call double @cdr(double noundef %7)
  store double %8, ptr %2, align 8, !tbaa !5
  %9 = call i32 @not(double noundef %8)
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %4
  br label %24

12:                                               ; preds = %4
  %13 = load i64, ptr %2, align 8, !tbaa !9
  %14 = lshr i64 %13, 48
  %15 = load i32, ptr @CONS, align 4, !tbaa !11
  %16 = zext i32 %15 to i64
  %17 = icmp ne i64 %14, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %12
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  %20 = load double, ptr %2, align 8, !tbaa !5
  call void @print(double noundef %20)
  br label %24

21:                                               ; preds = %12
  br label %22

22:                                               ; preds = %21
  %23 = call i32 @putchar(i32 noundef 32)
  br label %4

24:                                               ; preds = %18, %11
  %25 = call i32 @putchar(i32 noundef 41)
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #1

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

declare i32 @printf(ptr noundef, ...) #2

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 = { inlinehint 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 = { "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" }

!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 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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
@.str.21 = 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: nounwind uwtable
declare dso_local i32 @not(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @printlist(double noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @putchar(i32 noundef 40)
  %3 = tail call double @car(double noundef %0)
  tail call void @print(double noundef %3)
  %4 = tail call double @cdr(double noundef %0)
  %5 = tail call i32 @not(double noundef %4)
  %.not5 = icmp eq i32 %5, 0
  br i1 %.not5, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %1, %13
  %6 = phi double [ %16, %13 ], [ %4, %1 ]
  %7 = bitcast double %6 to i64
  %8 = lshr i64 %7, 48
  %9 = load i32, ptr @CONS, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %.not3 = icmp eq i64 %8, %10
  br i1 %.not3, label %13, label %11

11:                                               ; preds = %.lr.ph
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  tail call void @print(double noundef %6)
  br label %.loopexit

13:                                               ; preds = %.lr.ph
  %14 = tail call i32 @putchar(i32 noundef 32)
  %15 = tail call double @car(double noundef %6)
  tail call void @print(double noundef %15)
  %16 = tail call double @cdr(double noundef %6)
  %17 = tail call i32 @not(double noundef %16)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %.lr.ph, label %.loopexit

.loopexit:                                        ; preds = %13, %1, %11
  %18 = tail call i32 @putchar(i32 noundef 41)
  ret void
}

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) 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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { inlinehint nofree 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 = { 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" }

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


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