; LLVM IR from t-dillon/tdoku :: other (other_z3)

; 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.(anonymous namespace)::SolverZ3" = type { %"class.z3::context", %"class.z3::solver", %"class.z3::ast_vector_tpl" }
%"class.z3::context" = type { i8, i32, ptr }
%"class.z3::solver" = type { %"class.z3::object", ptr }
%"class.z3::object" = type { ptr }
%"class.z3::ast_vector_tpl" = type { %"class.z3::object", ptr }

@__dso_handle = external hidden global i8
@_ZZ13OtherSolverZ3E6solver = external hidden global %"struct.(anonymous namespace)::SolverZ3", align 8
@_ZGVZ13OtherSolverZ3E6solver = external hidden global i64, align 8

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #0

; Function Attrs: mustprogress uwtable
define dso_local i64 @OtherSolverZ3(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #0
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 81
  %16 = load i8, ptr %15, align 1, !tbaa !13
  %17 = sext i8 %16 to i32
  %18 = icmp sge i32 %17, 46
  %19 = zext i1 %18 to i8
  store i8 %19, ptr %11, align 1, !tbaa !14
  %20 = load atomic i8, ptr @_ZGVZ13OtherSolverZ3E6solver acquire, align 8
  %21 = icmp eq i8 %20, 0
  br i1 %21, label %22, label %28, !prof !16

22:                                               ; preds = %5
  %23 = call i32 @__cxa_guard_acquire(ptr @_ZGVZ13OtherSolverZ3E6solver) #0
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  invoke void @_ZN12_GLOBAL__N_18SolverZ3C2Ev(ptr noundef nonnull align 8 dereferenceable(48) @_ZZ13OtherSolverZ3E6solver)
          to label %26 unwind label %37

26:                                               ; preds = %25
  %27 = call i32 @__cxa_atexit(ptr @_ZN12_GLOBAL__N_18SolverZ3D2Ev, ptr @_ZZ13OtherSolverZ3E6solver, ptr @__dso_handle) #0
  call void @__cxa_guard_release(ptr @_ZGVZ13OtherSolverZ3E6solver) #0
  br label %28

28:                                               ; preds = %26, %22, %5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = trunc i64 %30 to i32
  %32 = load i8, ptr %11, align 1, !tbaa !14, !range !17, !noundef !18
  %33 = trunc i8 %32 to i1
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = call noundef i64 @_ZN12_GLOBAL__N_18SolverZ311SolveSudokuEPKcibPcPm(ptr noundef nonnull align 8 dereferenceable(48) @_ZZ13OtherSolverZ3E6solver, ptr noundef %29, i32 noundef %31, i1 noundef zeroext %33, ptr noundef %34, ptr noundef %35)
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #0
  ret i64 %36

37:                                               ; preds = %25
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %12, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %13, align 4
  call void @__cxa_guard_abort(ptr @_ZGVZ13OtherSolverZ3E6solver) #0
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #0
  br label %41

41:                                               ; preds = %37
  %42 = load ptr, ptr %12, align 8
  %43 = load i32, ptr %13, align 4
  %44 = insertvalue { ptr, i32 } poison, ptr %42, 0
  %45 = insertvalue { ptr, i32 } %44, i32 %43, 1
  resume { ptr, i32 } %45
}

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

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_18SolverZ3C2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18SolverZ3D2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 align 2

; Function Attrs: nounwind
declare void @__cxa_guard_abort(ptr) #0

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_18SolverZ311SolveSudokuEPKcibPcPm(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef) #1 align 2

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

attributes #0 = { nounwind }
attributes #1 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"branch_weights", i32 1, i32 1048575}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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.(anonymous namespace)::SolverZ3" = type { %"class.z3::context", %"class.z3::solver", %"class.z3::ast_vector_tpl" }
%"class.z3::context" = type { i8, i32, ptr }
%"class.z3::solver" = type { %"class.z3::object", ptr }
%"class.z3::object" = type { ptr }
%"class.z3::ast_vector_tpl" = type { %"class.z3::object", ptr }

@__dso_handle = external hidden global i8
@_ZZ13OtherSolverZ3E6solver = external hidden global %"struct.(anonymous namespace)::SolverZ3", align 8
@_ZGVZ13OtherSolverZ3E6solver = external hidden global i64, align 8

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @OtherSolverZ3(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 81
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = load atomic i8, ptr @_ZGVZ13OtherSolverZ3E6solver acquire, align 8
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %10, label %15, !prof !8

10:                                               ; preds = %5
  %11 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZ13OtherSolverZ3E6solver) #3
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %15, label %12

12:                                               ; preds = %10
  invoke void @_ZN12_GLOBAL__N_18SolverZ3C2Ev(ptr noundef nonnull align 8 dereferenceable(48) @_ZZ13OtherSolverZ3E6solver)
          to label %13 unwind label %19

13:                                               ; preds = %12
  %14 = tail call i32 @__cxa_atexit(ptr nonnull @_ZN12_GLOBAL__N_18SolverZ3D2Ev, ptr nonnull @_ZZ13OtherSolverZ3E6solver, ptr nonnull @__dso_handle) #3
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZ13OtherSolverZ3E6solver) #3
  br label %15

15:                                               ; preds = %13, %10, %5
  %16 = icmp sgt i8 %7, 45
  %17 = trunc i64 %1 to i32
  %18 = tail call noundef i64 @_ZN12_GLOBAL__N_18SolverZ311SolveSudokuEPKcibPcPm(ptr noundef nonnull align 8 dereferenceable(48) @_ZZ13OtherSolverZ3E6solver, ptr noundef nonnull %0, i32 noundef %17, i1 noundef zeroext %16, ptr noundef %3, ptr noundef %4)
  ret i64 %18

19:                                               ; preds = %12
  %20 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_guard_abort(ptr nonnull @_ZGVZ13OtherSolverZ3E6solver) #3
  resume { ptr, i32 } %20
}

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_18SolverZ3C2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18SolverZ3D2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: nofree nounwind
declare void @__cxa_guard_abort(ptr) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_18SolverZ311SolveSudokuEPKcibPcPm(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

attributes #0 = { nofree nounwind }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!8 = !{!"branch_weights", i32 1, i32 1048575}


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