; 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 float, align 4
@stderr = external global ptr, align 8
@buf = external dso_local global [256 x i8], align 16
@.str.17 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 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 float @err(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local float @string(ptr noundef) #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 float @readlisp() #1

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

; Function Attrs: nounwind uwtable
define dso_local float @parse() #1 {
  %1 = alloca float, align 4
  %2 = alloca float, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = load i8, ptr @buf, align 16, !tbaa !5
  %6 = sext i8 %5 to i32
  %7 = icmp eq i32 %6, 40
  br i1 %7, label %8, label %10

8:                                                ; preds = %0
  %9 = call float @list()
  store float %9, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

10:                                               ; preds = %0
  %11 = load i8, ptr @buf, align 16, !tbaa !5
  %12 = sext i8 %11 to i32
  %13 = icmp eq i32 %12, 39
  br i1 %13, label %14, label %21

14:                                               ; preds = %10
  %15 = call float @readlisp()
  %16 = load float, ptr @nil, align 4, !tbaa !8
  %17 = call float @cons(float noundef %15, float noundef %16)
  store float %17, ptr %2, align 4, !tbaa !8
  %18 = call float @atom(ptr noundef @.str.17)
  %19 = load float, ptr %2, align 4, !tbaa !8
  %20 = call float @cons(float noundef %18, float noundef %19)
  store float %20, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

21:                                               ; preds = %10
  %22 = load i8, ptr @buf, align 16, !tbaa !5
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 34
  br i1 %24, label %25, label %27

25:                                               ; preds = %21
  %26 = call float @string(ptr noundef getelementptr inbounds (i8, ptr @buf, i64 1))
  store float %26, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

27:                                               ; preds = %21
  %28 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef @buf, ptr noundef @.str.18, ptr noundef %2, ptr noundef %3) #3
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %38

30:                                               ; preds = %27
  %31 = load i32, ptr %3, align 4, !tbaa !10
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds [256 x i8], ptr @buf, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %38, label %36

36:                                               ; preds = %30
  %37 = load float, ptr %2, align 4, !tbaa !8
  store float %37, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

38:                                               ; preds = %30, %27
  %39 = load i8, ptr @buf, align 16, !tbaa !5
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %40, 41
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = call float @atom(ptr noundef @buf)
  store float %43, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

44:                                               ; preds = %38
  %45 = load ptr, ptr @stderr, align 8, !tbaa !12
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.19) #3
  %47 = call float @err(i32 noundef 8)
  store float %47, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

48:                                               ; preds = %44, %42, %36, %25, %14, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %49 = load float, ptr %1, align 4
  ret float %49
}

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

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

@nil = external dso_local local_unnamed_addr global float, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@buf = external dso_local global [256 x i8], align 16
@.str.17 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 x i8], align 1

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

; Function Attrs: mustprogress 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 float @err(i32 noundef) local_unnamed_addr #1

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local float @parse() local_unnamed_addr #1 {
  %1 = alloca float, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %3 = load i8, ptr @buf, align 16, !tbaa !5
  switch i8 %3, label %14 [
    i8 40, label %4
    i8 39, label %6
    i8 34, label %12
  ]

4:                                                ; preds = %0
  %5 = tail call float @list()
  br label %32

6:                                                ; preds = %0
  %7 = tail call float @readlisp()
  %8 = load float, ptr @nil, align 4, !tbaa !8
  %9 = tail call float @cons(float noundef %7, float noundef %8)
  %10 = tail call float @atom(ptr noundef nonnull @.str.17)
  %11 = tail call float @cons(float noundef %10, float noundef %9)
  br label %32

12:                                               ; preds = %0
  %13 = tail call float @string(ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 1))
  br label %32

14:                                               ; preds = %0
  %15 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull @buf, ptr noundef nonnull @.str.18, ptr noundef nonnull %1, ptr noundef nonnull %2) #3
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %24

17:                                               ; preds = %14
  %18 = load i32, ptr %2, align 4, !tbaa !10
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [256 x i8], ptr @buf, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not = icmp eq i8 %21, 0
  br i1 %.not, label %22, label %24

22:                                               ; preds = %17
  %23 = load float, ptr %1, align 4, !tbaa !8
  br label %32

24:                                               ; preds = %17, %14
  %25 = load i8, ptr @buf, align 16, !tbaa !5
  %.not2 = icmp eq i8 %25, 41
  br i1 %.not2, label %28, label %26

26:                                               ; preds = %24
  %27 = call float @atom(ptr noundef nonnull @buf)
  br label %32

28:                                               ; preds = %24
  %29 = load ptr, ptr @stderr, align 8, !tbaa !12
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.19) #4
  %31 = call float @err(i32 noundef 8)
  br label %32

32:                                               ; preds = %28, %26, %22, %12, %6, %4
  %.0 = phi float [ %5, %4 ], [ %11, %6 ], [ %13, %12 ], [ %27, %26 ], [ %31, %28 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret float %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_sscanf(ptr nocapture noundef readonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { 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 #3 = { nounwind }
attributes #4 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass