; LLVM IR from Dovyski/opengl-demos :: src/coordinate-system/main.ll (Z19mouseMotionCallbackii)

; 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.RenderState = type <{ float, float, float, float, i8, i8, [2 x i8] }>

@rs = external dso_local global %class.RenderState, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z19mouseMotionCallbackii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = load i8, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 4), align 4, !tbaa !9, !range !13, !noundef !14
  %6 = trunc i8 %5 to i1
  br i1 %6, label %7, label %24

7:                                                ; preds = %2
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sitofp i32 %8 to float
  %10 = load float, ptr @rs, align 4, !tbaa !15
  %11 = fsub float %9, %10
  %12 = load float, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 3), align 4, !tbaa !16
  %13 = fadd float %12, %11
  store float %13, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 3), align 4, !tbaa !16
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sitofp i32 %14 to float
  %16 = load float, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 1), align 4, !tbaa !17
  %17 = fsub float %15, %16
  %18 = load float, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 2), align 4, !tbaa !18
  %19 = fadd float %18, %17
  store float %19, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 2), align 4, !tbaa !18
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sitofp i32 %20 to float
  store float %21, ptr @rs, align 4, !tbaa !15
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sitofp i32 %22 to float
  store float %23, ptr getelementptr inbounds (%class.RenderState, ptr @rs, i32 0, i32 1), align 4, !tbaa !17
  br label %24

24:                                               ; preds = %7, %2
  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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"_ZTS11RenderState", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 17}
!11 = !{!"float", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 12}
!17 = !{!10, !11, i64 4}
!18 = !{!10, !11, i64 8}


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

%class.RenderState = type <{ float, float, float, float, i8, i8, [2 x i8] }>

@rs = external dso_local local_unnamed_addr global %class.RenderState, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z19mouseMotionCallbackii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i8, ptr getelementptr inbounds (i8, ptr @rs, i64 16), align 4, !tbaa !5, !range !11, !noundef !12
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %15

5:                                                ; preds = %2
  %6 = insertelement <2 x i32> poison, i32 %1, i64 0
  %7 = insertelement <2 x i32> %6, i32 %0, i64 1
  %8 = sitofp <2 x i32> %7 to <2 x float>
  %9 = load <2 x float>, ptr @rs, align 4, !tbaa !13
  %10 = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %11 = fsub <2 x float> %8, %10
  %12 = load <2 x float>, ptr getelementptr inbounds (i8, ptr @rs, i64 8), align 4, !tbaa !13
  %13 = fadd <2 x float> %12, %11
  store <2 x float> %13, ptr getelementptr inbounds (i8, ptr @rs, i64 8), align 4, !tbaa !13
  %14 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  store <2 x float> %14, ptr @rs, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %5, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, 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" }

!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, !10, i64 16}
!6 = !{!"_ZTS11RenderState", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!7, !7, i64 0}


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