; LLVM IR from microsoft/LightAIMD :: src (sample)

; 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.vec3d = type { double, double, double }
%struct.molecule = type { i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr }

@h2o_atomic_nums = external dso_local global [3 x i64], align 16
@h2o_coords = external dso_local global [3 x %struct.vec3d], align 16
@STANDARD_ATOMIC_WEIGHTS = external global [0 x double], align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @sample_molecule_h2o() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %3 = call ptr @x_malloc(i64 noundef 80)
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = call ptr @x_malloc(i64 noundef 24)
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.molecule, ptr %5, i32 0, i32 2
  store ptr %4, ptr %6, align 8, !tbaa !9
  %7 = call ptr @x_malloc(i64 noundef 24)
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.molecule, ptr %8, i32 0, i32 3
  store ptr %7, ptr %9, align 8, !tbaa !12
  %10 = call ptr @x_malloc(i64 noundef 72)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.molecule, ptr %11, i32 0, i32 4
  store ptr %10, ptr %12, align 8, !tbaa !13
  %13 = call ptr @x_malloc(i64 noundef 72)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.molecule, ptr %14, i32 0, i32 5
  store ptr %13, ptr %15, align 8, !tbaa !14
  %16 = call ptr @x_malloc(i64 noundef 72)
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.molecule, ptr %17, i32 0, i32 6
  store ptr %16, ptr %18, align 8, !tbaa !15
  %19 = call ptr @x_malloc(i64 noundef 72)
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.molecule, ptr %20, i32 0, i32 7
  store ptr %19, ptr %21, align 8, !tbaa !16
  %22 = call ptr @x_malloc(i64 noundef 8)
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.molecule, ptr %23, i32 0, i32 9
  store ptr %22, ptr %24, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 0, ptr %2, align 8, !tbaa !18
  br label %25

25:                                               ; preds = %82, %0
  %26 = load i64, ptr %2, align 8, !tbaa !18
  %27 = icmp ult i64 %26, 3
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  br label %85

29:                                               ; preds = %25
  %30 = load i64, ptr %2, align 8, !tbaa !18
  %31 = getelementptr inbounds [3 x i64], ptr @h2o_atomic_nums, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !18
  %33 = load ptr, ptr %1, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.molecule, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = load i64, ptr %2, align 8, !tbaa !18
  %37 = getelementptr inbounds i64, ptr %35, i64 %36
  store i64 %32, ptr %37, align 8, !tbaa !18
  %38 = load i64, ptr %2, align 8, !tbaa !18
  %39 = getelementptr inbounds [3 x i64], ptr @h2o_atomic_nums, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !18
  %41 = getelementptr inbounds [0 x double], ptr @STANDARD_ATOMIC_WEIGHTS, i64 0, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !19
  %43 = fmul double %42, 0x409C7B8DCF542A68
  %44 = load ptr, ptr %1, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.molecule, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = load i64, ptr %2, align 8, !tbaa !18
  %48 = getelementptr inbounds double, ptr %46, i64 %47
  store double %43, ptr %48, align 8, !tbaa !19
  %49 = load i64, ptr %2, align 8, !tbaa !18
  %50 = getelementptr inbounds [3 x %struct.vec3d], ptr @h2o_coords, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.vec3d, ptr %50, i32 0, i32 0
  %52 = load double, ptr %51, align 8, !tbaa !21
  %53 = fdiv double %52, 0x3FE0EF050BD3BD7A
  %54 = load ptr, ptr %1, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.molecule, ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = load i64, ptr %2, align 8, !tbaa !18
  %58 = getelementptr inbounds %struct.vec3d, ptr %56, i64 %57
  %59 = getelementptr inbounds %struct.vec3d, ptr %58, i32 0, i32 0
  store double %53, ptr %59, align 8, !tbaa !21
  %60 = load i64, ptr %2, align 8, !tbaa !18
  %61 = getelementptr inbounds [3 x %struct.vec3d], ptr @h2o_coords, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.vec3d, ptr %61, i32 0, i32 1
  %63 = load double, ptr %62, align 8, !tbaa !23
  %64 = fdiv double %63, 0x3FE0EF050BD3BD7A
  %65 = load ptr, ptr %1, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.molecule, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load i64, ptr %2, align 8, !tbaa !18
  %69 = getelementptr inbounds %struct.vec3d, ptr %67, i64 %68
  %70 = getelementptr inbounds %struct.vec3d, ptr %69, i32 0, i32 1
  store double %64, ptr %70, align 8, !tbaa !23
  %71 = load i64, ptr %2, align 8, !tbaa !18
  %72 = getelementptr inbounds [3 x %struct.vec3d], ptr @h2o_coords, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.vec3d, ptr %72, i32 0, i32 2
  %74 = load double, ptr %73, align 8, !tbaa !24
  %75 = fdiv double %74, 0x3FE0EF050BD3BD7A
  %76 = load ptr, ptr %1, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.molecule, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = load i64, ptr %2, align 8, !tbaa !18
  %80 = getelementptr inbounds %struct.vec3d, ptr %78, i64 %79
  %81 = getelementptr inbounds %struct.vec3d, ptr %80, i32 0, i32 2
  store double %75, ptr %81, align 8, !tbaa !24
  br label %82

