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

@NIL = external dso_local global i32, align 4
@fp = external dso_local global i32, align 4
@used = external dso_local global [128 x i32], align 16
@cell = external dso_local global [10240 x float], align 16

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @sweep() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr @fp, align 4, !tbaa !5
  store i32 4096, ptr %1, align 4, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %30, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = add i32 %4, -1
  store i32 %5, ptr %1, align 4, !tbaa !5
  %6 = icmp ne i32 %4, 0
  br i1 %6, label %7, label %31

7:                                                ; preds = %3
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = udiv i32 %8, 32
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds [128 x i32], ptr @used, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = urem i32 %13, 32
  %15 = shl i32 1, %14
  %16 = and i32 %12, %15
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %30, label %18

18:                                               ; preds = %7
  %19 = load i32, ptr @NIL, align 4, !tbaa !5
  %20 = load i32, ptr @fp, align 4, !tbaa !5
  %21 = call float @box(i32 noundef %19, i32 noundef %20)
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = mul i32 2, %22
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %24
  store float %21, ptr %25, align 4, !tbaa !9
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = mul i32 2, %26
  store i32 %27, ptr @fp, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add i32 %28, 2
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %18, %7
  br label %3, !llvm.loop !11

31:                                               ; preds = %3
  %32 = load i32, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret i32 %32
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@NIL = external dso_local local_unnamed_addr global i32, align 4
@fp = external dso_local local_unnamed_addr global i32, align 4
@used = external dso_local local_unnamed_addr global [128 x i32], align 16
@cell = external dso_local local_unnamed_addr global [10240 x float], align 16

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sweep() local_unnamed_addr #0 {
  store i32 0, ptr @fp, align 4, !tbaa !5
  br label %1

1:                                                ; preds = %0, %18
  %2 = phi i32 [ 0, %0 ], [ %19, %18 ]
  %indvars.iv = phi i64 [ 4095, %0 ], [ %indvars.iv.next, %18 ]
  %.09 = phi i32 [ 0, %0 ], [ %.1, %18 ]
  %3 = trunc nuw nsw i64 %indvars.iv to i32
  %4 = lshr i64 %indvars.iv, 5
  %5 = and i64 %4, 134217727
  %6 = getelementptr inbounds [128 x i32], ptr @used, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = and i32 %3, 31
  %9 = shl nuw i32 1, %8
  %10 = and i32 %7, %9
  %.not8 = icmp eq i32 %10, 0
  br i1 %.not8, label %11, label %18

11:                                               ; preds = %1
  %12 = load i32, ptr @NIL, align 4, !tbaa !5
  %13 = tail call float @box(i32 noundef %12, i32 noundef %2)
  %14 = shl i64 %indvars.iv, 1
  %15 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %14
  store float %13, ptr %15, align 8, !tbaa !9
  %16 = trunc nuw nsw i64 %14 to i32
  store i32 %16, ptr @fp, align 4, !tbaa !5
  %17 = add i32 %.09, 2
  br label %18

18:                                               ; preds = %11, %1
  %19 = phi i32 [ %2, %1 ], [ %16, %11 ]
  %.1 = phi i32 [ %.09, %1 ], [ %17, %11 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not = icmp eq i64 %indvars.iv, 0
  br i1 %.not, label %20, label %1, !llvm.loop !11

20:                                               ; preds = %18
  ret i32 %.1
}

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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,TailCallElimPass