; LLVM IR from turi-code/SFrame :: oss_src/flexible_type/string_escape.ll (ZN8graphlab15parse_hex_blockEPcRm)

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

; 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 uwtable
define dso_local noundef zeroext i1 @_ZN8graphlab15parse_hex_blockEPcRm(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %36, %2
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = icmp ult i64 %11, 4
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 2, ptr %7, align 4
  br label %39

14:                                               ; preds = %10
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = mul i64 %16, 16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %17, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = call noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext %22)
  store i64 %23, ptr %8, align 8, !tbaa !9
  %24 = load i64, ptr %8, align 8, !tbaa !9
  %25 = icmp eq i64 %24, -1
  br i1 %25, label %26, label %27

26:                                               ; preds = %14
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %33

27:                                               ; preds = %14
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = add i64 %29, %30
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %31, ptr %32, align 8, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %33

33:                                               ; preds = %27, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %34 = load i32, ptr %7, align 4
  switch i32 %34, label %39 [
    i32 0, label %35
  ]

35:                                               ; preds = %33
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %6, align 8, !tbaa !9
  %38 = add i64 %37, 1
  store i64 %38, ptr %6, align 8, !tbaa !9
  br label %10, !llvm.loop !12

39:                                               ; preds = %33, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %40 = load i32, ptr %7, align 4
  switch i32 %40, label %44 [
    i32 2, label %41
    i32 1, label %42
  ]

41:                                               ; preds = %39
  store i1 true, ptr %3, align 1
  br label %42

42:                                               ; preds = %41, %39
  %43 = load i1, ptr %3, align 1
  ret i1 %43

44:                                               ; preds = %39
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext) #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8graphlab15parse_hex_blockEPcRm(ptr nocapture noundef readonly %0, ptr nocapture noundef nonnull align 8 dereferenceable(8) %1) local_unnamed_addr #0 {
  store i64 0, ptr %1, align 8, !tbaa !5
  %3 = load i8, ptr %0, align 1, !tbaa !9
  %4 = tail call noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext %3)
  %.not = icmp eq i64 %4, -1
  br i1 %.not, label %.critedge, label %5

5:                                                ; preds = %2
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = add i64 %6, %4
  %8 = shl i64 %7, 4
  store i64 %8, ptr %1, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 1
  %10 = load i8, ptr %9, align 1, !tbaa !9
  %11 = tail call noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext %10)
  %.not.1 = icmp eq i64 %11, -1
  br i1 %.not.1, label %.critedge, label %12

12:                                               ; preds = %5
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = add i64 %13, %11
  %15 = shl i64 %14, 4
  store i64 %15, ptr %1, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = tail call noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext %17)
  %.not.2 = icmp eq i64 %18, -1
  br i1 %.not.2, label %.critedge, label %19

19:                                               ; preds = %12
  %20 = load i64, ptr %1, align 8, !tbaa !5
  %21 = add i64 %20, %18
  %22 = shl i64 %21, 4
  store i64 %22, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 3
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = tail call noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext %24)
  %.not.3 = icmp eq i64 %25, -1
  br i1 %.not.3, label %.critedge, label %26

26:                                               ; preds = %19
  %27 = load i64, ptr %1, align 8, !tbaa !5
  %28 = add i64 %27, %25
  store i64 %28, ptr %1, align 8, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %26, %19, %12, %5, %2
  %.lcssa = phi i1 [ false, %2 ], [ false, %5 ], [ false, %12 ], [ false, %19 ], [ true, %26 ]
  ret i1 %.lcssa
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN8graphlab10hex_to_valEc(i8 noundef signext) local_unnamed_addr #1

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass