; LLVM IR from ARMmbed/mbed-crypto :: library (base64)

; 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 [25 x i8], align 1
@base64_test_dec = external hidden constant [64 x i8], align 16
@base64_test_enc = external hidden constant [89 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_base64_encode(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef) #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_base64_decode(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_base64_self_test(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [128 x i8], align 16
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %6) #4
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %1
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %12

12:                                               ; preds = %10, %1
  store ptr @base64_test_dec, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = call i32 @mbedtls_base64_encode(ptr noundef %13, i64 noundef 128, ptr noundef %4, ptr noundef %14, i64 noundef 64)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %21, label %17

17:                                               ; preds = %12
  %18 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %19 = call i32 @memcmp(ptr noundef @base64_test_enc, ptr noundef %18, i64 noundef 88) #5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %27

21:                                               ; preds = %17, %12
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %26

26:                                               ; preds = %24, %21
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

27:                                               ; preds = %17
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %32

32:                                               ; preds = %30, %27
  store ptr @base64_test_enc, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = call i32 @mbedtls_base64_decode(ptr noundef %33, i64 noundef 128, ptr noundef %4, ptr noundef %34, i64 noundef 88)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %41, label %37

37:                                               ; preds = %32
  %38 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %39 = call i32 @memcmp(ptr noundef @base64_test_dec, ptr noundef %38, i64 noundef 64) #5
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %47

41:                                               ; preds = %37, %32
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %41
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %46

46:                                               ; preds = %44, %41
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

47:                                               ; preds = %37
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %47
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %52

52:                                               ; preds = %50, %47
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %53

53:                                               ; preds = %52, %46, %26
  call void @llvm.lifetime.end.p0(i64 128, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %54 = load i32, ptr %2, align 4
  ret i32 %54
}

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

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 willreturn memory(read) "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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@base64_test_dec = external hidden constant [64 x i8], align 16
@base64_test_enc = external hidden constant [89 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_base64_encode(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_base64_decode(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @mbedtls_base64_self_test(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca i64, align 8
  %3 = alloca [128 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #4
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %6, label %4

4:                                                ; preds = %1
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %6

6:                                                ; preds = %4, %1
  %7 = call i32 @mbedtls_base64_encode(ptr noundef nonnull %3, i64 noundef 128, ptr noundef nonnull %2, ptr noundef nonnull @base64_test_dec, i64 noundef 64)
  %.not7 = icmp eq i32 %7, 0
  br i1 %.not7, label %8, label %9

8:                                                ; preds = %6
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(88) @base64_test_enc, ptr noundef nonnull dereferenceable(88) %3, i64 88)
  %.not8 = icmp eq i32 %bcmp, 0
  br i1 %.not8, label %10, label %9

9:                                                ; preds = %8, %6
  br i1 %.not, label %19, label %.sink.split

10:                                               ; preds = %8
  br i1 %.not, label %13, label %11

11:                                               ; preds = %10
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %13

13:                                               ; preds = %11, %10
  %14 = call i32 @mbedtls_base64_decode(ptr noundef nonnull %3, i64 noundef 128, ptr noundef nonnull %2, ptr noundef nonnull @base64_test_enc, i64 noundef 88)
  %.not9 = icmp eq i32 %14, 0
  br i1 %.not9, label %15, label %16

15:                                               ; preds = %13
  %bcmp10 = call i32 @bcmp(ptr noundef nonnull dereferenceable(64) @base64_test_dec, ptr noundef nonnull dereferenceable(64) %3, i64 64)
  %.not11 = icmp eq i32 %bcmp10, 0
  br i1 %.not11, label %17, label %16

16:                                               ; preds = %15, %13
  br i1 %.not, label %19, label %.sink.split

17:                                               ; preds = %15
  br i1 %.not, label %19, label %.sink.split

.sink.split:                                      ; preds = %17, %16, %9
  %.str.3.sink = phi ptr [ @.str.1, %9 ], [ @.str.1, %16 ], [ @.str.3, %17 ]
  %.0.ph = phi i32 [ 1, %9 ], [ 1, %16 ], [ 0, %17 ]
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  br label %19

19:                                               ; preds = %.sink.split, %17, %16, %9
  %.0 = phi i32 [ 1, %9 ], [ 1, %16 ], [ 0, %17 ], [ %.0.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret i32 %.0
}

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { 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)"}


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