; LLVM IR from Discngine/fpocket :: src (energy)

; 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.s_vvertice = type { i32, i32, i32, i32, i32, float, float, float, float, i32, i32, [4 x i32], [4 x ptr], [3 x float], float }
%struct.s_grid = type { ptr, ptr, i32, i32, i32, float }

; 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: nounwind uwtable
define dso_local void @set_alpha_sphere_electrostatic_energy(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_vvertice, ptr %11, i32 0, i32 6
  %13 = load float, ptr %12, align 8, !tbaa !9
  store float %13, ptr %5, align 4, !tbaa !13
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_vvertice, ptr %14, i32 0, i32 7
  %16 = load float, ptr %15, align 4, !tbaa !14
  store float %16, ptr %6, align 4, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.s_vvertice, ptr %17, i32 0, i32 8
  %19 = load float, ptr %18, align 8, !tbaa !15
  store float %19, ptr %7, align 4, !tbaa !13
  %20 = load float, ptr %5, align 4, !tbaa !13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.s_grid, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds float, ptr %23, i64 0
  %25 = load float, ptr %24, align 4, !tbaa !13
  %26 = fsub float %20, %25
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_grid, ptr %27, i32 0, i32 5
  %29 = load float, ptr %28, align 4, !tbaa !18
  %30 = fdiv float %26, %29
  %31 = fpext float %30 to double
  %32 = fadd double %31, 5.000000e-01
  %33 = fptosi double %32 to i32
  store i32 %33, ptr %8, align 4, !tbaa !19
  %34 = load float, ptr %6, align 4, !tbaa !13
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.s_grid, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = getelementptr inbounds float, ptr %37, i64 1
  %39 = load float, ptr %38, align 4, !tbaa !13
  %40 = fsub float %34, %39
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s_grid, ptr %41, i32 0, i32 5
  %43 = load float, ptr %42, align 4, !tbaa !18
  %44 = fdiv float %40, %43
  %45 = fpext float %44 to double
  %46 = fadd double %45, 5.000000e-01
  %47 = fptosi double %46 to i32
  store i32 %47, ptr %9, align 4, !tbaa !19
  %48 = load float, ptr %7, align 4, !tbaa !13
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.s_grid, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = getelementptr inbounds float, ptr %51, i64 2
  %53 = load float, ptr %52, align 4, !tbaa !13
  %54 = fsub float %48, %53
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s_grid, ptr %55, i32 0, i32 5
  %57 = load float, ptr %56, align 4, !tbaa !18
  %58 = fdiv float %54, %57
  %59 = fpext float %58 to double
  %60 = fadd double %59, 5.000000e-01
  %61 = fptosi double %60 to i32
  store i32 %61, ptr %10, align 4, !tbaa !19
  %62 = load i32, ptr %8, align 4, !tbaa !19
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_grid, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 8, !tbaa !20
  %66 = icmp slt i32 %62, %65
  br i1 %66, label %67, label %106

67:                                               ; preds = %2
  %68 = load i32, ptr %9, align 4, !tbaa !19
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.s_grid, ptr %69, i32 0, i32 3
  %71 = load i32, ptr %70, align 4, !tbaa !21
  %72 = icmp slt i32 %68, %71
  br i1 %72, label %73, label %106

73:                                               ; preds = %67
  %74 = load i32, ptr %10, align 4, !tbaa !19
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.s_grid, ptr %75, i32 0, i32 4
  %77 = load i32, ptr %76, align 8, !tbaa !22
  %78 = icmp slt i32 %74, %77
  br i1 %78, label %79, label %106

79:                                               ; preds = %73
  %80 = load i32, ptr %8, align 4, !tbaa !19
  %81 = icmp sge i32 %80, 0
  br i1 %81, label %82, label %106

82:                                               ; preds = %79
  %83 = load i32, ptr %9, align 4, !tbaa !19
  %84 = icmp sge i32 %83, 0
  br i1 %84, label %85, label %106

85:                                               ; preds = %82
  %86 = load i32, ptr %10, align 4, !tbaa !19
  %87 = icmp sge i32 %86, 0
  br i1 %87, label %88, label %106

88:                                               ; preds = %85
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.s_grid, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !23
  %92 = load i32, ptr %8, align 4, !tbaa !19
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds ptr, ptr %91, i64 %93
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  %96 = load i32, ptr %9, align 4, !tbaa !19
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds ptr, ptr %95, i64 %97
  %99 = load ptr, ptr %98, align 8, !tbaa !5
  %100 = load i32, ptr %10, align 4, !tbaa !19
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds float, ptr %99, i64 %101
  %103 = load float, ptr %102, align 4, !tbaa !13
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.s_vvertice, ptr %104, i32 0, i32 14
  store float %103, ptr %105, align 4, !tbaa !24
  br label %106

106:                                              ; preds = %88, %85, %82, %79, %73, %67, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 24}
!10 = !{!"s_vvertice", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !11, i64 36, !11, i64 40, !7, i64 44, !7, i64 64, !7, i64 96, !12, i64 108}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 28}
!15 = !{!10, !12, i64 32}
!16 = !{!17, !6, i64 8}
!17 = !{!"s_grid", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !12, i64 28}
!18 = !{!17, !12, i64 28}
!19 = !{!11, !11, i64 0}
!20 = !{!17, !11, i64 16}
!21 = !{!17, !11, i64 20}
!22 = !{!17, !11, i64 24}
!23 = !{!17, !6, i64 0}
!24 = !{!10, !12, i64 108}


; 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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @set_alpha_sphere_electrostatic_energy(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load float, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %1, i64 28
  %9 = load float, ptr %8, align 4, !tbaa !14
  %10 = load <2 x float>, ptr %3, align 8, !tbaa !15
  %11 = load <2 x float>, ptr %7, align 4, !tbaa !15
  %12 = fsub <2 x float> %10, %11
  %13 = insertelement <2 x float> poison, float %9, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = fdiv <2 x float> %12, %14
  %16 = fpext <2 x float> %15 to <2 x double>
  %17 = fadd <2 x double> %16, <double 5.000000e-01, double 5.000000e-01>
  %18 = fptosi <2 x double> %17 to <2 x i32>
  %19 = getelementptr inbounds i8, ptr %7, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !15
  %21 = fsub float %5, %20
  %22 = fdiv float %21, %9
  %23 = fpext float %22 to double
  %24 = fadd double %23, 5.000000e-01
  %25 = fptosi double %24 to i32
  %26 = getelementptr inbounds i8, ptr %1, i64 16
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = extractelement <2 x i32> %18, i64 0
  %29 = icmp sgt i32 %27, %28
  br i1 %29, label %30, label %55

30:                                               ; preds = %2
  %31 = getelementptr inbounds i8, ptr %1, i64 20
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = extractelement <2 x i32> %18, i64 1
  %34 = icmp sgt i32 %32, %33
  br i1 %34, label %35, label %55

35:                                               ; preds = %30
  %36 = getelementptr inbounds i8, ptr %1, i64 24
  %37 = load i32, ptr %36, align 8, !tbaa !18
  %38 = icmp sgt i32 %37, %25
  %39 = icmp sgt <2 x i32> %18, <i32 -1, i32 -1>
  %40 = extractelement <2 x i1> %39, i64 0
  %or.cond = and i1 %40, %38
  %41 = extractelement <2 x i1> %39, i64 1
  %or.cond3 = select i1 %or.cond, i1 %41, i1 false
  %42 = icmp sgt i32 %25, -1
  %or.cond5 = select i1 %or.cond3, i1 %42, i1 false
  br i1 %or.cond5, label %43, label %55

43:                                               ; preds = %35
  %44 = load ptr, ptr %1, align 8, !tbaa !19
  %45 = zext nneg i32 %28 to i64
  %46 = getelementptr inbounds ptr, ptr %44, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  %48 = zext nneg i32 %33 to i64
  %49 = getelementptr inbounds ptr, ptr %47, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  %51 = zext nneg i32 %25 to i64
  %52 = getelementptr inbounds float, ptr %50, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !15
  %54 = getelementptr inbounds i8, ptr %0, i64 108
  store float %53, ptr %54, align 4, !tbaa !21
  br label %55

55:                                               ; preds = %43, %35, %30, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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, !10, i64 32}
!6 = !{!"s_vvertice", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 36, !7, i64 40, !8, i64 44, !8, i64 64, !8, i64 96, !10, i64 108}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"s_grid", !13, i64 0, !13, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 28}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!12, !10, i64 28}
!15 = !{!10, !10, i64 0}
!16 = !{!12, !7, i64 16}
!17 = !{!12, !7, i64 20}
!18 = !{!12, !7, i64 24}
!19 = !{!12, !13, i64 0}
!20 = !{!13, !13, i64 0}
!21 = !{!6, !10, i64 108}


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