; LLVM IR from aws/s2n-tls :: tests/unit (s2n_self_talk_session_id_test)

; 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.session_cache_entry = type { [32 x i8], i8, [255 x i8], i8, i8 }

; 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: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @cache_delete_callback(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = load i64, ptr %9, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %19, label %16

16:                                               ; preds = %4
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = icmp ugt i64 %17, 32
  br i1 %18, label %19, label %20

19:                                               ; preds = %16, %4
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %68

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 0
  %23 = load i8, ptr %22, align 1, !tbaa !11
  store i8 %23, ptr %12, align 1, !tbaa !11
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i8, ptr %12, align 1, !tbaa !11
  %26 = zext i8 %25 to i64
  %27 = getelementptr inbounds %struct.session_cache_entry, ptr %24, i64 %26
  %28 = getelementptr inbounds %struct.session_cache_entry, ptr %27, i32 0, i32 1
  %29 = load i8, ptr %28, align 1, !tbaa !12
  %30 = zext i8 %29 to i32
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %20
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

33:                                               ; preds = %20
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load i8, ptr %12, align 1, !tbaa !11
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds %struct.session_cache_entry, ptr %34, i64 %36
  %38 = getelementptr inbounds %struct.session_cache_entry, ptr %37, i32 0, i32 1
  %39 = load i8, ptr %38, align 1, !tbaa !12
  %40 = zext i8 %39 to i64
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = icmp ne i64 %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %33
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

44:                                               ; preds = %33
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = load i8, ptr %12, align 1, !tbaa !11
  %47 = zext i8 %46 to i64
  %48 = getelementptr inbounds %struct.session_cache_entry, ptr %45, i64 %47
  %49 = getelementptr inbounds %struct.session_cache_entry, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds [32 x i8], ptr %49, i64 0, i64 0
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %9, align 8, !tbaa !9
  %53 = call i32 @memcmp(ptr noundef %50, ptr noundef %51, i64 noundef %52) #4
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %44
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

56:                                               ; preds = %44
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load i8, ptr %12, align 1, !tbaa !11
  %59 = zext i8 %58 to i64
  %60 = getelementptr inbounds %struct.session_cache_entry, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct.session_cache_entry, ptr %60, i32 0, i32 1
  store i8 0, ptr %61, align 1, !tbaa !12
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load i8, ptr %12, align 1, !tbaa !11
  %64 = zext i8 %63 to i64
  %65 = getelementptr inbounds %struct.session_cache_entry, ptr %62, i64 %64
  %66 = getelementptr inbounds %struct.session_cache_entry, ptr %65, i32 0, i32 3
  store i8 0, ptr %66, align 1, !tbaa !14
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %67

67:                                               ; preds = %56, %55, %43, %32
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  br label %68

68:                                               ; preds = %67, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %69 = load i32, ptr %5, align 4
  ret i32 %69
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 }
attributes #4 = { 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 = !{!"any pointer", !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 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 32}
!13 = !{!"session_cache_entry", !7, i64 0, !7, i64 32, !7, i64 33, !7, i64 288, !7, i64 289}
!14 = !{!13, !7, i64 288}


; 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.session_cache_entry = type { [32 x i8], i8, [255 x i8], i8, i8 }

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local range(i32 -1, 1) i32 @cache_delete_callback(ptr nocapture noundef readnone %0, ptr nocapture noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = add i64 %3, -33
  %or.cond = icmp ult i64 %5, -32
  br i1 %or.cond, label %18, label %6

6:                                                ; preds = %4
  %7 = load i8, ptr %2, align 1, !tbaa !5
  %8 = zext i8 %7 to i64
  %9 = getelementptr inbounds %struct.session_cache_entry, ptr %1, i64 %8
  %10 = getelementptr inbounds i8, ptr %9, i64 32
  %11 = load i8, ptr %10, align 1, !tbaa !8
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %18, label %13

13:                                               ; preds = %6
  %14 = zext i8 %11 to i64
  %.not = icmp eq i64 %14, %3
  br i1 %.not, label %15, label %18

15:                                               ; preds = %13
  %bcmp = tail call i32 @bcmp(ptr nonnull %9, ptr nonnull %2, i64 %3)
  %.not19 = icmp eq i32 %bcmp, 0
  br i1 %.not19, label %16, label %18

16:                                               ; preds = %15
  store i8 0, ptr %10, align 1, !tbaa !8
  %17 = getelementptr inbounds i8, ptr %9, i64 288
  store i8 0, ptr %17, align 1, !tbaa !10
  br label %18

18:                                               ; preds = %16, %6, %13, %15, %4
  %.1 = phi i32 [ -1, %4 ], [ 0, %16 ], [ 0, %6 ], [ -1, %13 ], [ -1, %15 ]
  ret i32 %.1
}

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

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) 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 = { nofree nounwind willreturn memory(argmem: 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 32}
!9 = !{!"session_cache_entry", !6, i64 0, !6, i64 32, !6, i64 33, !6, i64 288, !6, i64 289}
!10 = !{!9, !6, i64 288}


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