; LLVM IR from intel/cryptography-primitives :: sources/ippcp/gfpec (pcpgfpecsetpointoctstring)

; 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.IppsGFpInfo = type { i32, i32, i32 }
%struct._cpGFpElement = type { i32, i32, ptr }
%struct._cpGFpEC = type { i32, i32, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._cpGFp = type { i32, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsGFpECSetPointOctString(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.IppsGFpInfo, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct._cpGFpElement, align 8
  %18 = alloca %struct._cpGFpElement, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp eq ptr null, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %4
  store i32 -8, ptr %5, align 4
  br label %106

22:                                               ; preds = %4
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp eq ptr null, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 -8, ptr %5, align 4
  br label %106

26:                                               ; preds = %22
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp eq ptr null, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 -8, ptr %5, align 4
  br label %106

30:                                               ; preds = %26
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._cpGFpEC, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call i64 @IPP_UINT_PTR(ptr noundef %34)
  %36 = trunc i64 %35 to i32
  %37 = xor i32 %33, %36
  %38 = icmp eq i32 %37, 1129136461
  br i1 %38, label %40, label %39

39:                                               ; preds = %30
  store i32 -13, ptr %5, align 4
  br label %106

40:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._cpGFpEC, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds %struct._cpGFp, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  store ptr %45, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #4
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._cpGFpEC, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = call i32 @ippsGFpGetInfo(ptr noundef %11, ptr noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %50 = getelementptr inbounds %struct.IppsGFpInfo, ptr %11, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !16
  %52 = getelementptr inbounds %struct.IppsGFpInfo, ptr %11, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !18
  %54 = mul nsw i32 %51, %53
  store i32 %54, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = add nsw i32 %55, 7
  %57 = ashr i32 %56, 3
  store i32 %57, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = add nsw i32 %58, 64
  %60 = sub nsw i32 %59, 1
  %61 = sdiv i32 %60, 64
  store i32 %61, ptr %14, align 4, !tbaa !9
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load i32, ptr %13, align 4, !tbaa !9
  %64 = mul nsw i32 %63, 2
  %65 = icmp ne i32 %62, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %40
  store i32 -6, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %105

67:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = call ptr @gsModPoolAlloc(ptr noundef %68, i32 noundef 1)
  %70 = load i32, ptr %14, align 4, !tbaa !9
  %71 = call ptr @cpGFpElementConstruct(ptr noundef %17, ptr noundef %69, i32 noundef %70)
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = call ptr @gsModPoolAlloc(ptr noundef %72, i32 noundef 1)
  %74 = load i32, ptr %14, align 4, !tbaa !9
  %75 = call ptr @cpGFpElementConstruct(ptr noundef %18, ptr noundef %73, i32 noundef %74)
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._cpGFpEC, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !13
  %81 = call i32 @ippsGFpSetElementOctString(ptr noundef %76, i32 noundef %77, ptr noundef %17, ptr noundef %80)
  store i32 %81, ptr %16, align 4, !tbaa !9
  %82 = load i32, ptr %16, align 4, !tbaa !9
  %83 = icmp eq i32 0, %82
  br i1 %83, label %84, label %95

84:                                               ; preds = %67
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = sext i32 %85 to i64
  %88 = getelementptr inbounds i8, ptr %86, i64 %87
  store ptr %88, ptr %6, align 8, !tbaa !5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %13, align 4, !tbaa !9
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._cpGFpEC, ptr %91, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !13
  %94 = call i32 @ippsGFpSetElementOctString(ptr noundef %89, i32 noundef %90, ptr noundef %18, ptr noundef %93)
  store i32 %94, ptr %16, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %84, %67
  %96 = load i32, ptr %16, align 4, !tbaa !9
  %97 = icmp eq i32 0, %96
  br i1 %97, label %98, label %102

98:                                               ; preds = %95
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = call i32 @ippsGFpECSetPoint(ptr noundef %17, ptr noundef %18, ptr noundef %99, ptr noundef %100)
  store i32 %101, ptr %16, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %98, %95
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  call void @gsModPoolFree(ptr noundef %103, i32 noundef 2)
  %104 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %104, ptr %5, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %105

105:                                              ; preds = %102, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %106

106:                                              ; preds = %105, %39, %29, %25, %21
  %107 = load i32, ptr %5, align 4
  ret i32 %107
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) #1

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

declare i32 @ippsGFpGetInfo(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementConstruct(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @gsModPoolAlloc(ptr noundef, i32 noundef) #1

declare i32 @ippsGFpSetElementOctString(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #3

declare i32 @ippsGFpECSetPoint(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gsModPoolFree(ptr noundef, i32 noundef) #1

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

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_cpGFpEC", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !6, i64 8}
!15 = !{!"_cpGFp", !10, i64 0, !10, i64 4, !6, i64 8}
!16 = !{!17, !10, i64 4}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!18 = !{!17, !10, i64 8}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsGFpECSetPointOctString(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.IppsGFpInfo, align 4
  %6 = alloca %struct._cpGFpElement, align 8
  %7 = alloca %struct._cpGFpElement, align 8
  %8 = icmp eq ptr %2, null
  %9 = icmp eq ptr %3, null
  %or.cond = or i1 %8, %9
  %10 = icmp eq ptr %0, null
  %or.cond35 = or i1 %10, %or.cond
  br i1 %or.cond35, label %50, label %11

11:                                               ; preds = %4
  %12 = load i32, ptr %3, align 8, !tbaa !5
  %13 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %3)
  %14 = trunc i64 %13 to i32
  %15 = xor i32 %12, %14
  %16 = icmp eq i32 %15, 1129136461
  br i1 %16, label %17, label %50

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %22 = call i32 @ippsGFpGetInfo(ptr noundef nonnull %5, ptr noundef %19) #4
  %23 = getelementptr inbounds i8, ptr %5, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %5, i64 8
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = mul nsw i32 %26, %24
  %28 = add nsw i32 %27, 7
  %29 = ashr i32 %28, 3
  %30 = shl nsw i32 %29, 1
  %.not = icmp eq i32 %30, %1
  br i1 %.not, label %31, label %49

31:                                               ; preds = %17
  %32 = add nsw i32 %27, 63
  %33 = sdiv i32 %32, 64
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %34 = call ptr @gsModPoolAlloc(ptr noundef %21, i32 noundef 1)
  %35 = call ptr @cpGFpElementConstruct(ptr noundef nonnull %6, ptr noundef %34, i32 noundef %33)
  %36 = call ptr @gsModPoolAlloc(ptr noundef %21, i32 noundef 1)
  %37 = call ptr @cpGFpElementConstruct(ptr noundef nonnull %7, ptr noundef %36, i32 noundef %33)
  %38 = load ptr, ptr %18, align 8, !tbaa !11
  %39 = call i32 @ippsGFpSetElementOctString(ptr noundef nonnull %0, i32 noundef %29, ptr noundef nonnull %6, ptr noundef %38) #4
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %.thread

41:                                               ; preds = %31
  %42 = sext i32 %29 to i64
  %43 = getelementptr inbounds i8, ptr %0, i64 %42
  %44 = load ptr, ptr %18, align 8, !tbaa !11
  %45 = call i32 @ippsGFpSetElementOctString(ptr noundef nonnull %43, i32 noundef %29, ptr noundef nonnull %7, ptr noundef %44) #4
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %.thread

47:                                               ; preds = %41
  %48 = call i32 @ippsGFpECSetPoint(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %2, ptr noundef nonnull %3) #4
  br label %.thread

.thread:                                          ; preds = %31, %47, %41
  %.1 = phi i32 [ %48, %47 ], [ %45, %41 ], [ %39, %31 ]
  call void @gsModPoolFree(ptr noundef %21, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %49

49:                                               ; preds = %17, %.thread
  %.029 = phi i32 [ %.1, %.thread ], [ -6, %17 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  br label %50

50:                                               ; preds = %11, %4, %49
  %.130 = phi i32 [ %.029, %49 ], [ -8, %4 ], [ -13, %11 ]
  ret i32 %.130
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) local_unnamed_addr #1

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

declare i32 @ippsGFpGetInfo(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementConstruct(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @gsModPoolAlloc(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @ippsGFpSetElementOctString(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @ippsGFpECSetPoint(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gsModPoolFree(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

!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, !7, i64 0}
!6 = !{!"_cpGFpEC", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !10, i64 8}
!13 = !{!"_cpGFp", !7, i64 0, !7, i64 4, !10, i64 8}
!14 = !{!15, !7, i64 4}
!15 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!16 = !{!15, !7, i64 8}


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