; LLVM IR from Robert-van-Engelen/lisp-cheney :: src (lisp-cheney)

; 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 double, align 8
@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 [6 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @err(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
declare dso_local double @atom(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @string(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @cons(double noundef, double noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @var(i32 noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @list() #0

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

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

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

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %16 = call double @readlisp()
  %17 = load double, ptr @nil, align 8, !tbaa !8
  %18 = call double @cons(double noundef %16, double noundef %17)
  store double %18, ptr %5, align 8, !tbaa !8
  call void (i32, ...) @var(i32 noundef 1, ptr noundef %5)
  %19 = call double @atom(ptr noundef @.str.17)
  store double %19, ptr %2, align 8, !tbaa !8
  %20 = load double, ptr %2, align 8, !tbaa !8
  %21 = load double, ptr %5, align 8, !tbaa !8
  %22 = call double @cons(double noundef %20, double noundef %21)
  %23 = call double @ret(i32 noundef 1, double noundef %22)
  store double %23, ptr %1, align 8
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %51

24:                                               ; preds = %11
  %25 = load i8, ptr @buf, align 16, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = icmp eq i32 %26, 34
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = call double @string(ptr noundef getelementptr inbounds (i8, ptr @buf, i64 1))
  store double %29, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %51

30:                                               ; preds = %24
  %31 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef @buf, ptr noundef @.str.18, ptr noundef %2, ptr noundef %3) #3
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %33, label %41

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

39:                                               ; preds = %33
  %40 = load double, ptr %2, align 8, !tbaa !8
  store double %40, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %51

41:                                               ; preds = %33, %30
  %42 = load i8, ptr @buf, align 16, !tbaa !5
  %43 = sext i8 %42 to i32
  %44 = icmp ne i32 %43, 41
  br i1 %44, label %45, label %47

45:                                               ; preds = %41
  %46 = call double @atom(ptr noundef @buf)
  store double %46, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %51

47:                                               ; preds = %41
  %48 = load ptr, ptr @stderr, align 8, !tbaa !12
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.19) #3
  %50 = call double @err(i32 noundef 8)
  store double %50, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %51

51:                                               ; preds = %47, %45, %39, %28, %15, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %52 = load double, ptr %1, align 8
  ret double %52
}

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(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 "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 = !{!"double", !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 double, align 8
@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 [6 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

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

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

; 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 void @var(i32 noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @list() local_unnamed_addr #0

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

5:                                                ; preds = %0
  %6 = tail call double @list()
  br label %35

7:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %8 = tail call double @readlisp()
  %9 = load double, ptr @nil, align 8, !tbaa !8
  %10 = tail call double @cons(double noundef %8, double noundef %9)
  store double %10, ptr %3, align 8, !tbaa !8
  call void (i32, ...) @var(i32 noundef 1, ptr noundef nonnull %3)
  %11 = call double @atom(ptr noundef nonnull @.str.17)
  %12 = load double, ptr %3, align 8, !tbaa !8
  %13 = call double @cons(double noundef %11, double noundef %12)
  %14 = call double @ret(i32 noundef 1, double noundef %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %35

15:                                               ; preds = %0
  %16 = tail call double @string(ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 1))
  br label %35

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

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

25:                                               ; preds = %20
  %26 = load double, ptr %1, align 8, !tbaa !8
  br label %35

27:                                               ; preds = %20, %17
  %28 = load i8, ptr @buf, align 16, !tbaa !5
  %.not2 = icmp eq i8 %28, 41
  br i1 %.not2, label %31, label %29

29:                                               ; preds = %27
  %30 = call double @atom(ptr noundef nonnull @buf)
  br label %35

31:                                               ; preds = %27
  %32 = load ptr, ptr @stderr, align 8, !tbaa !12
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.19) #4
  %34 = call double @err(i32 noundef 8)
  br label %35

35:                                               ; preds = %31, %29, %25, %15, %7, %5
  %.0 = phi double [ %6, %5 ], [ %14, %7 ], [ %16, %15 ], [ %30, %29 ], [ %34, %31 ], [ %26, %25 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret double %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_sscanf(ptr nocapture noundef readonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !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