82:                                               ; preds = %29
  %83 = load i64, ptr %2, align 8, !tbaa !18
  %84 = add i64 %83, 1
  store i64 %84, ptr %2, align 8, !tbaa !18
  br label %25, !llvm.loop !25

85:                                               ; preds = %28
  %86 = load ptr, ptr %1, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.molecule, ptr %86, i32 0, i32 0
  store i64 3, ptr %87, align 8, !tbaa !27
  %88 = load ptr, ptr %1, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.molecule, ptr %88, i32 0, i32 1
  store i64 10, ptr %89, align 8, !tbaa !28
  %90 = load ptr, ptr %1, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.molecule, ptr %90, i32 0, i32 8
  store i64 1, ptr %91, align 8, !tbaa !29
  %92 = load ptr, ptr %1, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.molecule, ptr %92, i32 0, i32 9
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %94, ptr align 1 @.str, i64 4, i1 false)
  %95 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret ptr %95
}

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

declare ptr @x_malloc(i64 noundef) #2

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

; 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

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 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"molecule", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !6, i64 72}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !6, i64 56}
!17 = !{!10, !6, i64 72}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!22, !20, i64 0}
!22 = !{!"vec3d", !20, i64 0, !20, i64 8, !20, i64 16}
!23 = !{!22, !20, i64 8}
!24 = !{!22, !20, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !11, i64 0}
!28 = !{!10, !11, i64 8}
!29 = !{!10, !11, i64 64}


; 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.vec3d = type { double, double, double }

@h2o_atomic_nums = external dso_local local_unnamed_addr global [3 x i64], align 16
@h2o_coords = external dso_local local_unnamed_addr global [3 x %struct.vec3d], align 16
@STANDARD_ATOMIC_WEIGHTS = external local_unnamed_addr global [0 x double], align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @sample_molecule_h2o() local_unnamed_addr #0 {
  %1 = tail call ptr @x_malloc(i64 noundef 80) #2
  %2 = tail call ptr @x_malloc(i64 noundef 24) #2
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %2, ptr %3, align 8, !tbaa !5
  %4 = tail call ptr @x_malloc(i64 noundef 24) #2
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %4, ptr %5, align 8, !tbaa !11
  %6 = tail call ptr @x_malloc(i64 noundef 72) #2
  %7 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %6, ptr %7, align 8, !tbaa !12
  %8 = tail call ptr @x_malloc(i64 noundef 72) #2
  %9 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr %8, ptr %9, align 8, !tbaa !13
  %10 = tail call ptr @x_malloc(i64 noundef 72) #2
  %11 = getelementptr inbounds i8, ptr %1, i64 48
  store ptr %10, ptr %11, align 8, !tbaa !14
  %12 = tail call ptr @x_malloc(i64 noundef 72) #2
  %13 = getelementptr inbounds i8, ptr %1, i64 56
  store ptr %12, ptr %13, align 8, !tbaa !15
  %14 = tail call ptr @x_malloc(i64 noundef 8) #2
  %15 = getelementptr inbounds i8, ptr %1, i64 72
  store ptr %14, ptr %15, align 8, !tbaa !16
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !11
  %18 = load ptr, ptr %7, align 8, !tbaa !12
  %19 = load i64, ptr @h2o_atomic_nums, align 16, !tbaa !17
  store i64 %19, ptr %16, align 8, !tbaa !17
  %20 = getelementptr inbounds [0 x double], ptr @STANDARD_ATOMIC_WEIGHTS, i64 0, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !18
  %22 = fmul double %21, 0x409C7B8DCF542A68
  store double %22, ptr %17, align 8, !tbaa !18
  %23 = load <2 x double>, ptr @h2o_coords, align 16, !tbaa !18
  %24 = fdiv <2 x double> %23, <double 0x3FE0EF050BD3BD7A, double 0x3FE0EF050BD3BD7A>
  store <2 x double> %24, ptr %18, align 8, !tbaa !18
  %25 = load double, ptr getelementptr inbounds (i8, ptr @h2o_coords, i64 16), align 16, !tbaa !20
  %26 = fdiv double %25, 0x3FE0EF050BD3BD7A
  %27 = getelementptr inbounds i8, ptr %18, i64 16
  store double %26, ptr %27, align 8, !tbaa !20
  %28 = load i64, ptr getelementptr inbounds (i8, ptr @h2o_atomic_nums, i64 8), align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %16, i64 8
  store i64 %28, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds [0 x double], ptr @STANDARD_ATOMIC_WEIGHTS, i64 0, i64 %28
  %31 = load double, ptr %30, align 8, !tbaa !18
  %32 = fmul double %31, 0x409C7B8DCF542A68
  %33 = getelementptr inbounds i8, ptr %17, i64 8
  store double %32, ptr %33, align 8, !tbaa !18
  %34 = getelementptr inbounds i8, ptr %18, i64 24
  %35 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @h2o_coords, i64 24), align 8, !tbaa !18
  %36 = fdiv <2 x double> %35, <double 0x3FE0EF050BD3BD7A, double 0x3FE0EF050BD3BD7A>
  store <2 x double> %36, ptr %34, align 8, !tbaa !18
  %37 = load double, ptr getelementptr inbounds (i8, ptr @h2o_coords, i64 40), align 8, !tbaa !20
  %38 = fdiv double %37, 0x3FE0EF050BD3BD7A
  %39 = getelementptr inbounds i8, ptr %18, i64 40
  store double %38, ptr %39, align 8, !tbaa !20
  %40 = load i64, ptr getelementptr inbounds (i8, ptr @h2o_atomic_nums, i64 16), align 16, !tbaa !17
  %41 = getelementptr inbounds i8, ptr %16, i64 16
  store i64 %40, ptr %41, align 8, !tbaa !17
  %42 = getelementptr inbounds [0 x double], ptr @STANDARD_ATOMIC_WEIGHTS, i64 0, i64 %40
  %43 = load double, ptr %42, align 8, !tbaa !18
  %44 = fmul double %43, 0x409C7B8DCF542A68
  %45 = getelementptr inbounds i8, ptr %17, i64 16
  store double %44, ptr %45, align 8, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %18, i64 48
  %47 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @h2o_coords, i64 48), align 16, !tbaa !18
  %48 = fdiv <2 x double> %47, <double 0x3FE0EF050BD3BD7A, double 0x3FE0EF050BD3BD7A>
  store <2 x double> %48, ptr %46, align 8, !tbaa !18
  %49 = load double, ptr getelementptr inbounds (i8, ptr @h2o_coords, i64 64), align 16, !tbaa !20
  %50 = fdiv double %49, 0x3FE0EF050BD3BD7A
  %51 = getelementptr inbounds i8, ptr %18, i64 64
  store double %50, ptr %51, align 8, !tbaa !20
  store i64 3, ptr %1, align 8, !tbaa !22
  %52 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 10, ptr %52, align 8, !tbaa !23
  %53 = getelementptr inbounds i8, ptr %1, i64 64
  store i64 1, ptr %53, align 8, !tbaa !24
  %54 = load i32, ptr @.str, align 1
  store i32 %54, ptr %14, align 1
  ret ptr %1
}

declare ptr @x_malloc(i64 noundef) local_unnamed_addr #1

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 = { "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, !10, i64 16}
!6 = !{!"molecule", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 56}
!16 = !{!6, !10, i64 72}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !8, i64 0}
!20 = !{!21, !19, i64 16}
!21 = !{!"vec3d", !19, i64 0, !19, i64 8, !19, i64 16}
!22 = !{!6, !7, i64 0}
!23 = !{!6, !7, i64 8}
!24 = !{!6, !7, i64 64}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass