; LLVM IR from HarshCasper/NeoAlgo :: C/other (Find_the_numbers)

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

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

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

14:                                               ; preds = %27, %2
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %30

19:                                               ; preds = %14
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %21, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = xor i32 %20, %25
  store i32 %26, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %19
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !11

30:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = xor i32 %33, -1
  %35 = and i32 %31, %34
  store i32 %35, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %67, %30
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %70

41:                                               ; preds = %36
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = and i32 %46, %47
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %58

50:                                               ; preds = %41
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = xor i32 %51, %56
  store i32 %57, ptr %8, align 4, !tbaa !9
  br label %66

58:                                               ; preds = %41
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr %60, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = xor i32 %59, %64
  store i32 %65, ptr %9, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %58, %50
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %10, align 4, !tbaa !9
  br label %36, !llvm.loop !13

70:                                               ; preds = %40
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = icmp sgt i32 %71, %72
  br i1 %73, label %74, label %78

74:                                               ; preds = %70
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = load i32, ptr %8, align 4, !tbaa !9
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %75, i32 noundef %76)
  br label %82

78:                                               ; preds = %70
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %79, i32 noundef %80)
  br label %82

82:                                               ; preds = %78, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; 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

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"any pointer", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @findUniquePair(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = icmp sgt i32 %1, 1
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %1 to i64
  %5 = add nsw i64 %wide.trip.count, -1
  %min.iters.check = icmp ult i32 %1, 9
  br i1 %min.iters.check, label %.lr.ph.preheader81, label %vector.ph

.lr.ph.preheader81:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.02933.ph = phi i32 [ %3, %.lr.ph.preheader ], [ %12, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %5, -8
  %ind.end = or disjoint i64 %n.vec, 1
  %6 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %3, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %6, %vector.ph ], [ %9, %vector.body ]
  %vec.phi52 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %10, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %7 = getelementptr inbounds i32, ptr %0, i64 %offset.idx
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %wide.load = load <4 x i32>, ptr %7, align 4, !tbaa !5
  %wide.load53 = load <4 x i32>, ptr %8, align 4, !tbaa !5
  %9 = xor <4 x i32> %wide.load, %vec.phi
  %10 = xor <4 x i32> %wide.load53, %vec.phi52
  %index.next = add nuw i64 %index, 8
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = xor <4 x i32> %10, %9
  %12 = tail call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %5, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader81

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %2
  %.029.lcssa = phi i32 [ %3, %2 ], [ %12, %middle.block ], [ %35, %.lr.ph ]
  %13 = sub i32 0, %.029.lcssa
  %14 = and i32 %.029.lcssa, %13
  %15 = icmp sgt i32 %1, 0
  br i1 %15, label %.lr.ph38.preheader, label %._crit_edge39.thread

.lr.ph38.preheader:                               ; preds = %._crit_edge
  %wide.trip.count46 = zext nneg i32 %1 to i64
  %min.iters.check56 = icmp ult i32 %1, 8
  br i1 %min.iters.check56, label %.lr.ph38.preheader75, label %vector.ph57

.lr.ph38.preheader75:                             ; preds = %middle.block54, %.lr.ph38.preheader
  %indvars.iv43.ph = phi i64 [ 0, %.lr.ph38.preheader ], [ %n.vec59, %middle.block54 ]
  %.02635.ph = phi i32 [ 0, %.lr.ph38.preheader ], [ %31, %middle.block54 ]
  %.02734.ph = phi i32 [ 0, %.lr.ph38.preheader ], [ %32, %middle.block54 ]
  br label %.lr.ph38

vector.ph57:                                      ; preds = %.lr.ph38.preheader
  %n.vec59 = and i64 %wide.trip.count46, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %14, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body61

vector.body61:                                    ; preds = %vector.body61, %vector.ph57
  %index62 = phi i64 [ 0, %vector.ph57 ], [ %index.next69, %vector.body61 ]
  %vec.phi63 = phi <4 x i32> [ zeroinitializer, %vector.ph57 ], [ %28, %vector.body61 ]
  %vec.phi64 = phi <4 x i32> [ zeroinitializer, %vector.ph57 ], [ %29, %vector.body61 ]
  %vec.phi65 = phi <4 x i32> [ zeroinitializer, %vector.ph57 ], [ %24, %vector.body61 ]
  %vec.phi66 = phi <4 x i32> [ zeroinitializer, %vector.ph57 ], [ %25, %vector.body61 ]
  %16 = getelementptr inbounds i32, ptr %0, i64 %index62
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load67 = load <4 x i32>, ptr %16, align 4, !tbaa !5
  %wide.load68 = load <4 x i32>, ptr %17, align 4, !tbaa !5
  %18 = and <4 x i32> %broadcast.splat, %wide.load67
  %19 = and <4 x i32> %broadcast.splat, %wide.load68
  %20 = icmp eq <4 x i32> %18, zeroinitializer
  %21 = icmp eq <4 x i32> %19, zeroinitializer
  %22 = select <4 x i1> %20, <4 x i32> zeroinitializer, <4 x i32> %wide.load67
  %23 = select <4 x i1> %21, <4 x i32> zeroinitializer, <4 x i32> %wide.load68
  %24 = xor <4 x i32> %22, %vec.phi65
  %25 = xor <4 x i32> %23, %vec.phi66
  %26 = select <4 x i1> %20, <4 x i32> %wide.load67, <4 x i32> zeroinitializer
  %27 = select <4 x i1> %21, <4 x i32> %wide.load68, <4 x i32> zeroinitializer
  %28 = xor <4 x i32> %26, %vec.phi63
  %29 = xor <4 x i32> %27, %vec.phi64
  %index.next69 = add nuw i64 %index62, 8
  %30 = icmp eq i64 %index.next69, %n.vec59
  br i1 %30, label %middle.block54, label %vector.body61, !llvm.loop !13

middle.block54:                                   ; preds = %vector.body61
  %bin.rdx70 = xor <4 x i32> %29, %28
  %31 = tail call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %bin.rdx70)
  %bin.rdx71 = xor <4 x i32> %25, %24
  %32 = tail call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %bin.rdx71)
  %cmp.n72 = icmp eq i64 %n.vec59, %wide.trip.count46
  br i1 %cmp.n72, label %._crit_edge39, label %.lr.ph38.preheader75

.lr.ph:                                           ; preds = %.lr.ph.preheader81, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader81 ]
  %.02933 = phi i32 [ %35, %.lr.ph ], [ %.02933.ph, %.lr.ph.preheader81 ]
  %33 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = xor i32 %34, %.02933
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge39:                                    ; preds = %.lr.ph38, %middle.block54
  %.128.lcssa = phi i32 [ %32, %middle.block54 ], [ %.128, %.lr.ph38 ]
  %.1.lcssa = phi i32 [ %31, %middle.block54 ], [ %.1, %.lr.ph38 ]
  %36 = icmp sgt i32 %.128.lcssa, %.1.lcssa
  br i1 %36, label %42, label %._crit_edge39.thread

.lr.ph38:                                         ; preds = %.lr.ph38.preheader75, %.lr.ph38
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.lr.ph38 ], [ %indvars.iv43.ph, %.lr.ph38.preheader75 ]
  %.02635 = phi i32 [ %.1, %.lr.ph38 ], [ %.02635.ph, %.lr.ph38.preheader75 ]
  %.02734 = phi i32 [ %.128, %.lr.ph38 ], [ %.02734.ph, %.lr.ph38.preheader75 ]
  %37 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv43
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = and i32 %14, %38
  %.not = icmp eq i32 %39, 0
  %40 = select i1 %.not, i32 0, i32 %38
  %.128 = xor i32 %40, %.02734
  %41 = select i1 %.not, i32 %38, i32 0
  %.1 = xor i32 %41, %.02635
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next44, %wide.trip.count46
  br i1 %exitcond47.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !15

42:                                               ; preds = %._crit_edge39
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.1.lcssa, i32 noundef %.128.lcssa)
  br label %45

._crit_edge39.thread:                             ; preds = %._crit_edge, %._crit_edge39
  %.026.lcssa51 = phi i32 [ %.1.lcssa, %._crit_edge39 ], [ 0, %._crit_edge ]
  %.027.lcssa50 = phi i32 [ %.128.lcssa, %._crit_edge39 ], [ 0, %._crit_edge ]
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.027.lcssa50, i32 noundef %.026.lcssa51)
  br label %45

45:                                               ; preds = %._crit_edge39.thread, %42
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.xor.v4i32(<4 x i32>) #2

attributes #0 = { 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" }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11, !12}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10, !12, !11}


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