; LLVM IR from ARM-software/Arm-2D :: examples/common/controls (meter_pointer)

; 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.meter_pointer_t = type { %union.anon, %struct.anon.8 }
%union.anon = type { %struct.spin_zoom_widget_t }
%struct.spin_zoom_widget_t = type { %struct.anon, [320 x i8] }
%struct.anon = type { %struct.spin_zoom_widget_cfg_t }
%struct.spin_zoom_widget_cfg_t = type { ptr, %struct.anon.0, ptr, %struct.anon.3, i32 }
%struct.anon.0 = type { ptr, ptr, %union.anon.1, %union.anon.2 }
%union.anon.1 = type { %struct.arm_2d_point_float_t }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.2 = type { i16 }
%struct.anon.3 = type { %struct.anon.4, %struct.anon.5, %struct.anon.6 }
%struct.anon.4 = type { float, i32 }
%struct.anon.5 = type { float, i32 }
%struct.anon.6 = type { float, %union.anon.7, float }
%union.anon.7 = type { float }
%struct.anon.8 = type { %struct.arm_2d_helper_pi_slider_cfg_t, [4 x i8], %struct.arm_2d_helper_pi_slider_t, float, [4 x i8] }
%struct.arm_2d_helper_pi_slider_cfg_t = type { i32, float, float }
%struct.arm_2d_helper_pi_slider_t = type { [40 x i8] }

@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.meter_pointer_get_current_value = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @meter_pointer_get_current_value(ptr noundef nonnull %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp ne ptr null, %3
  br i1 %4, label %5, label %6

5:                                                ; preds = %1
  br label %7

6:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 248, ptr noundef @__PRETTY_FUNCTION__.meter_pointer_get_current_value) #2
  unreachable

7:                                                ; preds = %5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.meter_pointer_t, ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds %struct.anon.8, ptr %9, i32 0, i32 3
  %11 = load float, ptr %10, align 8, !tbaa !9
  %12 = fptosi float %11 to i32
  ret i32 %12
}

attributes #0 = { noreturn nounwind "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 = { 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 #2 = { noreturn 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, !14, i64 456}
!10 = !{!"meter_pointer_t", !7, i64 0, !11, i64 400}
!11 = !{!"", !12, i64 0, !15, i64 16, !14, i64 56}
!12 = !{!"arm_2d_helper_pi_slider_cfg_t", !13, i64 0, !14, i64 4, !14, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"arm_2d_helper_pi_slider_t", !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(argmem: read) uwtable
define dso_local i32 @meter_pointer_get_current_value(ptr nocapture noundef nonnull readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 456
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = fptosi float %3 to i32
  ret i32 %4
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !12, i64 456}
!6 = !{!"meter_pointer_t", !7, i64 0, !9, i64 400}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !10, i64 0, !13, i64 16, !12, i64 56}
!10 = !{!"arm_2d_helper_pi_slider_cfg_t", !11, i64 0, !12, i64 4, !12, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"arm_2d_helper_pi_slider_t", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass