; LLVM IR from Razakhel/RaZ :: extern/simdjson/simdjson.ll (ZNK8simdjson8fallback14implementation6minifyEPKhmPhRm)

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

@_ZN8simdjson8fallbackL10jump_tableE = external hidden global [768 x i8], align 16

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK8simdjson8fallback14implementation6minifyEPKhmPhRm(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4) unnamed_addr #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 0, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 0, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  store i8 0, ptr %13, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #2
  store i8 1, ptr %14, align 1, !tbaa !11
  br label %18

18:                                               ; preds = %22, %5
  %19 = load i64, ptr %11, align 8, !tbaa !9
  %20 = load i64, ptr %8, align 8, !tbaa !9
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %22, label %70

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #2
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %23, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  store i8 %26, ptr %15, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %27 = load i8, ptr %15, align 1, !tbaa !11
  %28 = zext i8 %27 to i32
  %29 = mul nsw i32 3, %28
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr @_ZN8simdjson8fallbackL10jump_tableE, i64 %30
  store ptr %31, ptr %16, align 8, !tbaa !5
  %32 = load i8, ptr %13, align 1, !tbaa !11
  %33 = zext i8 %32 to i32
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 0
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  %38 = load i8, ptr %14, align 1, !tbaa !11
  %39 = zext i8 %38 to i32
  %40 = and i32 %37, %39
  %41 = xor i32 %33, %40
  %42 = trunc i32 %41 to i8
  store i8 %42, ptr %13, align 1, !tbaa !11
  %43 = load i8, ptr %15, align 1, !tbaa !11
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i64, ptr %12, align 8, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %44, i64 %45
  store i8 %43, ptr %46, align 1, !tbaa !11
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 2
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = zext i8 %49 to i32
  %51 = load i8, ptr %13, align 1, !tbaa !11
  %52 = zext i8 %51 to i32
  %53 = or i32 %50, %52
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr %12, align 8, !tbaa !9
  %56 = add i64 %55, %54
  store i64 %56, ptr %12, align 8, !tbaa !9
  %57 = load i64, ptr %11, align 8, !tbaa !9
  %58 = add i64 %57, 1
  store i64 %58, ptr %11, align 8, !tbaa !9
  %59 = load i8, ptr %14, align 1, !tbaa !11
  %60 = zext i8 %59 to i32
  %61 = xor i32 %60, -1
  %62 = trunc i32 %61 to i8
  %63 = zext i8 %62 to i32
  %64 = load ptr, ptr %16, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = zext i8 %66 to i32
  %68 = or i32 %63, %67
  %69 = trunc i32 %68 to i8
  store i8 %69, ptr %14, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #2
  br label %18, !llvm.loop !12

70:                                               ; preds = %18
  %71 = load i64, ptr %12, align 8, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %71, ptr %72, align 8, !tbaa !9
  %73 = load i8, ptr %13, align 1, !tbaa !11
  %74 = icmp ne i8 %73, 0
  %75 = zext i1 %74 to i64
  %76 = select i1 %74, i32 15, i32 0
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret i32 %76
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@_ZN8simdjson8fallbackL10jump_tableE = external hidden local_unnamed_addr global [768 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef range(i32 0, 16) i32 @_ZNK8simdjson8fallback14implementation6minifyEPKhmPhRm(ptr nocapture noundef nonnull readnone align 8 dereferenceable(48) %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %4) unnamed_addr #0 align 2 {
  %.not28 = icmp eq i64 %2, 0
  br i1 %.not28, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.026 = phi i64 [ %20, %.lr.ph ], [ 0, %5 ]
  %.02025 = phi i64 [ %19, %.lr.ph ], [ 0, %5 ]
  %.02124 = phi i8 [ %24, %.lr.ph ], [ 1, %5 ]
  %.02223 = phi i8 [ %13, %.lr.ph ], [ 0, %5 ]
  %6 = getelementptr inbounds i8, ptr %1, i64 %.026
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = zext i8 %7 to i64
  %9 = mul nuw nsw i64 %8, 3
  %10 = getelementptr inbounds i8, ptr @_ZN8simdjson8fallbackL10jump_tableE, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = and i8 %11, %.02124
  %13 = xor i8 %12, %.02223
  %14 = getelementptr inbounds i8, ptr %3, i64 %.02025
  store i8 %7, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %10, i64 2
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = or i8 %16, %13
  %18 = zext i8 %17 to i64
  %19 = add i64 %.02025, %18
  %20 = add nuw i64 %.026, 1
  %21 = xor i8 %.02124, -1
  %22 = getelementptr inbounds i8, ptr %10, i64 1
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = or i8 %23, %21
  %exitcond.not = icmp eq i64 %20, %2
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !8

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %25 = icmp eq i8 %12, %.02223
  %26 = select i1 %25, i32 0, i32 15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %5
  %.022.lcssa = phi i32 [ 0, %5 ], [ %26, %._crit_edge.loopexit ]
  %.020.lcssa = phi i64 [ 0, %5 ], [ %19, %._crit_edge.loopexit ]
  store i64 %.020.lcssa, ptr %4, align 8, !tbaa !10
  ret i32 %.022.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !6, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass