; LLVM IR from peacemakr-io/peacemakr-core-crypto :: src/core/src (CiphertextBlob)

; 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.crypto_config_t = type { i32, i32, i32, i32 }
%struct.CiphertextBlob = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }

@peacemakr_global_malloc = external global ptr, align 8
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@__FUNCTION__.ciphertext_blob_from_buffers = external hidden unnamed_addr constant [29 x i8], align 1

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

declare void @log_printf(ptr noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ciphertext_blob_from_buffers(i64 %0, i64 %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %9 = alloca ptr, align 8
  %10 = alloca %struct.crypto_config_t, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  store i64 %0, ptr %19, align 4
  %20 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  store i64 %1, ptr %20, align 4
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %21 = load ptr, ptr @peacemakr_global_malloc, align 8, !tbaa !5
  %22 = call ptr %21(i64 noundef 72)
  store ptr %22, ptr %17, align 8, !tbaa !5
  %23 = load ptr, ptr %17, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %8
  call void (ptr, i32, ptr, ...) @log_printf(ptr noundef @__FUNCTION__.ciphertext_blob_from_buffers, i32 noundef 115, ptr noundef @.str)
  store ptr null, ptr %9, align 8
  store i32 1, ptr %18, align 4
  br label %74

26:                                               ; preds = %8
  %27 = load ptr, ptr %17, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.CiphertextBlob, ptr %27, i32 0, i32 0
  store i32 1, ptr %28, align 8, !tbaa !9
  %29 = load ptr, ptr %17, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.CiphertextBlob, ptr %29, i32 0, i32 5
  store ptr null, ptr %30, align 8, !tbaa !12
  %31 = getelementptr inbounds %struct.crypto_config_t, ptr %10, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = load ptr, ptr %17, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.CiphertextBlob, ptr %33, i32 0, i32 1
  store i32 %32, ptr %34, align 4, !tbaa !15
  %35 = getelementptr inbounds %struct.crypto_config_t, ptr %10, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !16
  %37 = load ptr, ptr %17, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.CiphertextBlob, ptr %37, i32 0, i32 2
  store i32 %36, ptr %38, align 8, !tbaa !17
  %39 = getelementptr inbounds %struct.crypto_config_t, ptr %10, i32 0, i32 2
  %40 = load i32, ptr %39, align 4, !tbaa !18
  %41 = load ptr, ptr %17, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.CiphertextBlob, ptr %41, i32 0, i32 3
  store i32 %40, ptr %42, align 4, !tbaa !19
  %43 = getelementptr inbounds %struct.crypto_config_t, ptr %10, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !20
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.CiphertextBlob, ptr %45, i32 0, i32 4
  store i32 %44, ptr %46, align 8, !tbaa !21
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = call i64 @buffer_get_size(ptr noundef %47)
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %54

50:                                               ; preds = %26
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %17, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.CiphertextBlob, ptr %52, i32 0, i32 5
  store ptr %51, ptr %53, align 8, !tbaa !12
  br label %57

54:                                               ; preds = %26
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.CiphertextBlob, ptr %55, i32 0, i32 5
  store ptr null, ptr %56, align 8, !tbaa !12
  br label %57

57:                                               ; preds = %54, %50
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.CiphertextBlob, ptr %59, i32 0, i32 6
  store ptr %58, ptr %60, align 8, !tbaa !22
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.CiphertextBlob, ptr %62, i32 0, i32 7
  store ptr %61, ptr %63, align 8, !tbaa !23
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.CiphertextBlob, ptr %65, i32 0, i32 8
  store ptr %64, ptr %66, align 8, !tbaa !24
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.CiphertextBlob, ptr %68, i32 0, i32 9
  store ptr %67, ptr %69, align 8, !tbaa !25
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.CiphertextBlob, ptr %71, i32 0, i32 10
  store ptr %70, ptr %72, align 8, !tbaa !26
  %73 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %73, ptr %9, align 8
  store i32 1, ptr %18, align 4
  br label %74

74:                                               ; preds = %57, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  %75 = load ptr, ptr %9, align 8
  ret ptr %75
}

declare i64 @buffer_get_size(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 }

!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, !11, i64 0}
!10 = !{!"CiphertextBlob", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!14, !11, i64 0}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!15 = !{!10, !11, i64 4}
!16 = !{!14, !11, i64 4}
!17 = !{!10, !11, i64 8}
!18 = !{!14, !11, i64 8}
!19 = !{!10, !11, i64 12}
!20 = !{!14, !11, i64 12}
!21 = !{!10, !11, i64 16}
!22 = !{!10, !6, i64 32}
!23 = !{!10, !6, i64 40}
!24 = !{!10, !6, i64 48}
!25 = !{!10, !6, i64 56}
!26 = !{!10, !6, i64 64}


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

@peacemakr_global_malloc = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@__FUNCTION__.ciphertext_blob_from_buffers = external hidden unnamed_addr constant [29 x i8], align 1

declare void @log_printf(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @ciphertext_blob_from_buffers(i64 %0, i64 %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = load ptr, ptr @peacemakr_global_malloc, align 8, !tbaa !5
  %10 = tail call ptr %9(i64 noundef 72) #2
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  tail call void (ptr, i32, ptr, ...) @log_printf(ptr noundef nonnull @__FUNCTION__.ciphertext_blob_from_buffers, i32 noundef 115, ptr noundef nonnull @.str) #2
  br label %25

13:                                               ; preds = %8
  %.sroa.5.8.extract.shift = lshr i64 %1, 32
  %.sroa.5.8.extract.trunc = trunc nuw i64 %.sroa.5.8.extract.shift to i32
  %.sroa.3.8.extract.trunc = trunc i64 %1 to i32
  %.sroa.2.0.extract.shift = lshr i64 %0, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %0 to i32
  store i32 1, ptr %10, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %10, i64 24
  store ptr null, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 %.sroa.0.0.extract.trunc, ptr %15, align 4, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %10, i64 8
  store i32 %.sroa.2.0.extract.trunc, ptr %16, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %10, i64 12
  store i32 %.sroa.3.8.extract.trunc, ptr %17, align 4, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %10, i64 16
  store i32 %.sroa.5.8.extract.trunc, ptr %18, align 8, !tbaa !16
  %19 = tail call i64 @buffer_get_size(ptr noundef %2) #2
  %.not = icmp eq i64 %19, 0
  %. = select i1 %.not, ptr null, ptr %2
  store ptr %., ptr %14, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %10, i64 32
  store ptr %3, ptr %20, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %10, i64 40
  store ptr %4, ptr %21, align 8, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %10, i64 48
  store ptr %5, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %10, i64 56
  store ptr %6, ptr %23, align 8, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %10, i64 64
  store ptr %7, ptr %24, align 8, !tbaa !21
  br label %25

25:                                               ; preds = %13, %12
  ret ptr %10
}

declare i64 @buffer_get_size(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"CiphertextBlob", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !6, i64 32}
!18 = !{!10, !6, i64 40}
!19 = !{!10, !6, i64 48}
!20 = !{!10, !6, i64 56}
!21 = !{!10, !6, i64 64}


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