; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper)

; 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.arm_2d_helper_pi_slider_cfg_t = type { i32, float, float }
%struct.arm_2d_helper_pi_slider_t = type { %struct.anon.0 }
%struct.anon.0 = type { i32, i32, i32, i32, i32, i64, i32 }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_pi_slider_init = external hidden unnamed_addr constant [127 x i8], align 1
@__const.arm_2d_helper_pi_slider_init.tCFG = external hidden unnamed_addr constant %struct.arm_2d_helper_pi_slider_cfg_t, align 4

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: nounwind uwtable
declare dso_local i64 @arm_2d_helper_convert_ms_to_ticks(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @arm_2d_helper_pi_slider_init(ptr noundef nonnull %0, ptr noundef nonnull %1, i16 noundef signext %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca %struct.arm_2d_helper_pi_slider_cfg_t, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i16 %2, ptr %6, align 2, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  br label %12

11:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 445, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_pi_slider_init) #6
  unreachable

12:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 @__const.arm_2d_helper_pi_slider_init.tCFG, i64 12, i1 false)
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store ptr %7, ptr %5, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %17, i8 0, i64 40, i1 false)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_cfg_t, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = call i64 @arm_2d_helper_convert_ms_to_ticks(i32 noundef %20)
  %22 = trunc i64 %21 to i32
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_t, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.anon.0, ptr %24, i32 0, i32 4
  store i32 %22, ptr %25, align 8, !tbaa !15
  %26 = load i16, ptr %6, align 2, !tbaa !9
  %27 = call i32 @reinterpret_q16_s16(i16 noundef signext %26)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_t, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.anon.0, ptr %29, i32 0, i32 2
  store i32 %27, ptr %30, align 8, !tbaa !19
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_cfg_t, ptr %31, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !20
  %34 = call i32 @reinterpret_q16_f32(float noundef %33)
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon.0, ptr %36, i32 0, i32 0
  store i32 %34, ptr %37, align 8, !tbaa !21
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_cfg_t, ptr %38, i32 0, i32 2
  %40 = load float, ptr %39, align 4, !tbaa !22
  %41 = call i32 @reinterpret_q16_f32(float noundef %40)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_2d_helper_pi_slider_t, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.anon.0, ptr %43, i32 0, i32 1
  store i32 %41, ptr %44, align 4, !tbaa !23
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #7
  ret ptr %45
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @reinterpret_q16_s16(i16 noundef signext) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @reinterpret_q16_f32(float noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint 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 #6 = { noreturn nounwind }
attributes #7 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !13, i64 0}
!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 = !{!16, !13, i64 16}
!16 = !{!"arm_2d_helper_pi_slider_t", !17, i64 0}
!17 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !18, i64 24, !13, i64 32}
!18 = !{!"long", !7, i64 0}
!19 = !{!16, !13, i64 8}
!20 = !{!12, !14, i64 4}
!21 = !{!16, !13, i64 0}
!22 = !{!12, !14, i64 8}
!23 = !{!16, !13, i64 4}


; 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
declare dso_local i64 @arm_2d_helper_convert_ms_to_ticks(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @arm_2d_helper_pi_slider_init(ptr noundef nonnull returned writeonly %0, ptr nocapture noundef nonnull readonly %1, i16 noundef signext %2) local_unnamed_addr #0 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %0, i8 0, i64 40, i1 false)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = tail call i64 @arm_2d_helper_convert_ms_to_ticks(i32 noundef %4)
  %6 = trunc i64 %5 to i32
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %6, ptr %7, align 8, !tbaa !11
  %8 = tail call i32 @reinterpret_q16_s16(i16 noundef signext %2)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %8, ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load float, ptr %10, align 4, !tbaa !16
  %12 = tail call i32 @reinterpret_q16_f32(float noundef %11)
  store i32 %12, ptr %0, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load float, ptr %13, align 4, !tbaa !18
  %15 = tail call i32 @reinterpret_q16_f32(float noundef %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %15, ptr %16, align 4, !tbaa !19
  ret ptr %0
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @reinterpret_q16_s16(i16 noundef signext) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @reinterpret_q16_f32(float noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { inlinehint 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, !7, i64 0}
!6 = !{!"arm_2d_helper_pi_slider_cfg_t", !7, i64 0, !10, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"arm_2d_helper_pi_slider_t", !13, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !14, i64 24, !7, i64 32}
!14 = !{!"long", !8, i64 0}
!15 = !{!12, !7, i64 8}
!16 = !{!6, !10, i64 4}
!17 = !{!12, !7, i64 0}
!18 = !{!6, !10, i64 8}
!19 = !{!12, !7, i64 4}


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