; LLVM IR from alekras/ao.rtos.cpp :: Library/hex2bin (Hex2BinEFSMachine)

; 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: mustprogress nounwind uwtable
define dso_local i32 @convert(i32 noundef %0, i8 noundef signext %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %6 = load i8, ptr %4, align 1, !tbaa !9
  %7 = sext i8 %6 to i32
  %8 = icmp sge i32 %7, 48
  br i1 %8, label %9, label %17

9:                                                ; preds = %2
  %10 = load i8, ptr %4, align 1, !tbaa !9
  %11 = sext i8 %10 to i32
  %12 = icmp sle i32 %11, 57
  br i1 %12, label %13, label %17

13:                                               ; preds = %9
  %14 = load i8, ptr %4, align 1, !tbaa !9
  %15 = sext i8 %14 to i32
  %16 = sub nsw i32 %15, 48
  store i32 %16, ptr %5, align 4, !tbaa !5
  br label %46

17:                                               ; preds = %9, %2
  %18 = load i8, ptr %4, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp sge i32 %19, 65
  br i1 %20, label %21, label %30

21:                                               ; preds = %17
  %22 = load i8, ptr %4, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp sle i32 %23, 70
  br i1 %24, label %25, label %30

25:                                               ; preds = %21
  %26 = load i8, ptr %4, align 1, !tbaa !9
  %27 = sext i8 %26 to i32
  %28 = sub nsw i32 %27, 65
  %29 = add nsw i32 %28, 10
  store i32 %29, ptr %5, align 4, !tbaa !5
  br label %45

30:                                               ; preds = %21, %17
  %31 = load i8, ptr %4, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = icmp sge i32 %32, 97
  br i1 %33, label %34, label %43

34:                                               ; preds = %30
  %35 = load i8, ptr %4, align 1, !tbaa !9
  %36 = sext i8 %35 to i32
  %37 = icmp sle i32 %36, 102
  br i1 %37, label %38, label %43

38:                                               ; preds = %34
  %39 = load i8, ptr %4, align 1, !tbaa !9
  %40 = sext i8 %39 to i32
  %41 = sub nsw i32 %40, 97
  %42 = add nsw i32 %41, 10
  store i32 %42, ptr %5, align 4, !tbaa !5
  br label %44

43:                                               ; preds = %34, %30
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %43, %38
  br label %45

45:                                               ; preds = %44, %25
  br label %46

46:                                               ; preds = %45, %13
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = shl i32 %47, 4
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = or i32 %48, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %50
}

; 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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @convert(i32 noundef %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %3 = sext i8 %1 to i32
  %4 = add i8 %1, -48
  %or.cond = icmp ult i8 %4, 10
  br i1 %or.cond, label %5, label %7

5:                                                ; preds = %2
  %6 = add nsw i32 %3, -48
  br label %14

7:                                                ; preds = %2
  %8 = add i8 %1, -65
  %or.cond5 = icmp ult i8 %8, 6
  br i1 %or.cond5, label %9, label %11

9:                                                ; preds = %7
  %10 = add nsw i32 %3, -55
  br label %14

11:                                               ; preds = %7
  %12 = add i8 %1, -97
  %or.cond8 = icmp ult i8 %12, 6
  %13 = add nsw i32 %3, -87
  %spec.select = select i1 %or.cond8, i32 %13, i32 0
  br label %14

14:                                               ; preds = %11, %9, %5
  %.0 = phi i32 [ %6, %5 ], [ %10, %9 ], [ %spec.select, %11 ]
  %15 = shl i32 %0, 4
  %16 = or i32 %.0, %15
  ret i32 %16
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass