; LLVM IR from IOsonata/IOsonata :: src/sensors/accel_adxl362.ll (ZN12AccelAdxl36210UpdateDataEv)

; 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.Device = type { ptr, i8, i32, ptr, ptr, i64, i8, ptr, i8, i32 }
%class.AccelSensor = type <{ %class.Sensor.base, %struct.__AccelSensor_Raw_Data, [5 x i8], ptr, i16, [2 x i8], [3 x [3 x float]], [3 x float], [4 x i8], %class.Device }>
%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.__AccelSensor_Raw_Data = type <{ i64, i16, i16, %union.anon }>
%union.anon = type { [3 x i16] }
%struct.anon = type { i16, i16, i16 }

@__const._ZN12AccelAdxl36210UpdateDataEv.cmd = external hidden unnamed_addr constant [2 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12AccelAdxl36210UpdateDataEv(ptr noundef nonnull align 8 dereferenceable(157) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca [2 x i8], align 1
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 @__const._ZN12AccelAdxl36210UpdateDataEv.cmd, i64 2, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %6, i64 %9
  %11 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %12 = load ptr, ptr %10, align 8, !tbaa !9
  %13 = getelementptr inbounds ptr, ptr %12, i64 11
  %14 = load ptr, ptr %13, align 8
  %15 = call noundef zeroext i8 %14(ptr noundef nonnull align 8 dereferenceable(64) %10, ptr noundef %11, i32 noundef 2)
  store i8 %15, ptr %4, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !12
  %16 = load i8, ptr %4, align 1, !tbaa !11
  %17 = zext i8 %16 to i32
  %18 = and i32 %17, 1
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %87

20:                                               ; preds = %1
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr %6, i64 %23
  %25 = getelementptr inbounds %class.Device, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %42

28:                                               ; preds = %20
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr i8, ptr %29, i64 -24
  %31 = load i64, ptr %30, align 8
  %32 = getelementptr inbounds i8, ptr %6, i64 %31
  %33 = getelementptr inbounds %class.Device, ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %35, i64 14
  %37 = load ptr, ptr %36, align 8
  %38 = call noundef i32 %37(ptr noundef nonnull align 8 dereferenceable(140) %34)
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %41 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %40, i32 0, i32 0
  store i64 %39, ptr %41, align 1, !tbaa !19
  br label %47

42:                                               ; preds = %20
  %43 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %44 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 1, !tbaa !19
  %46 = add i64 %45, 1
  store i64 %46, ptr %44, align 1, !tbaa !19
  br label %47

47:                                               ; preds = %42, %28
  %48 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 1
  store i8 14, ptr %48, align 1, !tbaa !11
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = getelementptr i8, ptr %49, i64 -24
  %51 = load i64, ptr %50, align 8
  %52 = getelementptr inbounds i8, ptr %6, i64 %51
  %53 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %54 = load ptr, ptr %52, align 8, !tbaa !9
  %55 = getelementptr inbounds ptr, ptr %54, i64 12
  %56 = load ptr, ptr %55, align 8
  %57 = call noundef zeroext i16 %56(ptr noundef nonnull align 8 dereferenceable(64) %52, ptr noundef %53, i32 noundef 2)
  %58 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %59 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %58, i32 0, i32 3
  %60 = getelementptr inbounds %struct.anon, ptr %59, i32 0, i32 0
  store i16 %57, ptr %60, align 1, !tbaa !11
  %61 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 1
  store i8 16, ptr %61, align 1, !tbaa !11
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = getelementptr i8, ptr %62, i64 -24
  %64 = load i64, ptr %63, align 8
  %65 = getelementptr inbounds i8, ptr %6, i64 %64
  %66 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %67 = load ptr, ptr %65, align 8, !tbaa !9
  %68 = getelementptr inbounds ptr, ptr %67, i64 12
  %69 = load ptr, ptr %68, align 8
  %70 = call noundef zeroext i16 %69(ptr noundef nonnull align 8 dereferenceable(64) %65, ptr noundef %66, i32 noundef 2)
  %71 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %72 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %71, i32 0, i32 3
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 1
  store i16 %70, ptr %73, align 1, !tbaa !11
  %74 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 1
  store i8 18, ptr %74, align 1, !tbaa !11
  %75 = load ptr, ptr %6, align 8, !tbaa !9
  %76 = getelementptr i8, ptr %75, i64 -24
  %77 = load i64, ptr %76, align 8
  %78 = getelementptr inbounds i8, ptr %6, i64 %77
  %79 = getelementptr inbounds [2 x i8], ptr %3, i64 0, i64 0
  %80 = load ptr, ptr %78, align 8, !tbaa !9
  %81 = getelementptr inbounds ptr, ptr %80, i64 12
  %82 = load ptr, ptr %81, align 8
  %83 = call noundef zeroext i16 %82(ptr noundef nonnull align 8 dereferenceable(64) %78, ptr noundef %79, i32 noundef 2)
  %84 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %85 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %84, i32 0, i32 3
  %86 = getelementptr inbounds %struct.anon, ptr %85, i32 0, i32 2
  store i16 %83, ptr %86, align 1, !tbaa !11
  store i8 1, ptr %5, align 1, !tbaa !12
  br label %94

87:                                               ; preds = %1
  %88 = load i8, ptr %4, align 1, !tbaa !11
  %89 = zext i8 %88 to i32
  %90 = and i32 %89, 2
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %87
  br label %93

93:                                               ; preds = %92, %87
  br label %94

94:                                               ; preds = %93, %47
  %95 = load i8, ptr %5, align 1, !tbaa !12, !range !28, !noundef !29
  %96 = trunc i8 %95 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #3
  ret i1 %96
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"_ZTS6Device", !13, i64 8, !16, i64 12, !6, i64 16, !6, i64 24, !17, i64 32, !13, i64 40, !6, i64 48, !7, i64 56, !18, i64 60}
!16 = !{!"int", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTS21__Dev_Data_Byte_Order", !7, i64 0}
!19 = !{!20, !17, i64 73}
!20 = !{!"_ZTS11AccelSensor", !21, i64 0, !26, i64 73, !6, i64 96, !27, i64 104, !7, i64 108, !7, i64 144}
!21 = !{!"_ZTS6Sensor", !16, i64 8, !22, i64 12, !23, i64 16, !16, i64 20, !17, i64 24, !13, i64 32, !17, i64 40, !17, i64 48, !16, i64 56, !16, i64 60, !16, i64 64, !16, i64 68, !24, i64 72}
!22 = !{!"_ZTS14__Sensor_State", !7, i64 0}
!23 = !{!"_ZTS15__Sensor_OpMode", !7, i64 0}
!24 = !{!"_ZTSSt11atomic_flag", !25, i64 0}
!25 = !{!"_ZTSSt18__atomic_flag_base", !13, i64 0}
!26 = !{!"_ZTS22__AccelSensor_Raw_Data", !17, i64 0, !27, i64 8, !27, i64 10, !7, i64 12}
!27 = !{!"short", !7, i64 0}
!28 = !{i8 0, i8 2}
!29 = !{}


; 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"

@__const._ZN12AccelAdxl36210UpdateDataEv.cmd = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12AccelAdxl36210UpdateDataEv(ptr noundef nonnull align 8 dereferenceable(157) %0) unnamed_addr #1 align 2 {
  %2 = alloca [2 x i8], align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %2) #2
  %3 = load i16, ptr @__const._ZN12AccelAdxl36210UpdateDataEv.cmd, align 1
  store i16 %3, ptr %2, align 2
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 %6
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 88
  %10 = load ptr, ptr %9, align 8
  %11 = call noundef zeroext i8 %10(ptr noundef nonnull align 8 dereferenceable(64) %7, ptr noundef nonnull %2, i32 noundef 2)
  %12 = and i8 %11, 1
  %.not = icmp ne i8 %12, 0
  br i1 %.not, label %13, label %60

13:                                               ; preds = %1
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 %16
  %18 = getelementptr inbounds i8, ptr %17, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !8
  %.not4 = icmp eq ptr %19, null
  br i1 %.not4, label %27, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr %19, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 112
  %23 = load ptr, ptr %22, align 8
  %24 = call noundef i32 %23(ptr noundef nonnull align 8 dereferenceable(140) %19)
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %0, i64 73
  store i64 %25, ptr %26, align 1, !tbaa !16
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %31

27:                                               ; preds = %13
  %28 = getelementptr inbounds i8, ptr %0, i64 73
  %29 = load i64, ptr %28, align 1, !tbaa !16
  %30 = add i64 %29, 1
  store i64 %30, ptr %28, align 1, !tbaa !16
  br label %31

31:                                               ; preds = %27, %20
  %32 = phi ptr [ %14, %27 ], [ %.pre, %20 ]
  %33 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 14, ptr %33, align 1, !tbaa !25
  %34 = getelementptr i8, ptr %32, i64 -24
  %35 = load i64, ptr %34, align 8
  %36 = getelementptr inbounds i8, ptr %0, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 96
  %39 = load ptr, ptr %38, align 8
  %40 = call noundef zeroext i16 %39(ptr noundef nonnull align 8 dereferenceable(64) %36, ptr noundef nonnull %2, i32 noundef 2)
  %41 = getelementptr inbounds i8, ptr %0, i64 85
  store i16 %40, ptr %41, align 1, !tbaa !25
  store i8 16, ptr %33, align 1, !tbaa !25
  %42 = load ptr, ptr %0, align 8, !tbaa !5
  %43 = getelementptr i8, ptr %42, i64 -24
  %44 = load i64, ptr %43, align 8
  %45 = getelementptr inbounds i8, ptr %0, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 96
  %48 = load ptr, ptr %47, align 8
  %49 = call noundef zeroext i16 %48(ptr noundef nonnull align 8 dereferenceable(64) %45, ptr noundef nonnull %2, i32 noundef 2)
  %50 = getelementptr inbounds i8, ptr %0, i64 87
  store i16 %49, ptr %50, align 1, !tbaa !25
  store i8 18, ptr %33, align 1, !tbaa !25
  %51 = load ptr, ptr %0, align 8, !tbaa !5
  %52 = getelementptr i8, ptr %51, i64 -24
  %53 = load i64, ptr %52, align 8
  %54 = getelementptr inbounds i8, ptr %0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 96
  %57 = load ptr, ptr %56, align 8
  %58 = call noundef zeroext i16 %57(ptr noundef nonnull align 8 dereferenceable(64) %54, ptr noundef nonnull %2, i32 noundef 2)
  %59 = getelementptr inbounds i8, ptr %0, i64 89
  store i16 %58, ptr %59, align 1, !tbaa !25
  br label %60

60:                                               ; preds = %1, %31
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %2) #2
  ret i1 %.not
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !13, i64 24}
!9 = !{!"_ZTS6Device", !10, i64 8, !12, i64 12, !13, i64 16, !13, i64 24, !14, i64 32, !10, i64 40, !13, i64 48, !11, i64 56, !15, i64 60}
!10 = !{!"bool", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"any pointer", !11, i64 0}
!14 = !{!"long", !11, i64 0}
!15 = !{!"_ZTS21__Dev_Data_Byte_Order", !11, i64 0}
!16 = !{!17, !14, i64 73}
!17 = !{!"_ZTS11AccelSensor", !18, i64 0, !23, i64 73, !13, i64 96, !24, i64 104, !11, i64 108, !11, i64 144}
!18 = !{!"_ZTS6Sensor", !12, i64 8, !19, i64 12, !20, i64 16, !12, i64 20, !14, i64 24, !10, i64 32, !14, i64 40, !14, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !21, i64 72}
!19 = !{!"_ZTS14__Sensor_State", !11, i64 0}
!20 = !{!"_ZTS15__Sensor_OpMode", !11, i64 0}
!21 = !{!"_ZTSSt11atomic_flag", !22, i64 0}
!22 = !{!"_ZTSSt18__atomic_flag_base", !10, i64 0}
!23 = !{!"_ZTS22__AccelSensor_Raw_Data", !14, i64 0, !24, i64 8, !24, i64 10, !11, i64 12}
!24 = !{!"short", !11, i64 0}
!25 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass