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

@hp = external dso_local global i32, align 4
@sp = external dso_local global i32, align 4
@cell = external dso_local global [10240 x float], align 16

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @gc() #0

; Function Attrs: nounwind uwtable
define dso_local ptr @push(float noundef %0) #0 {
  %2 = alloca float, align 4
  store float %0, ptr %2, align 4, !tbaa !5
  %3 = load float, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr @sp, align 4, !tbaa !9
  %5 = add i32 %4, -1
  store i32 %5, ptr @sp, align 4, !tbaa !9
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %6
  store float %3, ptr %7, align 4, !tbaa !5
  %8 = load i32, ptr @hp, align 4, !tbaa !9
  %9 = load i32, ptr @sp, align 4, !tbaa !9
  %10 = sub i32 %9, 1
  %11 = shl i32 %10, 3
  %12 = icmp ugt i32 %8, %11
  br i1 %12, label %13, label %23

13:                                               ; preds = %1
  %14 = call i32 @gc()
  %15 = load i32, ptr @hp, align 4, !tbaa !9
  %16 = load i32, ptr @sp, align 4, !tbaa !9
  %17 = sub i32 %16, 1
  %18 = shl i32 %17, 3
  %19 = icmp ugt i32 %15, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %13
  %21 = call float @err(i32 noundef 6)
  br label %22

22:                                               ; preds = %20, %13
  br label %23

23:                                               ; preds = %22, %1
  %24 = load i32, ptr @sp, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %25
  ret ptr %26
}

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

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


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

@hp = external dso_local local_unnamed_addr global i32, align 4
@sp = external dso_local local_unnamed_addr global i32, align 4
@cell = external dso_local global [10240 x float], align 16

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @gc() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local nonnull ptr @push(float noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @sp, align 4, !tbaa !5
  %3 = add i32 %2, -1
  store i32 %3, ptr @sp, align 4, !tbaa !5
  %4 = zext i32 %3 to i64
  %5 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %4
  store float %0, ptr %5, align 4, !tbaa !9
  %6 = load i32, ptr @hp, align 4, !tbaa !5
  %7 = shl i32 %2, 3
  %8 = add i32 %7, -16
  %9 = icmp ugt i32 %6, %8
  br i1 %9, label %10, label %19

10:                                               ; preds = %1
  %11 = tail call i32 @gc()
  %12 = load i32, ptr @hp, align 4, !tbaa !5
  %13 = load i32, ptr @sp, align 4, !tbaa !5
  %14 = shl i32 %13, 3
  %15 = add i32 %14, -8
  %16 = icmp ugt i32 %12, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %10
  %18 = tail call float @err(i32 noundef 6)
  %.pre = load i32, ptr @sp, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %10, %17, %1
  %20 = phi i32 [ %13, %10 ], [ %.pre, %17 ], [ %3, %1 ]
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %21
  ret ptr %22
}

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

!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 = !{!"float", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass