; LLVM IR from dynexcoin/Dynex :: src/crypto (crypto-ops)

; 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.ge_cached = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }
%struct.ge_p1p1 = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }
%struct.ge_p3 = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }

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

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

; Function Attrs: nounwind uwtable
declare hidden void @slide(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @ge_p2_0(ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @ge_double_scalarmult_precomp_vartime(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [256 x i8], align 16
  %12 = alloca [256 x i8], align 16
  %13 = alloca [8 x %struct.ge_cached], align 16
  %14 = alloca %struct.ge_p1p1, align 4
  %15 = alloca %struct.ge_p3, align 4
  %16 = alloca i32, align 4
  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 ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 256, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 1280, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 160, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 160, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %17 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @slide(ptr noundef %17, ptr noundef %18)
  %19 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  call void @slide(ptr noundef %19, ptr noundef %20)
  %21 = getelementptr inbounds [8 x %struct.ge_cached], ptr %13, i64 0, i64 0
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ge_dsm_precomp(ptr noundef %21, ptr noundef %22)
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ge_p2_0(ptr noundef %23)
  store i32 255, ptr %16, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %43, %5
  %25 = load i32, ptr %16, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 0
  br i1 %26, label %27, label %46

27:                                               ; preds = %24
  %28 = load i32, ptr %16, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %41, label %34

34:                                               ; preds = %27
  %35 = load i32, ptr %16, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %34, %27
  br label %46

42:                                               ; preds = %34
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %16, align 4, !tbaa !9
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr %16, align 4, !tbaa !9
  br label %24, !llvm.loop !12

46:                                               ; preds = %41, %24
  br label %47

47:                                               ; preds = %123, %46
  %48 = load i32, ptr %16, align 4, !tbaa !9
  %49 = icmp sge i32 %48, 0
  br i1 %49, label %50, label %126

50:                                               ; preds = %47
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ge_p2_dbl(ptr noundef %14, ptr noundef %51)
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = sext i8 %55 to i32
  %57 = icmp sgt i32 %56, 0
  br i1 %57, label %58, label %67

58:                                               ; preds = %50
  call void @ge_p1p1_to_p3(ptr noundef %15, ptr noundef %14)
  %59 = load i32, ptr %16, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !11
  %63 = sext i8 %62 to i32
  %64 = sdiv i32 %63, 2
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [8 x %struct.ge_cached], ptr %13, i64 0, i64 %65
  call void @ge_add(ptr noundef %14, ptr noundef %15, ptr noundef %66)
  br label %85

67:                                               ; preds = %50
  %68 = load i32, ptr %16, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = sext i8 %71 to i32
  %73 = icmp slt i32 %72, 0
  br i1 %73, label %74, label %84

74:                                               ; preds = %67
  call void @ge_p1p1_to_p3(ptr noundef %15, ptr noundef %14)
  %75 = load i32, ptr %16, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !11
  %79 = sext i8 %78 to i32
  %80 = sub nsw i32 0, %79
  %81 = sdiv i32 %80, 2
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [8 x %struct.ge_cached], ptr %13, i64 0, i64 %82
  call void @ge_sub(ptr noundef %14, ptr noundef %15, ptr noundef %83)
  br label %84

84:                                               ; preds = %74, %67
  br label %85

85:                                               ; preds = %84, %58
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !11
  %90 = sext i8 %89 to i32
  %91 = icmp sgt i32 %90, 0
  br i1 %91, label %92, label %102

92:                                               ; preds = %85
  call void @ge_p1p1_to_p3(ptr noundef %15, ptr noundef %14)
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 %95
  %97 = load i8, ptr %96, align 1, !tbaa !11
  %98 = sext i8 %97 to i32
  %99 = sdiv i32 %98, 2
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %struct.ge_cached, ptr %93, i64 %100
  call void @ge_add(ptr noundef %14, ptr noundef %15, ptr noundef %101)
  br label %121

102:                                              ; preds = %85
  %103 = load i32, ptr %16, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !11
  %107 = sext i8 %106 to i32
  %108 = icmp slt i32 %107, 0
  br i1 %108, label %109, label %120

109:                                              ; preds = %102
  call void @ge_p1p1_to_p3(ptr noundef %15, ptr noundef %14)
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = load i32, ptr %16, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 %112
  %114 = load i8, ptr %113, align 1, !tbaa !11
  %115 = sext i8 %114 to i32
  %116 = sub nsw i32 0, %115
  %117 = sdiv i32 %116, 2
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds %struct.ge_cached, ptr %110, i64 %118
  call void @ge_sub(ptr noundef %14, ptr noundef %15, ptr noundef %119)
  br label %120

120:                                              ; preds = %109, %102
  br label %121

121:                                              ; preds = %120, %92
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ge_p1p1_to_p2(ptr noundef %122, ptr noundef %14)
  br label %123

123:                                              ; preds = %121
  %124 = load i32, ptr %16, align 4, !tbaa !9
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr %16, align 4, !tbaa !9
  br label %47, !llvm.loop !14

126:                                              ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 160, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 160, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 1280, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr %11) #2
  ret void
}

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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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.ge_cached = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }
%struct.ge_p1p1 = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }
%struct.ge_p3 = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }

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

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

; Function Attrs: nounwind uwtable
declare hidden void @slide(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @ge_double_scalarmult_precomp_vartime(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca [256 x i8], align 16
  %7 = alloca [256 x i8], align 16
  %8 = alloca [8 x %struct.ge_cached], align 16
  %9 = alloca %struct.ge_p1p1, align 4
  %10 = alloca %struct.ge_p3, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %7) #2
  call void @llvm.lifetime.start.p0(i64 1280, ptr nonnull %8) #2
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %9) #2
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %10) #2
  call void @slide(ptr noundef nonnull %6, ptr noundef %1)
  call void @slide(ptr noundef nonnull %7, ptr noundef %3)
  call void @ge_dsm_precomp(ptr noundef nonnull %8, ptr noundef %2)
  call void @ge_p2_0(ptr noundef %0)
  br label %11

11:                                               ; preds = %26, %5
  %.024 = phi i32 [ 255, %5 ], [ %27, %26 ]
  %12 = zext nneg i32 %.024 to i64
  %13 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not = icmp eq i8 %14, 0
  br i1 %.not, label %15, label %28

15:                                               ; preds = %11
  %16 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 %12
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %.not23 = icmp eq i8 %17, 0
  br i1 %.not23, label %18, label %28

18:                                               ; preds = %15
  %19 = add nsw i32 %.024, -1
  %20 = zext nneg i32 %19 to i64
  %21 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %.not.1 = icmp eq i8 %22, 0
  br i1 %.not.1, label %23, label %28

23:                                               ; preds = %18
  %24 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 %20
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %.not23.1 = icmp eq i8 %25, 0
  br i1 %.not23.1, label %26, label %28

26:                                               ; preds = %23
  %27 = add nsw i32 %.024, -2
  %.not27.1 = icmp eq i32 %19, 0
  br i1 %.not27.1, label %._crit_edge, label %11, !llvm.loop !8

28:                                               ; preds = %23, %18, %11, %15
  %.024.lcssa = phi i32 [ %.024, %11 ], [ %.024, %15 ], [ %19, %18 ], [ %19, %23 ]
  %29 = icmp sgt i32 %.024.lcssa, -1
  br i1 %29, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %28
  %30 = zext nneg i32 %.024.lcssa to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %62
  %indvars.iv = phi i64 [ %30, %.lr.ph.preheader ], [ %indvars.iv.next, %62 ]
  call void @ge_p2_dbl(ptr noundef nonnull %9, ptr noundef %0)
  %31 = getelementptr inbounds [256 x i8], ptr %6, i64 0, i64 %indvars.iv
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = icmp sgt i8 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %.lr.ph
  call void @ge_p1p1_to_p3(ptr noundef nonnull %10, ptr noundef nonnull %9)
  %35 = load i8, ptr %31, align 1, !tbaa !5
  %36 = sdiv i8 %35, 2
  %37 = sext i8 %36 to i64
  %38 = getelementptr inbounds [8 x %struct.ge_cached], ptr %8, i64 0, i64 %37
  call void @ge_add(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %38)
  br label %46

39:                                               ; preds = %.lr.ph
  %40 = icmp slt i8 %32, 0
  br i1 %40, label %41, label %46

41:                                               ; preds = %39
  call void @ge_p1p1_to_p3(ptr noundef nonnull %10, ptr noundef nonnull %9)
  %42 = load i8, ptr %31, align 1, !tbaa !5
  %43 = sdiv i8 %42, -2
  %44 = sext i8 %43 to i64
  %45 = getelementptr inbounds [8 x %struct.ge_cached], ptr %8, i64 0, i64 %44
  call void @ge_sub(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %45)
  br label %46

46:                                               ; preds = %39, %41, %34
  %47 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 %indvars.iv
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = icmp sgt i8 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %46
  call void @ge_p1p1_to_p3(ptr noundef nonnull %10, ptr noundef nonnull %9)
  %51 = load i8, ptr %47, align 1, !tbaa !5
  %52 = sdiv i8 %51, 2
  %53 = sext i8 %52 to i64
  %54 = getelementptr inbounds %struct.ge_cached, ptr %4, i64 %53
  call void @ge_add(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef %54)
  br label %62

55:                                               ; preds = %46
  %56 = icmp slt i8 %48, 0
  br i1 %56, label %57, label %62

57:                                               ; preds = %55
  call void @ge_p1p1_to_p3(ptr noundef nonnull %10, ptr noundef nonnull %9)
  %58 = load i8, ptr %47, align 1, !tbaa !5
  %59 = sdiv i8 %58, -2
  %60 = sext i8 %59 to i64
  %61 = getelementptr inbounds %struct.ge_cached, ptr %4, i64 %60
  call void @ge_sub(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef %61)
  br label %62

62:                                               ; preds = %55, %57, %50
  call void @ge_p1p1_to_p2(ptr noundef %0, ptr noundef nonnull %9)
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %63 = icmp sgt i64 %indvars.iv, 0
  br i1 %63, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %26, %62, %28
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %10) #2
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %9) #2
  call void @llvm.lifetime.end.p0(i64 1280, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %6) #2
  ret void
}

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass