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

@cell = external dso_local global [10240 x float], align 16
@nil = external dso_local global float, align 4
@stderr = external global ptr, align 8
@buf = external dso_local global [256 x i8], align 16
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ord(float noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @push(float noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local float @pop() #1

; Function Attrs: nounwind uwtable
declare dso_local float @cons(float noundef, float noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @scan() #1

; Function Attrs: nounwind uwtable
declare dso_local float @readlisp() #1

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

6:                                                ; preds = %32, %0
  br label %7

7:                                                ; preds = %6
  %8 = call signext i8 @scan()
  %9 = sext i8 %8 to i32
  %10 = icmp eq i32 %9, 41
  br i1 %10, label %11, label %13

11:                                               ; preds = %7
  %12 = call float @pop()
  store float %12, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %43

13:                                               ; preds = %7
  %14 = load i8, ptr @buf, align 16, !tbaa !11
  %15 = sext i8 %14 to i32
  %16 = icmp eq i32 %15, 46
  br i1 %16, label %17, label %32

17:                                               ; preds = %13
  %18 = load i8, ptr getelementptr inbounds ([256 x i8], ptr @buf, i64 0, i64 1), align 1, !tbaa !11
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %32, label %20

20:                                               ; preds = %17
  %21 = call float @readlisp()
  %22 = load ptr, ptr %2, align 8, !tbaa !9
  store float %21, ptr %22, align 4, !tbaa !5
  %23 = call signext i8 @scan()
  %24 = sext i8 %23 to i32
  %25 = icmp ne i32 %24, 41
  br i1 %25, label %26, label %30

26:                                               ; preds = %20
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.16) #3
  %29 = call float @err(i32 noundef 8)
  br label %30

30:                                               ; preds = %26, %20
  %31 = call float @pop()
  store float %31, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %43

32:                                               ; preds = %17, %13
  %33 = call float @parse()
  %34 = load float, ptr @nil, align 4, !tbaa !5
  %35 = call float @cons(float noundef %33, float noundef %34)
  %36 = load ptr, ptr %2, align 8, !tbaa !9
  store float %35, ptr %36, align 4, !tbaa !5
  %37 = load ptr, ptr %2, align 8, !tbaa !9
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = call i32 @ord(float noundef %38)
  %40 = add i32 %39, 1
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %41
  store ptr %42, ptr %2, align 8, !tbaa !9
  br label %6

43:                                               ; preds = %30, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %44 = load float, ptr %1, align 4
  ret float %44
}

; Function Attrs: nounwind uwtable
declare dso_local float @parse() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #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 = !{!"float", !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 = !{!7, !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"

@cell = external dso_local local_unnamed_addr global [10240 x float], align 16
@nil = external dso_local local_unnamed_addr global float, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@buf = external dso_local local_unnamed_addr global [256 x i8], align 16
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local float @pop() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @cons(float noundef, float 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 signext i8 @scan() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @readlisp() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @list() local_unnamed_addr #0 {
  %1 = load float, ptr @nil, align 4, !tbaa !5
  %2 = tail call ptr @push(float noundef %1)
  %3 = tail call signext i8 @scan()
  %4 = icmp eq i8 %3, 41
  br i1 %4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %16
  %.07 = phi ptr [ %23, %16 ], [ %2, %0 ]
  %5 = load i8, ptr @buf, align 16, !tbaa !9
  %6 = icmp ne i8 %5, 46
  %7 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 1), align 1
  %8 = icmp ne i8 %7, 0
  %or.cond = select i1 %6, i1 true, i1 %8
  br i1 %or.cond, label %16, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call float @readlisp()
  store float %10, ptr %.07, align 4, !tbaa !5
  %11 = tail call signext i8 @scan()
  %.not = icmp eq i8 %11, 41
  br i1 %.not, label %._crit_edge, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr @stderr, align 8, !tbaa !10
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.16) #2
  %15 = tail call float @err(i32 noundef 8)
  br label %._crit_edge

16:                                               ; preds = %.lr.ph
  %17 = tail call float @parse()
  %18 = load float, ptr @nil, align 4, !tbaa !5
  %19 = tail call float @cons(float noundef %17, float noundef %18)
  store float %19, ptr %.07, align 4, !tbaa !5
  %20 = tail call i32 @ord(float noundef %19)
  %21 = add i32 %20, 1
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds [10240 x float], ptr @cell, i64 0, i64 %22
  %24 = tail call signext i8 @scan()
  %25 = icmp eq i8 %24, 41
  br i1 %25, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %16, %9, %12, %0
  %26 = tail call float @pop()
  ret float %26
}

; Function Attrs: nounwind uwtable
declare dso_local float @parse() local_unnamed_addr #0

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


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