; LLVM IR from ahr9n/psolving-paradigms :: 1.brute-force/1.2.recursive-brute-force-(backtracking)/Gym 325692E - Creating Expre_62b93ec3 (Z2okii)

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

@n = external dso_local global i64, align 8
@x = external dso_local global i64, align 8
@arr = external dso_local global [21 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2okii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = load i64, ptr @n, align 8, !tbaa !9
  %9 = icmp eq i64 %7, %8
  br i1 %9, label %10, label %15

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = load i64, ptr @x, align 8, !tbaa !9
  %14 = icmp eq i64 %12, %13
  store i1 %14, ptr %3, align 1
  br label %42

15:                                               ; preds = %2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [21 x i64], ptr @arr, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = add nsw i64 %19, %23
  %25 = trunc i64 %24 to i32
  %26 = call noundef zeroext i1 @_Z2okii(i32 noundef %17, i32 noundef %25)
  %27 = zext i1 %26 to i32
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [21 x i64], ptr @arr, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = sub nsw i64 %31, %35
  %37 = trunc i64 %36 to i32
  %38 = call noundef zeroext i1 @_Z2okii(i32 noundef %29, i32 noundef %37)
  %39 = zext i1 %38 to i32
  %40 = or i32 %27, %39
  %41 = icmp ne i32 %40, 0
  store i1 %41, ptr %3, align 1
  br label %42

42:                                               ; preds = %15, %10
  %43 = load i1, ptr %3, align 1
  ret i1 %43
}

attributes #0 = { 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long 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"

@n = external dso_local local_unnamed_addr global i64, align 8
@x = external dso_local local_unnamed_addr global i64, align 8
@arr = external dso_local local_unnamed_addr global [21 x i64], align 16

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z2okii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i64, ptr @n, align 8, !tbaa !5
  %4 = sext i32 %0 to i64
  %5 = icmp eq i64 %3, %4
  br i1 %5, label %tailrecurse._crit_edge, label %tailrecurse

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %2
  %accumulator.tr.lcssa = phi i1 [ false, %2 ], [ %16, %tailrecurse ]
  %.tr9.lcssa = phi i32 [ %1, %2 ], [ %15, %tailrecurse ]
  %6 = sext i32 %.tr9.lcssa to i64
  %7 = load i64, ptr @x, align 8, !tbaa !5
  %8 = icmp eq i64 %7, %6
  %accumulator.ret.tr = or i1 %accumulator.tr.lcssa, %8
  ret i1 %accumulator.ret.tr

tailrecurse:                                      ; preds = %2, %tailrecurse
  %indvars.iv = phi i64 [ %indvars.iv.next, %tailrecurse ], [ %4, %2 ]
  %.tr912 = phi i32 [ %15, %tailrecurse ], [ %1, %2 ]
  %accumulator.tr10 = phi i1 [ %16, %tailrecurse ], [ false, %2 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %9 = getelementptr inbounds [21 x i64], ptr @arr, i64 0, i64 %indvars.iv
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = trunc i64 %10 to i32
  %12 = add i32 %.tr912, %11
  %13 = trunc nsw i64 %indvars.iv.next to i32
  %14 = tail call noundef zeroext i1 @_Z2okii(i32 noundef %13, i32 noundef %12)
  %15 = sub i32 %.tr912, %11
  %16 = or i1 %accumulator.tr10, %14
  %17 = icmp eq i64 %3, %indvars.iv.next
  br i1 %17, label %tailrecurse._crit_edge, label %tailrecurse
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass