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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @md_initialize(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = call ptr @x_malloc(i64 noundef 56)
  store ptr %10, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.cmd_line_args, ptr %11, i32 0, i32 12
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.md_context, ptr %14, i32 0, i32 0
  store double %13, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.cmd_line_args, ptr %16, i32 0, i32 13
  %18 = load double, ptr %17, align 8, !tbaa !16
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.md_context, ptr %19, i32 0, i32 1
  store double %18, ptr %20, align 8, !tbaa !17
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.cmd_line_args, ptr %21, i32 0, i32 14
  %23 = load double, ptr %22, align 8, !tbaa !18
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.md_context, ptr %24, i32 0, i32 2
  store double %23, ptr %25, align 8, !tbaa !19
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.md_context, ptr %27, i32 0, i32 3
  store ptr %26, ptr %28, align 8, !tbaa !20
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.md_context, ptr %30, i32 0, i32 5
  store ptr %29, ptr %31, align 8, !tbaa !21
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.md_context, ptr %32, i32 0, i32 6
  store i64 0, ptr %33, align 8, !tbaa !22
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = mul i64 %34, %35
  %37 = mul i64 %36, 8
  %38 = call ptr @x_malloc(i64 noundef %37)
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.md_context, ptr %39, i32 0, i32 4
  store ptr %38, ptr %40, align 8, !tbaa !23
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %41
}

; 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

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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 96}
!12 = !{!"cmd_line_args", !10, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !10, i64 120, !10, i64 128}
!13 = !{!"double", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"md_context", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48}
!16 = !{!12, !13, i64 104}
!17 = !{!15, !13, i64 8}
!18 = !{!12, !13, i64 112}
!19 = !{!15, !13, i64 16}
!20 = !{!15, !6, i64 24}
!21 = !{!15, !6, i64 40}
!22 = !{!15, !10, i64 48}
!23 = !{!15, !6, i64 32}


; 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: nounwind uwtable
define dso_local noundef ptr @md_initialize(ptr nocapture noundef readonly %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @x_malloc(i64 noundef 56) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  %7 = load <2 x double>, ptr %6, align 8, !tbaa !5
  store <2 x double> %7, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  store double %9, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %1, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %3, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %5, i64 48
  store i64 0, ptr %13, align 8, !tbaa !17
  %14 = shl i64 %2, 3
  %15 = mul i64 %14, %2
  %16 = tail call ptr @x_malloc(i64 noundef %15) #2
  %17 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %16, ptr %17, align 8, !tbaa !18
  ret ptr %5
}

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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 112}
!10 = !{!"cmd_line_args", !11, i64 0, !12, i64 8, !12, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !11, i64 120, !11, i64 128}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"md_context", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !11, i64 48}
!15 = !{!14, !12, i64 24}
!16 = !{!14, !12, i64 40}
!17 = !{!14, !11, i64 48}
!18 = !{!14, !12, i64 32}


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