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

@CONS = external dso_local global i64, align 8
@cell = external dso_local global ptr, align 8
@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.16 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i64 @ord(double noundef) #0

; 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 @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 signext i8 @scan() #0

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

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

6:                                                ; preds = %57, %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 %12

11:                                               ; preds = %7
  br label %59

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

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

19:                                               ; preds = %16
  %20 = call double @readlisp()
  store double %20, ptr %3, align 8, !tbaa !5
  %21 = call signext i8 @scan()
  %22 = sext i8 %21 to i32
  %23 = icmp ne i32 %22, 41
  br i1 %23, label %24, label %28

24:                                               ; preds = %19
  %25 = load ptr, ptr @stderr, align 8, !tbaa !10
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.16) #3
  %27 = call double @err(i32 noundef 8)
  br label %28

28:                                               ; preds = %24, %19
  %29 = load double, ptr %3, align 8, !tbaa !5
  %30 = load i64, ptr %2, align 8, !tbaa !12
  %31 = lshr i64 %30, 48
  %32 = load i64, ptr @CONS, align 8, !tbaa !12
  %33 = icmp eq i64 %31, %32
  br i1 %33, label %34, label %39

34:                                               ; preds = %28
  %35 = load ptr, ptr @cell, align 8, !tbaa !10
  %36 = load double, ptr %2, align 8, !tbaa !5
  %37 = call i64 @ord(double noundef %36)
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  br label %40

39:                                               ; preds = %28
  br label %40

40:                                               ; preds = %39, %34
  %41 = phi ptr [ %38, %34 ], [ %1, %39 ]
  store double %29, ptr %41, align 8, !tbaa !5
  br label %59

42:                                               ; preds = %16, %12
  %43 = call double @parse()
  %44 = load double, ptr @nil, align 8, !tbaa !5
  %45 = call double @cons(double noundef %43, double noundef %44)
  store double %45, ptr %3, align 8, !tbaa !5
  %46 = load double, ptr %3, align 8, !tbaa !5
  %47 = load i64, ptr %2, align 8, !tbaa !12
  %48 = lshr i64 %47, 48
  %49 = load i64, ptr @CONS, align 8, !tbaa !12
  %50 = icmp eq i64 %48, %49
  br i1 %50, label %51, label %56

51:                                               ; preds = %42
  %52 = load ptr, ptr @cell, align 8, !tbaa !10
  %53 = load double, ptr %2, align 8, !tbaa !5
  %54 = call i64 @ord(double noundef %53)
  %55 = getelementptr inbounds double, ptr %52, i64 %54
  br label %57

56:                                               ; preds = %42
  br label %57

57:                                               ; preds = %56, %51
  %58 = phi ptr [ %55, %51 ], [ %1, %56 ]
  store double %46, ptr %58, align 8, !tbaa !5
  store double %46, ptr %2, align 8, !tbaa !5
  br label %6

59:                                               ; preds = %40, %11
  %60 = load double, ptr %1, align 8, !tbaa !5
  %61 = call double @ret(i32 noundef 2, double noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret double %61
}

; Function Attrs: nounwind uwtable
declare dso_local double @parse() #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 = { 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 = !{!"double", !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}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !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"

@CONS = external dso_local local_unnamed_addr global i64, align 8
@cell = external dso_local local_unnamed_addr global ptr, align 8
@nil = external dso_local local_unnamed_addr global double, align 8
@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 i64 @ord(double noundef) local_unnamed_addr #0

; 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 @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 signext i8 @scan() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local double @list() local_unnamed_addr #0 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %3 = load double, ptr @nil, align 8, !tbaa !5
  store double %3, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store double %3, ptr %2, align 8, !tbaa !5
  call void (i32, ...) @var(i32 noundef 2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = call signext i8 @scan()
  %5 = icmp eq i8 %4, 41
  br i1 %5, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %0, %42
  %6 = load i8, ptr @buf, align 16, !tbaa !9
  %7 = icmp ne i8 %6, 46
  %8 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 1), align 1
  %9 = icmp ne i8 %8, 0
  %or.cond = select i1 %7, i1 true, i1 %9
  br i1 %or.cond, label %29, label %10

10:                                               ; preds = %.lr.ph
  %11 = call double @readlisp()
  %12 = call signext i8 @scan()
  %.not = icmp eq i8 %12, 41
  br i1 %.not, label %17, label %13

13:                                               ; preds = %10
  %14 = load ptr, ptr @stderr, align 8, !tbaa !10
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.16) #4
  %16 = call double @err(i32 noundef 8)
  br label %17

17:                                               ; preds = %13, %10
  %18 = load i64, ptr %2, align 8
  %19 = lshr i64 %18, 48
  %20 = load i64, ptr @CONS, align 8, !tbaa !12
  %21 = icmp eq i64 %19, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %17
  %23 = bitcast i64 %18 to double
  %24 = load ptr, ptr @cell, align 8, !tbaa !10
  %25 = call i64 @ord(double noundef %23)
  %26 = getelementptr inbounds double, ptr %24, i64 %25
  br label %27

27:                                               ; preds = %17, %22
  %28 = phi ptr [ %26, %22 ], [ %1, %17 ]
  store double %11, ptr %28, align 8, !tbaa !5
  br label %.loopexit

29:                                               ; preds = %.lr.ph
  %30 = call double @parse()
  %31 = load double, ptr @nil, align 8, !tbaa !5
  %32 = call double @cons(double noundef %30, double noundef %31)
  %33 = load i64, ptr %2, align 8
  %34 = lshr i64 %33, 48
  %35 = load i64, ptr @CONS, align 8, !tbaa !12
  %36 = icmp eq i64 %34, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %29
  %38 = bitcast i64 %33 to double
  %39 = load ptr, ptr @cell, align 8, !tbaa !10
  %40 = call i64 @ord(double noundef %38)
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  br label %42

42:                                               ; preds = %29, %37
  %43 = phi ptr [ %41, %37 ], [ %1, %29 ]
  store double %32, ptr %43, align 8, !tbaa !5
  store double %32, ptr %2, align 8, !tbaa !5
  %44 = call signext i8 @scan()
  %45 = icmp eq i8 %44, 41
  br i1 %45, label %.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %42, %0, %27
  %46 = load double, ptr %1, align 8, !tbaa !5
  %47 = call double @ret(i32 noundef 2, double noundef %46)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret double %47
}

; Function Attrs: nounwind uwtable
declare dso_local double @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 = { 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 = !{!"double", !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}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}


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