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

%struct.State = type { [1 x %struct.__jmp_buf_tag], i32 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@state = external dso_local global %struct.State, align 8
@tr = external dso_local global i64, align 8
@.str.64 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [5 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 void @var(i32 noundef, ...) #1

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: inlinehint nounwind uwtable
declare i32 @getchar() #3

; Function Attrs: nounwind uwtable
define dso_local double @eval(double noundef %0, ptr noundef %1) #1 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load i64, ptr @tr, align 8, !tbaa !11
  %9 = icmp ne i64 %8, 0
  br i1 %9, label %14, label %10

10:                                               ; preds = %2
  %11 = load double, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = call double @step(double noundef %11, ptr noundef %12)
  store double %13, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %36

14:                                               ; preds = %2
  call void (i32, ...) @var(i32 noundef 1, ptr noundef %4)
  %15 = load double, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = call double @step(double noundef %15, ptr noundef %16)
  store double %17, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr getelementptr inbounds (%struct.State, ptr @state, i32 0, i32 1), align 8, !tbaa !13
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.64, i32 noundef %18)
  %20 = load double, ptr %4, align 8, !tbaa !5
  call void @print(double noundef %20)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.65)
  %22 = load double, ptr %6, align 8, !tbaa !5
  call void @print(double noundef %22)
  %23 = load i64, ptr @tr, align 8, !tbaa !11
  %24 = icmp ugt i64 %23, 1
  br i1 %24, label %25, label %31

25:                                               ; preds = %14
  br label %26

26:                                               ; preds = %29, %25
  %27 = call i32 @getchar()
  %28 = icmp sge i32 %27, 32
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %26, !llvm.loop !16

30:                                               ; preds = %26
  br label %33

31:                                               ; preds = %14
  %32 = call i32 @putchar(i32 noundef 10)
  br label %33

33:                                               ; preds = %31, %30
  %34 = load double, ptr %6, align 8, !tbaa !5
  %35 = call double @ret(i32 noundef 1, double noundef %34)
  store double %35, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %36

36:                                               ; preds = %33, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %37 = load double, ptr %3, align 8
  ret double %37
}

; Function Attrs: nounwind uwtable
declare dso_local void @print(double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local double @step(double noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #3

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 = { "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 = { inlinehint 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 200}
!14 = !{!"State", !7, i64 0, !15, i64 200}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%struct.State = type { [1 x %struct.__jmp_buf_tag], i32 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@state = external dso_local local_unnamed_addr global %struct.State, align 8
@tr = external dso_local local_unnamed_addr global i64, align 8
@.str.64 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [5 x i8], align 1

; 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local double @eval(double noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  %4 = load i64, ptr @tr, align 8, !tbaa !9
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call double @step(double noundef %0, ptr noundef %1)
  br label %21

7:                                                ; preds = %2
  call void (i32, ...) @var(i32 noundef 1, ptr noundef nonnull %3)
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = call double @step(double noundef %8, ptr noundef %1)
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @state, i64 200), align 8, !tbaa !11
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.64, i32 noundef %10)
  %12 = load double, ptr %3, align 8, !tbaa !5
  call void @print(double noundef %12)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.65)
  call void @print(double noundef %9)
  %14 = load i64, ptr @tr, align 8, !tbaa !9
  %15 = icmp ugt i64 %14, 1
  br i1 %15, label %.preheader, label %18

.preheader:                                       ; preds = %7, %.preheader
  %16 = call i32 @getchar()
  %17 = icmp sgt i32 %16, 31
  br i1 %17, label %.preheader, label %.loopexit, !llvm.loop !14

18:                                               ; preds = %7
  %19 = call i32 @putchar(i32 noundef 10)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %18
  %20 = call double @ret(i32 noundef 1, double noundef %9)
  br label %21

21:                                               ; preds = %.loopexit, %5
  %.0 = phi double [ %20, %.loopexit ], [ %6, %5 ]
  ret double %.0
}

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

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

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) 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 = { 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 = { inlinehint nofree 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" }

!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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 200}
!12 = !{!"State", !7, i64 0, !13, i64 200}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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