; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 30. CPP Programs (elliptic_curve_key_exchange)

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

%class.uint256_t = type { %class.uint128_t, %class.uint128_t }
%class.uint128_t = type { i64, i64 }

; 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: mustprogress uwtable
define dso_local void @_ZN7ciphers27elliptic_curve_key_exchange3expE9uint256_tS1_RKS1_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %class.uint256_t, align 8
  %10 = alloca %class.uint256_t, align 8
  %11 = alloca i32, align 4
  %12 = alloca %class.uint256_t, align 8
  %13 = alloca %class.uint256_t, align 8
  %14 = alloca i32, align 4
  %15 = alloca %class.uint256_t, align 8
  %16 = alloca %class.uint256_t, align 8
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZN9uint256_tntEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %17, label %18, label %19

18:                                               ; preds = %4
  call void @_ZN9uint256_tC2IiiEET_(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  br label %34

19:                                               ; preds = %4
  call void @_ZN9uint256_tC2IiiEET_(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #4
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %20)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %9, i64 32, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #4
  br label %21

21:                                               ; preds = %32, %19
  %22 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %22, label %23, label %33

23:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !12
  call void @_ZN9uint256_tanIiiEES_RKT_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %10, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %24 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #4
  br i1 %24, label %25, label %27

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #4
  call void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %13, ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %12, ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef nonnull align 8 dereferenceable(32) %26)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %12, i64 32, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  br label %27

27:                                               ; preds = %25, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !12
  %28 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN9uint256_trSIiiEERS_RKT_(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %29 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %16) #4
  call void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %16, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind writable sret(%class.uint256_t) align 8 %15, ptr noundef nonnull align 8 dereferenceable(32) %16, ptr noundef nonnull align 8 dereferenceable(32) %31)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %15, i64 32, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 32, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #4
  br label %32

32:                                               ; preds = %30, %27
  br label %21, !llvm.loop !14

33:                                               ; preds = %21
  br label %34

34:                                               ; preds = %33, %18
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9uint256_tntEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9uint256_tC2IiiEET_(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9uint256_trmERKS_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9uint256_tanIiiEES_RKT_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN9uint256_trSIiiEERS_RKT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{i64 0, i64 8, !10, i64 8, i64 8, !10, i64 16, i64 8, !10, i64 24, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%class.uint256_t = type { %class.uint128_t, %class.uint128_t }
%class.uint128_t = type { i64, i64 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ciphers27elliptic_curve_key_exchange3expE9uint256_tS1_RKS1_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8 %0, ptr noundef %1, ptr noundef nonnull %2, ptr noundef nonnull align 8 dereferenceable(32) %3) local_unnamed_addr #1 {
  %5 = alloca %class.uint256_t, align 8
  %6 = alloca %class.uint256_t, align 8
  %7 = alloca i32, align 4
  %8 = alloca %class.uint256_t, align 8
  %9 = alloca %class.uint256_t, align 8
  %10 = alloca i32, align 4
  %11 = alloca %class.uint256_t, align 8
  %12 = alloca %class.uint256_t, align 8
  %13 = tail call noundef zeroext i1 @_ZN9uint256_tntEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  tail call void @_ZN9uint256_tC2IiiEET_(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #4
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %3)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %5, i64 32, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #4
  %15 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %15, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %14, %22
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store i32 1, ptr %7, align 4, !tbaa !10
  call void @_ZN9uint256_tanIiiEES_RKT_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %6, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %16 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  br i1 %16, label %17, label %18

17:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #4
  call void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1)
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(32) %3)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %8, i64 32, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #4
  br label %18

18:                                               ; preds = %17, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  store i32 1, ptr %10, align 4, !tbaa !10
  %19 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN9uint256_trSIiiEERS_RKT_(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  %20 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %11) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %12) #4
  call void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %12, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %1)
  call void @_ZN9uint256_trmERKS_(ptr dead_on_unwind nonnull writable sret(%class.uint256_t) align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %3)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %11, i64 32, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %11) #4
  br label %22

22:                                               ; preds = %21, %18
  %23 = call noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  br i1 %23, label %.lr.ph, label %.loopexit, !llvm.loop !12

.loopexit:                                        ; preds = %22, %4, %14
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9uint256_tntEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9uint256_tC2IiiEET_(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9uint256_trmERKS_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK9uint256_tcvbEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9uint256_tanIiiEES_RKT_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9uint256_tmlERKS_(ptr dead_on_unwind noalias writable sret(%class.uint256_t) align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN9uint256_trSIiiEERS_RKT_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6, i64 16, i64 8, !6, i64 24, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass