; LLVM IR from gem5/gem5 :: ext/dsent/model/optical_graph (OpticalModulator)

; 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.DSENT::OpticalModulator" = type <{ %"class.DSENT::OpticalNode", ptr, double, double, i8, [7 x i8] }>
%"class.DSENT::OpticalNode" = type { i32, %"class.LibUtil::String", ptr, ptr, i32, double, %"struct.std::pair" }
%"class.LibUtil::String" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.std::pair" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5DSENT16OpticalModulatorC2ERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiEbPNS_18OpticalTransmitterE(ptr noundef nonnull align 8 dereferenceable(105) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(8) %3, i1 noundef zeroext %4, ptr noundef %5) unnamed_addr #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  %13 = zext i1 %4 to i8
  store i8 %13, ptr %11, align 1, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN5DSENT11OpticalNodeC2ENS0_4TypeERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiE(ptr noundef nonnull align 8 dereferenceable(80) %14, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(32) %15, ptr noundef %16, ptr noundef nonnull align 4 dereferenceable(8) %17)
  %18 = getelementptr inbounds %"class.DSENT::OpticalModulator", ptr %14, i32 0, i32 1
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %19, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %"class.DSENT::OpticalModulator", ptr %14, i32 0, i32 2
  store double 0.000000e+00, ptr %20, align 8, !tbaa !22
  %21 = getelementptr inbounds %"class.DSENT::OpticalModulator", ptr %14, i32 0, i32 3
  store double 0.000000e+00, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds %"class.DSENT::OpticalModulator", ptr %14, i32 0, i32 4
  %23 = load i8, ptr %11, align 1, !tbaa !9, !range !24, !noundef !25
  %24 = trunc i8 %23 to i1
  %25 = zext i1 %24 to i8
  store i8 %25, ptr %22, align 8, !tbaa !26
  ret void
}

declare void @_ZN5DSENT11OpticalNodeC2ENS0_4TypeERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiE(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1

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

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"_ZTSN5DSENT16OpticalModulatorE", !13, i64 0, !6, i64 80, !20, i64 88, !20, i64 96, !10, i64 104}
!13 = !{!"_ZTSN5DSENT11OpticalNodeE", !14, i64 0, !15, i64 8, !6, i64 40, !6, i64 48, !19, i64 56, !20, i64 64, !21, i64 72}
!14 = !{!"_ZTSN5DSENT11OpticalNode4TypeE", !7, i64 0}
!15 = !{!"_ZTSN7LibUtil6StringE", !16, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!"_ZTSSt4pairIiiE", !19, i64 0, !19, i64 4}
!22 = !{!12, !20, i64 88}
!23 = !{!12, !20, i64 96}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!12, !10, i64 104}


; 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 uwtable
define dso_local void @_ZN5DSENT16OpticalModulatorC2ERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiEbPNS_18OpticalTransmitterE(ptr noundef nonnull align 8 dereferenceable(105) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(8) %3, i1 noundef zeroext %4, ptr noundef %5) unnamed_addr #0 align 2 {
  %7 = zext i1 %4 to i8
  tail call void @_ZN5DSENT11OpticalNodeC2ENS0_4TypeERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiE(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %5, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 88
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  store i8 %7, ptr %10, align 8, !tbaa !20
  ret void
}

declare void @_ZN5DSENT11OpticalNodeC2ENS0_4TypeERKN7LibUtil6StringEPNS_12OpticalModelERKSt4pairIiiE(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !14, i64 80}
!6 = !{!"_ZTSN5DSENT16OpticalModulatorE", !7, i64 0, !14, i64 80, !17, i64 88, !17, i64 96, !19, i64 104}
!7 = !{!"_ZTSN5DSENT11OpticalNodeE", !8, i64 0, !11, i64 8, !14, i64 40, !14, i64 48, !16, i64 56, !17, i64 64, !18, i64 72}
!8 = !{!"_ZTSN5DSENT11OpticalNode4TypeE", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN7LibUtil6StringE", !12, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !15, i64 8, !9, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"long", !9, i64 0}
!16 = !{!"int", !9, i64 0}
!17 = !{!"double", !9, i64 0}
!18 = !{!"_ZTSSt4pairIiiE", !16, i64 0, !16, i64 4}
!19 = !{!"bool", !9, i64 0}
!20 = !{!6, !19, i64 104}


; Effective O3 passes: EarlyCSEPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass