; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 30. CPP Programs/base64_encoding.ll (ZN7ciphers15base64_encoding8find_idxEc)

; 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 noundef zeroext i8 @_ZN7ciphers15base64_encoding8find_idxEc(i8 noundef signext %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca i8, align 1
  store i8 %0, ptr %3, align 1, !tbaa !5
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp sge i32 %5, 65
  br i1 %6, label %7, label %16

7:                                                ; preds = %1
  %8 = load i8, ptr %3, align 1, !tbaa !5
  %9 = sext i8 %8 to i32
  %10 = icmp sle i32 %9, 90
  br i1 %10, label %11, label %16

11:                                               ; preds = %7
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = sext i8 %12 to i32
  %14 = sub nsw i32 %13, 65
  %15 = trunc i32 %14 to i8
  store i8 %15, ptr %2, align 1
  br label %59

16:                                               ; preds = %7, %1
  %17 = load i8, ptr %3, align 1, !tbaa !5
  %18 = sext i8 %17 to i32
  %19 = icmp sge i32 %18, 97
  br i1 %19, label %20, label %30

20:                                               ; preds = %16
  %21 = load i8, ptr %3, align 1, !tbaa !5
  %22 = sext i8 %21 to i32
  %23 = icmp sle i32 %22, 122
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  %25 = load i8, ptr %3, align 1, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = sub nsw i32 %26, 97
  %28 = add nsw i32 %27, 26
  %29 = trunc i32 %28 to i8
  store i8 %29, ptr %2, align 1
  br label %59

30:                                               ; preds = %20, %16
  %31 = load i8, ptr %3, align 1, !tbaa !5
  %32 = sext i8 %31 to i32
  %33 = icmp sge i32 %32, 48
  br i1 %33, label %34, label %44

34:                                               ; preds = %30
  %35 = load i8, ptr %3, align 1, !tbaa !5
  %36 = sext i8 %35 to i32
  %37 = icmp sle i32 %36, 57
  br i1 %37, label %38, label %44

38:                                               ; preds = %34
  %39 = load i8, ptr %3, align 1, !tbaa !5
  %40 = sext i8 %39 to i32
  %41 = sub nsw i32 %40, 48
  %42 = add nsw i32 %41, 52
  %43 = trunc i32 %42 to i8
  store i8 %43, ptr %2, align 1
  br label %59

44:                                               ; preds = %34, %30
  %45 = load i8, ptr %3, align 1, !tbaa !5
  %46 = sext i8 %45 to i32
  %47 = icmp eq i32 %46, 43
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  store i8 62, ptr %2, align 1
  br label %59

49:                                               ; preds = %44
  %50 = load i8, ptr %3, align 1, !tbaa !5
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 47
  br i1 %52, label %53, label %54

53:                                               ; preds = %49
  store i8 63, ptr %2, align 1
  br label %59

54:                                               ; preds = %49
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  store i8 -1, ptr %2, align 1
  br label %59

59:                                               ; preds = %58, %53, %48, %38, %24, %11
  %60 = load i8, ptr %2, align 1
  ret i8 %60
}

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

!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"}


; 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 noundef zeroext range(i8 -1, 64) i8 @_ZN7ciphers15base64_encoding8find_idxEc(i8 noundef signext %0) local_unnamed_addr #0 {
  %2 = add i8 %0, -65
  %or.cond = icmp ult i8 %2, 26
  br i1 %or.cond, label %12, label %3

3:                                                ; preds = %1
  %4 = add i8 %0, -97
  %or.cond5 = icmp ult i8 %4, 26
  br i1 %or.cond5, label %5, label %7

5:                                                ; preds = %3
  %6 = add nsw i8 %0, -71
  br label %12

7:                                                ; preds = %3
  %8 = add i8 %0, -48
  %or.cond8 = icmp ult i8 %8, 10
  br i1 %or.cond8, label %9, label %11

9:                                                ; preds = %7
  %10 = add nuw nsw i8 %0, 4
  br label %12

11:                                               ; preds = %7
  %switch.selectcmp = icmp eq i8 %0, 47
  %switch.select = select i1 %switch.selectcmp, i8 63, i8 -1
  %switch.selectcmp21 = icmp eq i8 %0, 43
  %switch.select22 = select i1 %switch.selectcmp21, i8 62, i8 %switch.select
  br label %12

12:                                               ; preds = %1, %11, %9, %5
  %.0 = phi i8 [ %6, %5 ], [ %10, %9 ], [ %switch.select22, %11 ], [ %2, %1 ]
  ret i8 %.0
}

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,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass