; 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
@.str.22 = external hidden unnamed_addr constant [4 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 double @atom(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local double @car(double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @unwind(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local double @f_catch(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca %struct.State, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 208, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @state, i64 208, i1 false), !tbaa.struct !9
  %7 = call i32 @_setjmp(ptr noundef @state) #5
  %8 = sitofp i32 %7 to double
  store double %8, ptr %5, align 8, !tbaa !13
  %9 = fcmp une double %8, 0.000000e+00
  br i1 %9, label %16, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load double, ptr %11, align 8, !tbaa !13
  %13 = call double @car(double noundef %12)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call double @eval(double noundef %13, ptr noundef %14)
  store double %15, ptr %5, align 8, !tbaa !13
  br label %24

16:                                               ; preds = %2
  %17 = load i32, ptr getelementptr inbounds (%struct.State, ptr @state, i32 0, i32 1), align 8, !tbaa !15
  %18 = getelementptr inbounds %struct.State, ptr %6, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = sub nsw i32 %17, %19
  call void @unwind(i32 noundef %20)
  %21 = call double @atom(ptr noundef @.str.22)
  %22 = load double, ptr %5, align 8, !tbaa !13
  %23 = call double @cons(double noundef %21, double noundef %22)
  store double %23, ptr %5, align 8, !tbaa !13
  br label %24

24:                                               ; preds = %16, %10
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @state, ptr align 8 %6, i64 208, i1 false), !tbaa.struct !9
  %25 = load double, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 208, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret double %25
}

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind returns_twice "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 }
attributes #5 = { nounwind returns_twice }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 200, !10, i64 200, i64 4, !11}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !12, i64 200}
!16 = !{!"State", !7, i64 0, !12, i64 200}


; 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 global %struct.State, align 8
@.str.22 = external hidden unnamed_addr constant [4 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 double @atom(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local double @car(double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @unwind(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local double @f_catch(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %.sroa.0 = alloca %struct.__jmp_buf_tag, align 8
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %.sroa.0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(200) %.sroa.0, ptr noundef nonnull align 8 dereferenceable(200) @state, i64 200, i1 false), !tbaa.struct !5
  %3 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @state, i64 200), align 8
  %4 = call i32 @_setjmp(ptr noundef nonnull @state) #4
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %9

5:                                                ; preds = %2
  %6 = load double, ptr %0, align 8, !tbaa !11
  %7 = call double @car(double noundef %6)
  %8 = call double @eval(double noundef %7, ptr noundef %1)
  br label %16

9:                                                ; preds = %2
  %10 = sitofp i32 %4 to double
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @state, i64 200), align 8, !tbaa !13
  %12 = extractelement <2 x i32> %3, i64 0
  %13 = sub nsw i32 %11, %12
  call void @unwind(i32 noundef %13)
  %14 = call double @atom(ptr noundef nonnull @.str.22)
  %15 = call double @cons(double noundef %14, double noundef %10)
  br label %16

16:                                               ; preds = %9, %5
  %.0 = phi double [ %15, %9 ], [ %8, %5 ]
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(200) @state, ptr noundef nonnull align 8 dereferenceable(200) %.sroa.0, i64 200, i1 false), !tbaa.struct !5
  store <2 x i32> %3, ptr getelementptr inbounds (i8, ptr @state, i64 200), align 8
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %.sroa.0)
  ret double %.0
}

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind returns_twice "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 returns_twice }

!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 = !{i64 0, i64 200, !6, i64 200, i64 4, !9}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 200}
!14 = !{!"State", !7, i64 0, !10, i64 200}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass