; LLVM IR from albertobsd/keyhunt :: gmp256k1/GMP256K1.ll (ZN9Secp256K110GetHash160EibR5PointPh)

; 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.Point = type { %class.Int, %class.Int, %class.Int }
%class.Int = type { [1 x %struct.__mpz_struct] }
%struct.__mpz_struct = type { i32, i32, ptr }

; 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

declare void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #1

declare noundef zeroext i1 @_ZN3Int6IsEvenEv(ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9Secp256K110GetHash160EibR5PointPh(ptr noundef nonnull align 8 dereferenceable(393296) %0, i32 noundef %1, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [64 x i8], align 16
  %12 = alloca [128 x i8], align 16
  %13 = alloca [64 x i8], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  %14 = zext i1 %2 to i8
  store i8 %14, ptr %8, align 1, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #3
  %16 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %16, label %66 [
    i32 0, label %17
    i32 2, label %17
    i32 1, label %52
  ]

17:                                               ; preds = %5, %5
  %18 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %19 = trunc i8 %18 to i1
  br i1 %19, label %33, label %20

20:                                               ; preds = %17
  %21 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  store i8 4, ptr %21, align 16, !tbaa !15
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.Point, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %25 = getelementptr inbounds i8, ptr %24, i64 1
  call void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef %25)
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.Point, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %29 = getelementptr inbounds i8, ptr %28, i64 33
  call void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef %29)
  %30 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %31 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %32 = call noundef i32 @_Z6sha256PKhmPh(ptr noundef %30, i64 noundef 65, ptr noundef %31)
  br label %48

33:                                               ; preds = %17
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.Point, ptr %34, i32 0, i32 1
  %36 = call noundef zeroext i1 @_ZN3Int6IsEvenEv(ptr noundef nonnull align 8 dereferenceable(16) %35)
  %37 = zext i1 %36 to i64
  %38 = select i1 %36, i32 2, i32 3
  %39 = trunc i32 %38 to i8
  %40 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  store i8 %39, ptr %40, align 16, !tbaa !15
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.Point, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  call void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef %44)
  %45 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %46 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %47 = call noundef i32 @_Z6sha256PKhmPh(ptr noundef %45, i64 noundef 33, ptr noundef %46)
  br label %48

48:                                               ; preds = %33, %20
  %49 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = call noundef i32 @_Z6rmd160PKhmPh(ptr noundef %49, i64 noundef 32, ptr noundef %50)
  br label %66

52:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 64, ptr %13) #3
  %53 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  store i8 0, ptr %53, align 16, !tbaa !15
  %54 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 1
  store i8 20, ptr %54, align 1, !tbaa !15
  %55 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %56 = trunc i8 %55 to i1
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  %59 = getelementptr inbounds i8, ptr %58, i64 2
  call void @_ZN9Secp256K110GetHash160EibR5PointPh(ptr noundef nonnull align 8 dereferenceable(393296) %15, i32 noundef 0, i1 noundef zeroext %56, ptr noundef nonnull align 8 dereferenceable(48) %57, ptr noundef %59)
  %60 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  %61 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %62 = call noundef i32 @_Z6sha256PKhmPh(ptr noundef %60, i64 noundef 22, ptr noundef %61)
  %63 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = call noundef i32 @_Z6rmd160PKhmPh(ptr noundef %63, i64 noundef 32, ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 64, ptr %13) #3
  br label %66

66:                                               ; preds = %52, %48, %5
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #3
  ret void
}

declare noundef i32 @_Z6sha256PKhmPh(ptr noundef, i64 noundef, ptr noundef) #1

declare noundef i32 @_Z6rmd160PKhmPh(ptr noundef, i64 noundef, 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 = { 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}


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

; 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

declare void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN3Int6IsEvenEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9Secp256K110GetHash160EibR5PointPh(ptr nocapture noundef nonnull readnone align 8 dereferenceable(393296) %0, i32 noundef %1, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4) local_unnamed_addr #2 align 2 {
  %6 = alloca [64 x i8], align 16
  %7 = alloca [128 x i8], align 16
  %8 = alloca [64 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #3
  %.sink12.sroa.gep = getelementptr inbounds i8, ptr %7, i64 1
  %.sink12.sroa.gep13 = getelementptr inbounds i8, ptr %7, i64 33
  switch i32 %1, label %25 [
    i32 0, label %9
    i32 2, label %9
    i32 1, label %20
  ]

9:                                                ; preds = %5, %5
  br i1 %2, label %13, label %10

10:                                               ; preds = %9
  store i8 4, ptr %7, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %7, i64 1
  call void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull %11)
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  br label %17

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %3, i64 16
  %15 = tail call noundef zeroext i1 @_ZN3Int6IsEvenEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
  %16 = select i1 %15, i8 2, i8 3
  store i8 %16, ptr %7, align 16, !tbaa !5
  br label %17

17:                                               ; preds = %13, %10
  %.sink12.sroa.phi = phi ptr [ %.sink12.sroa.gep, %13 ], [ %.sink12.sroa.gep13, %10 ]
  %.sink10 = phi ptr [ %3, %13 ], [ %12, %10 ]
  %.sink = phi i64 [ 33, %13 ], [ 65, %10 ]
  call void @_ZN3Int10Get32BytesEPh(ptr noundef nonnull align 8 dereferenceable(16) %.sink10, ptr noundef nonnull %.sink12.sroa.phi)
  %18 = call noundef i32 @_Z6sha256PKhmPh(ptr noundef nonnull %7, i64 noundef %.sink, ptr noundef nonnull %6)
  %19 = call noundef i32 @_Z6rmd160PKhmPh(ptr noundef nonnull %6, i64 noundef 32, ptr noundef %4)
  br label %25

20:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #3
  store i8 0, ptr %8, align 16, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %8, i64 1
  store i8 20, ptr %21, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %8, i64 2
  call void @_ZN9Secp256K110GetHash160EibR5PointPh(ptr noundef nonnull align 8 dereferenceable(393296) %0, i32 noundef 0, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull %22)
  %23 = call noundef i32 @_Z6sha256PKhmPh(ptr noundef nonnull %8, i64 noundef 22, ptr noundef nonnull %6)
  %24 = call noundef i32 @_Z6rmd160PKhmPh(ptr noundef nonnull %6, i64 noundef 32, ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #3
  br label %25

25:                                               ; preds = %20, %17, %5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #3
  ret void
}

declare noundef i32 @_Z6sha256PKhmPh(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare noundef i32 @_Z6rmd160PKhmPh(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 = { 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++ TBAA"}


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