; LLVM IR from IOsonata/IOsonata :: src/sensors/temp_ntc.ll (ZN7TempNtc4InitEjjjP5Timer)

; 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.TempNtc = type { %class.TempSensor.base, i32, i32, i32, ptr, i64, %class.Device }
%class.TempSensor.base = type { %class.Sensor.base, %struct.__TemperatureSensor_Data, ptr }
%class.Sensor.base = type <{ ptr, i32, i32, i32, i32, i64, i8, [7 x i8], i64, i64, i32, i32, i32, i32, %"struct.std::atomic_flag" }>
%"struct.std::atomic_flag" = type { %"struct.std::__atomic_flag_base" }
%"struct.std::__atomic_flag_base" = type { i8 }
%struct.__TemperatureSensor_Data = type <{ i64, i32 }>
%class.Device = type { ptr, i8, i32, ptr, ptr, i64, i8, ptr, i8, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7TempNtc4InitEjjjP5Timer(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = getelementptr inbounds %class.TempNtc, ptr %11, i32 0, i32 1
  store i32 %12, ptr %13, align 8, !tbaa !11
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = getelementptr inbounds %class.TempNtc, ptr %11, i32 0, i32 2
  store i32 %14, ptr %15, align 4, !tbaa !22
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = getelementptr inbounds %class.TempNtc, ptr %11, i32 0, i32 3
  store i32 %16, ptr %17, align 8, !tbaa !23
  %18 = getelementptr inbounds %class.TempNtc, ptr %11, i32 0, i32 4
  store ptr null, ptr %18, align 8, !tbaa !24
  %19 = getelementptr inbounds %class.TempNtc, ptr %11, i32 0, i32 5
  store i64 0, ptr %19, align 8, !tbaa !25
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %11, align 8, !tbaa !26
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr %11, i64 %23
  %25 = getelementptr inbounds %class.Device, ptr %24, i32 0, i32 4
  store ptr %20, ptr %25, align 8, !tbaa !28
  ret void
}

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

!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, !10, i64 96}
!12 = !{!"_ZTS7TempNtc", !13, i64 0, !10, i64 96, !10, i64 100, !10, i64 104, !6, i64 112, !17, i64 120}
!13 = !{!"_ZTS10TempSensor", !14, i64 0, !21, i64 73, !6, i64 88}
!14 = !{!"_ZTS6Sensor", !10, i64 8, !15, i64 12, !16, i64 16, !10, i64 20, !17, i64 24, !18, i64 32, !17, i64 40, !17, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !19, i64 72}
!15 = !{!"_ZTS14__Sensor_State", !7, i64 0}
!16 = !{!"_ZTS15__Sensor_OpMode", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTSSt11atomic_flag", !20, i64 0}
!20 = !{!"_ZTSSt18__atomic_flag_base", !18, i64 0}
!21 = !{!"_ZTS24__TemperatureSensor_Data", !17, i64 0, !10, i64 8}
!22 = !{!12, !10, i64 100}
!23 = !{!12, !10, i64 104}
!24 = !{!12, !6, i64 112}
!25 = !{!12, !17, i64 120}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !8, i64 0}
!28 = !{!29, !6, i64 24}
!29 = !{!"_ZTS6Device", !18, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !17, i64 32, !18, i64 40, !6, i64 48, !7, i64 56, !30, i64 60}
!30 = !{!"_ZTS21__Dev_Data_Byte_Order", !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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN7TempNtc4InitEjjjP5Timer(ptr nocapture noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %1, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 %2, ptr %7, align 4, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %3, ptr %8, align 8, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  %10 = load ptr, ptr %0, align 8, !tbaa !22
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 %12
  %14 = getelementptr inbounds i8, ptr %13, i64 24
  store ptr %4, ptr %14, align 8, !tbaa !24
  ret void
}

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

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" }
attributes #1 = { 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, !9, i64 96}
!6 = !{!"_ZTS7TempNtc", !7, i64 0, !9, i64 96, !9, i64 100, !9, i64 104, !19, i64 112, !14, i64 120}
!7 = !{!"_ZTS10TempSensor", !8, i64 0, !18, i64 73, !19, i64 88}
!8 = !{!"_ZTS6Sensor", !9, i64 8, !12, i64 12, !13, i64 16, !9, i64 20, !14, i64 24, !15, i64 32, !14, i64 40, !14, i64 48, !9, i64 56, !9, i64 60, !9, i64 64, !9, i64 68, !16, i64 72}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTS14__Sensor_State", !10, i64 0}
!13 = !{!"_ZTS15__Sensor_OpMode", !10, i64 0}
!14 = !{!"long", !10, i64 0}
!15 = !{!"bool", !10, i64 0}
!16 = !{!"_ZTSSt11atomic_flag", !17, i64 0}
!17 = !{!"_ZTSSt18__atomic_flag_base", !15, i64 0}
!18 = !{!"_ZTS24__TemperatureSensor_Data", !14, i64 0, !9, i64 8}
!19 = !{!"any pointer", !10, i64 0}
!20 = !{!6, !9, i64 100}
!21 = !{!6, !9, i64 104}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !11, i64 0}
!24 = !{!25, !19, i64 24}
!25 = !{!"_ZTS6Device", !15, i64 8, !9, i64 12, !19, i64 16, !19, i64 24, !14, i64 32, !15, i64 40, !19, i64 48, !10, i64 56, !26, i64 60}
!26 = !{!"_ZTS21__Dev_Data_Byte_Order", !10, i64 0}


; Effective O3 passes: GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass