; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (ccm)

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

%struct.mbedtls_ccm_context = type { %struct.mbedtls_cipher_context_t }
%struct.mbedtls_cipher_context_t = type { ptr, i32, i32, ptr, ptr, [16 x i8], i64, [16 x i8], i64, ptr }

@key = external hidden constant [16 x i8], align 16
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@msg_len = external hidden constant [3 x i64], align 16
@iv = external hidden constant [12 x i8], align 1
@iv_len = external hidden constant [3 x i64], align 16
@ad = external hidden constant [20 x i8], align 16
@add_len = external hidden constant [3 x i64], align 16
@msg = external hidden constant [24 x i8], align 16
@tag_len = external hidden constant [3 x i64], align 16
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@res = external hidden constant <{ <{ [8 x i8], [24 x i8] }>, <{ [22 x i8], [10 x i8] }>, [32 x i8] }>, align 16

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_ccm_init(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ccm_setkey(ptr noundef, i32 noundef, ptr noundef, i32 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 void @mbedtls_ccm_free(ptr noundef) #0

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

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

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

11:                                               ; preds = %1
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %16

16:                                               ; preds = %14, %11
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %126

17:                                               ; preds = %1
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %117, %17
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = icmp ult i64 %19, 3
  br i1 %20, label %21, label %120

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

24:                                               ; preds = %21
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = trunc i64 %25 to i32
  %27 = add i32 %26, 1
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %27)
  br label %29

29:                                               ; preds = %24, %21
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = getelementptr inbounds [3 x i64], ptr @iv_len, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds [3 x i64], ptr @add_len, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds [32 x i8], ptr %5, i64 0, i64 0
  %40 = getelementptr inbounds [32 x i8], ptr %5, i64 0, i64 0
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %40, i64 %43
  %45 = load i64, ptr %6, align 8, !tbaa !9
  %46 = getelementptr inbounds [3 x i64], ptr @tag_len, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = call i32 @mbedtls_ccm_encrypt_and_tag(ptr noundef %4, i64 noundef %32, ptr noundef @iv, i64 noundef %35, ptr noundef @ad, i64 noundef %38, ptr noundef @msg, ptr noundef %39, ptr noundef %44, i64 noundef %47)
  store i32 %48, ptr %7, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %65, label %51

51:                                               ; preds = %29
  %52 = getelementptr inbounds [32 x i8], ptr %5, i64 0, i64 0
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds [3 x [32 x i8]], ptr @res, i64 0, i64 %53
  %55 = getelementptr inbounds [32 x i8], ptr %54, i64 0, i64 0
  %56 = load i64, ptr %6, align 8, !tbaa !9
  %57 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = load i64, ptr %6, align 8, !tbaa !9
  %60 = getelementptr inbounds [3 x i64], ptr @tag_len, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = add i64 %58, %61
  %63 = call i32 @memcmp(ptr noundef %52, ptr noundef %55, i64 noundef %62) #5
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %71

65:                                               ; preds = %51, %29
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %65
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %70

70:                                               ; preds = %68, %65
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %126

71:                                               ; preds = %51
  %72 = load i64, ptr %6, align 8, !tbaa !9
  %73 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !9
  %75 = load i64, ptr %6, align 8, !tbaa !9
  %76 = getelementptr inbounds [3 x i64], ptr @iv_len, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = load i64, ptr %6, align 8, !tbaa !9
  %79 = getelementptr inbounds [3 x i64], ptr @add_len, i64 0, i64 %78
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %81 = load i64, ptr %6, align 8, !tbaa !9
  %82 = getelementptr inbounds [3 x [32 x i8]], ptr @res, i64 0, i64 %81
  %83 = getelementptr inbounds [32 x i8], ptr %82, i64 0, i64 0
  %84 = getelementptr inbounds [32 x i8], ptr %5, i64 0, i64 0
  %85 = load i64, ptr %6, align 8, !tbaa !9
  %86 = getelementptr inbounds [3 x [32 x i8]], ptr @res, i64 0, i64 %85
  %87 = getelementptr inbounds [32 x i8], ptr %86, i64 0, i64 0
  %88 = load i64, ptr %6, align 8, !tbaa !9
  %89 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !9
  %91 = getelementptr inbounds i8, ptr %87, i64 %90
  %92 = load i64, ptr %6, align 8, !tbaa !9
  %93 = getelementptr inbounds [3 x i64], ptr @tag_len, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !9
  %95 = call i32 @mbedtls_ccm_auth_decrypt(ptr noundef %4, i64 noundef %74, ptr noundef @iv, i64 noundef %77, ptr noundef @ad, i64 noundef %80, ptr noundef %83, ptr noundef %84, ptr noundef %91, i64 noundef %94)
  store i32 %95, ptr %7, align 4, !tbaa !5
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %105, label %98

98:                                               ; preds = %71
  %99 = getelementptr inbounds [32 x i8], ptr %5, i64 0, i64 0
  %100 = load i64, ptr %6, align 8, !tbaa !9
  %101 = getelementptr inbounds [3 x i64], ptr @msg_len, i64 0, i64 %100
  %102 = load i64, ptr %101, align 8, !tbaa !9
  %103 = call i32 @memcmp(ptr noundef %99, ptr noundef @msg, i64 noundef %102) #5
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %111

105:                                              ; preds = %98, %71
  %106 = load i32, ptr %3, align 4, !tbaa !5
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %110

108:                                              ; preds = %105
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %110

110:                                              ; preds = %108, %105
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %126

111:                                              ; preds = %98
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %116

114:                                              ; preds = %111
  %115 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %116

116:                                              ; preds = %114, %111
  br label %117

117:                                              ; preds = %116
  %118 = load i64, ptr %6, align 8, !tbaa !9
  %119 = add i64 %118, 1
  store i64 %119, ptr %6, align 8, !tbaa !9
  br label %18, !llvm.loop !11

120:                                              ; preds = %18
  call void @mbedtls_ccm_free(ptr noundef %4)
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %125

123:                                              ; preds = %120
  %124 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %125

125:                                              ; preds = %123, %120
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %126

126:                                              ; preds = %125, %110, %70, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 88, ptr %4) #4
  %127 = load i32, ptr %2, align 4
  ret i32 %127
}

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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%struct.mbedtls_ccm_context = type { %struct.mbedtls_cipher_context_t }
%struct.mbedtls_cipher_context_t = type { ptr, i32, i32, ptr, ptr, [16 x i8], i64, [16 x i8], i64, ptr }

@key = external hidden constant [16 x i8], align 16
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@msg_len = external hidden local_unnamed_addr constant [3 x i64], align 16
@iv = external hidden constant [12 x i8], align 1
@iv_len = external hidden local_unnamed_addr constant [3 x i64], align 16
@ad = external hidden constant [20 x i8], align 16
@add_len = external hidden local_unnamed_addr constant [3 x i64], align 16
@msg = external hidden constant [24 x i8], align 16
@tag_len = external hidden local_unnamed_addr constant [3 x i64], align 16
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@res = external hidden constant <{ <{ [8 x i8], [24 x i8] }>, <{ [22 x i8], [10 x i8] }>, [32 x i8] }>, align 16

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_ccm_init(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ccm_setkey(ptr noundef, i32 noundef, ptr noundef, i32 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 void @mbedtls_ccm_free(ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @mbedtls_ccm_self_test(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.mbedtls_ccm_context, align 8
  %3 = alloca [32 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  call void @mbedtls_ccm_init(ptr noundef nonnull %2)
  %4 = call i32 @mbedtls_ccm_setkey(ptr noundef nonnull %2, i32 noundef 2, ptr noundef nonnull @key, i32 noundef 128)
  %.not = icmp eq i32 %4, 0
  %.not30 = icmp eq i32 %0, 0
  br i1 %.not, label %.preheader, label %5

.preheader:                                       ; preds = %1
  br i1 %.not30, label %10, label %8

5:                                                ; preds = %1
  br i1 %.not30, label %65, label %6

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

8:                                                ; preds = %.preheader
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 1)
  br label %10

10:                                               ; preds = %8, %.preheader
  %11 = load i64, ptr @msg_len, align 16, !tbaa !5
  %12 = load i64, ptr @iv_len, align 16, !tbaa !5
  %13 = load i64, ptr @add_len, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %3, i64 %11
  %15 = load i64, ptr @tag_len, align 16, !tbaa !5
  %16 = call i32 @mbedtls_ccm_encrypt_and_tag(ptr noundef nonnull %2, i64 noundef %11, ptr noundef nonnull @iv, i64 noundef %12, ptr noundef nonnull @ad, i64 noundef %13, ptr noundef nonnull @msg, ptr noundef nonnull %3, ptr noundef nonnull %14, i64 noundef %15)
  %.not31 = icmp eq i32 %16, 0
  br i1 %.not31, label %17, label %19

17:                                               ; preds = %10
  %18 = add i64 %15, %11
  %bcmp = call i32 @bcmp(ptr nonnull %3, ptr nonnull @res, i64 %18)
  %.not32 = icmp eq i32 %bcmp, 0
  br i1 %.not32, label %22, label %19

19:                                               ; preds = %55, %.thread39, %39, %.thread, %17, %10
  br i1 %.not30, label %65, label %20

20:                                               ; preds = %19
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %65

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr @res, i64 %11
  %24 = call i32 @mbedtls_ccm_auth_decrypt(ptr noundef nonnull %2, i64 noundef %11, ptr noundef nonnull @iv, i64 noundef %12, ptr noundef nonnull @ad, i64 noundef %13, ptr noundef nonnull @res, ptr noundef nonnull %3, ptr noundef nonnull %23, i64 noundef %15)
  %.not33 = icmp eq i32 %24, 0
  br i1 %.not33, label %25, label %26

25:                                               ; preds = %22
  %bcmp34 = call i32 @bcmp(ptr nonnull %3, ptr nonnull @msg, i64 %11)
  %.not35 = icmp eq i32 %bcmp34, 0
  br i1 %.not35, label %29, label %26

26:                                               ; preds = %60, %57, %44, %41, %25, %22
  br i1 %.not30, label %65, label %27

27:                                               ; preds = %26
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %65

29:                                               ; preds = %25
  br i1 %.not30, label %.thread, label %30

30:                                               ; preds = %29
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 2)
  br label %.thread

.thread:                                          ; preds = %29, %30
  %33 = load i64, ptr getelementptr inbounds (i8, ptr @msg_len, i64 8), align 8, !tbaa !5
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @iv_len, i64 8), align 8, !tbaa !5
  %35 = load i64, ptr getelementptr inbounds (i8, ptr @add_len, i64 8), align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %3, i64 %33
  %37 = load i64, ptr getelementptr inbounds (i8, ptr @tag_len, i64 8), align 8, !tbaa !5
  %38 = call i32 @mbedtls_ccm_encrypt_and_tag(ptr noundef nonnull %2, i64 noundef %33, ptr noundef nonnull @iv, i64 noundef %34, ptr noundef nonnull @ad, i64 noundef %35, ptr noundef nonnull @msg, ptr noundef nonnull %3, ptr noundef nonnull %36, i64 noundef %37)
  %.not31.1 = icmp eq i32 %38, 0
  br i1 %.not31.1, label %39, label %19

39:                                               ; preds = %.thread
  %40 = add i64 %37, %33
  %bcmp.1 = call i32 @bcmp(ptr nonnull %3, ptr nonnull getelementptr inbounds (i8, ptr @res, i64 32), i64 %40)
  %.not32.1 = icmp eq i32 %bcmp.1, 0
  br i1 %.not32.1, label %41, label %19

41:                                               ; preds = %39
  %42 = getelementptr inbounds i8, ptr getelementptr inbounds (i8, ptr @res, i64 32), i64 %33
  %43 = call i32 @mbedtls_ccm_auth_decrypt(ptr noundef nonnull %2, i64 noundef %33, ptr noundef nonnull @iv, i64 noundef %34, ptr noundef nonnull @ad, i64 noundef %35, ptr noundef nonnull getelementptr inbounds (i8, ptr @res, i64 32), ptr noundef nonnull %3, ptr noundef nonnull %42, i64 noundef %37)
  %.not33.1 = icmp eq i32 %43, 0
  br i1 %.not33.1, label %44, label %26

44:                                               ; preds = %41
  %bcmp34.1 = call i32 @bcmp(ptr nonnull %3, ptr nonnull @msg, i64 %33)
  %.not35.1 = icmp eq i32 %bcmp34.1, 0
  br i1 %.not35.1, label %45, label %26

45:                                               ; preds = %44
  br i1 %.not30, label %.thread39, label %46

46:                                               ; preds = %45
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 3)
  br label %.thread39

.thread39:                                        ; preds = %45, %46
  %49 = load i64, ptr getelementptr inbounds (i8, ptr @msg_len, i64 16), align 16, !tbaa !5
  %50 = load i64, ptr getelementptr inbounds (i8, ptr @iv_len, i64 16), align 16, !tbaa !5
  %51 = load i64, ptr getelementptr inbounds (i8, ptr @add_len, i64 16), align 16, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %3, i64 %49
  %53 = load i64, ptr getelementptr inbounds (i8, ptr @tag_len, i64 16), align 16, !tbaa !5
  %54 = call i32 @mbedtls_ccm_encrypt_and_tag(ptr noundef nonnull %2, i64 noundef %49, ptr noundef nonnull @iv, i64 noundef %50, ptr noundef nonnull @ad, i64 noundef %51, ptr noundef nonnull @msg, ptr noundef nonnull %3, ptr noundef nonnull %52, i64 noundef %53)
  %.not31.2 = icmp eq i32 %54, 0
  br i1 %.not31.2, label %55, label %19

55:                                               ; preds = %.thread39
  %56 = add i64 %53, %49
  %bcmp.2 = call i32 @bcmp(ptr nonnull %3, ptr nonnull getelementptr inbounds (i8, ptr @res, i64 64), i64 %56)
  %.not32.2 = icmp eq i32 %bcmp.2, 0
  br i1 %.not32.2, label %57, label %19

57:                                               ; preds = %55
  %58 = getelementptr inbounds i8, ptr getelementptr inbounds (i8, ptr @res, i64 64), i64 %49
  %59 = call i32 @mbedtls_ccm_auth_decrypt(ptr noundef nonnull %2, i64 noundef %49, ptr noundef nonnull @iv, i64 noundef %50, ptr noundef nonnull @ad, i64 noundef %51, ptr noundef nonnull getelementptr inbounds (i8, ptr @res, i64 64), ptr noundef nonnull %3, ptr noundef nonnull %58, i64 noundef %53)
  %.not33.2 = icmp eq i32 %59, 0
  br i1 %.not33.2, label %60, label %26

60:                                               ; preds = %57
  %bcmp34.2 = call i32 @bcmp(ptr nonnull %3, ptr nonnull @msg, i64 %49)
  %.not35.2 = icmp eq i32 %bcmp34.2, 0
  br i1 %.not35.2, label %61, label %26

61:                                               ; preds = %60
  br i1 %.not30, label %.thread40, label %62

.thread40:                                        ; preds = %61
  call void @mbedtls_ccm_free(ptr noundef nonnull %2)
  br label %65

62:                                               ; preds = %61
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  call void @mbedtls_ccm_free(ptr noundef nonnull %2)
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %65

65:                                               ; preds = %.thread40, %62, %26, %27, %19, %20, %5, %6
  %.028 = phi i32 [ 1, %6 ], [ 1, %5 ], [ 1, %20 ], [ 1, %19 ], [ 1, %27 ], [ 1, %26 ], [ 0, %62 ], [ 0, %.thread40 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %2) #4
  ret i32 %.028
}

; 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass