; 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
@hp = 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 @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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @copy(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local float @atom(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 32772, ptr %3, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %17, %1
  %5 = load i32, ptr %3, align 4, !tbaa !9
  %6 = load i32, ptr @hp, align 4, !tbaa !9
  %7 = icmp ult i32 %5, %6
  br i1 %7, label %8, label %15

8:                                                ; preds = %4
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds i8, ptr @cell, i64 %10
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = call i32 @strcmp(ptr noundef %11, ptr noundef %12) #4
  %14 = icmp ne i32 %13, 0
  br label %15

15:                                               ; preds = %8, %4
  %16 = phi i1 [ false, %4 ], [ %14, %8 ]
  br i1 %16, label %17, label %28

17:                                               ; preds = %15
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr @cell, i64 %19
  %21 = call i64 @strlen(ptr noundef %20) #4
  %22 = add i64 %21, 4
  %23 = add i64 %22, 1
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = add i64 %25, %23
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %3, align 4, !tbaa !9
  br label %4, !llvm.loop !11

28:                                               ; preds = %15
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = load i32, ptr @hp, align 4, !tbaa !9
  %31 = icmp uge i32 %29, %30
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = call i32 @copy(ptr noundef %33)
  store i32 %34, ptr %3, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %32, %28
  %36 = load i32, ptr @ATOM, align 4, !tbaa !9
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = call float @box(i32 noundef %36, i32 noundef %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %38
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

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

@ATOM = external dso_local local_unnamed_addr global i32, align 4
@hp = 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 @box(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local float @atom(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @hp, align 4, !tbaa !5
  %3 = icmp ugt i32 %2, 32772
  br i1 %3, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %1, %7
  %.09 = phi i32 [ %11, %7 ], [ 32772, %1 ]
  %4 = zext i32 %.09 to i64
  %5 = getelementptr inbounds i8, ptr @cell, i64 %4
  %6 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %0) #2
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.critedge.thread, label %7

7:                                                ; preds = %.lr.ph
  %8 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %5) #2
  %9 = trunc i64 %8 to i32
  %10 = add i32 %.09, 5
  %11 = add i32 %10, %9
  %12 = icmp ult i32 %11, %2
  br i1 %12, label %.lr.ph, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %7, %1
  %13 = tail call i32 @copy(ptr noundef %0)
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %.lr.ph, %.critedge
  %.1 = phi i32 [ %13, %.critedge ], [ %.09, %.lr.ph ]
  %14 = load i32, ptr @ATOM, align 4, !tbaa !5
  %15 = tail call float @box(i32 noundef %14, i32 noundef %.1)
  ret float %15
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

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


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