; LLVM IR from kobalicek/simdtests :: 3rdparty/real.ll (ZN3lol4realC2Ed)

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

%union.anon = type { double }
%"class.lol::real" = type { [16 x i32], i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3lol4realC2Ed(ptr noundef nonnull align 4 dereferenceable(68) %0, double noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca %union.anon, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @_ZN3lol4realC1Ev(ptr noundef nonnull align 4 dereferenceable(68) %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load double, ptr %4, align 8, !tbaa !9
  store double %9, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = load i64, ptr %5, align 8, !tbaa !11
  %11 = lshr i64 %10, 63
  %12 = shl i64 %11, 31
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %14 = load i64, ptr %5, align 8, !tbaa !11
  %15 = shl i64 %14, 1
  %16 = lshr i64 %15, 53
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %7, align 4, !tbaa !12
  %18 = load i32, ptr %7, align 4, !tbaa !12
  switch i32 %18, label %26 [
    i32 0, label %19
    i32 2047, label %22
  ]

19:                                               ; preds = %2
  %20 = load i32, ptr %6, align 4, !tbaa !12
  %21 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 1
  store i32 %20, ptr %21, align 4, !tbaa !14
  br label %33

22:                                               ; preds = %2
  %23 = load i32, ptr %6, align 4, !tbaa !12
  %24 = or i32 %23, 2147483647
  %25 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 1
  store i32 %24, ptr %25, align 4, !tbaa !14
  br label %33

26:                                               ; preds = %2
  %27 = load i32, ptr %6, align 4, !tbaa !12
  %28 = load i32, ptr %7, align 4, !tbaa !12
  %29 = add i32 %28, 1073741824
  %30 = sub i32 %29, 1024
  %31 = or i32 %27, %30
  %32 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 1
  store i32 %31, ptr %32, align 4, !tbaa !14
  br label %33

33:                                               ; preds = %26, %22, %19
  %34 = load i64, ptr %5, align 8, !tbaa !11
  %35 = lshr i64 %34, 20
  %36 = trunc i64 %35 to i32
  %37 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 0
  %38 = getelementptr inbounds [16 x i32], ptr %37, i64 0, i64 0
  store i32 %36, ptr %38, align 4, !tbaa !12
  %39 = load i64, ptr %5, align 8, !tbaa !11
  %40 = shl i64 %39, 12
  %41 = trunc i64 %40 to i32
  %42 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 0
  %43 = getelementptr inbounds [16 x i32], ptr %42, i64 0, i64 1
  store i32 %41, ptr %43, align 4, !tbaa !12
  %44 = getelementptr inbounds %"class.lol::real", ptr %8, i32 0, i32 0
  %45 = getelementptr inbounds [16 x i32], ptr %44, i64 0, i64 0
  %46 = getelementptr inbounds i32, ptr %45, i64 2
  call void @llvm.memset.p0.i64(ptr align 4 %46, i8 0, i64 56, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

declare void @_ZN3lol4realC1Ev(ptr)

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 64}
!15 = !{!"_ZTSN3lol4realE", !7, i64 0, !13, i64 64}


; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3lol4realC2Ed(ptr noundef nonnull align 4 dereferenceable(68) %0, double noundef %1) unnamed_addr #1 align 2 {
  tail call void @_ZN3lol4realC1Ev(ptr noundef nonnull align 4 dereferenceable(68) %0)
  %3 = bitcast double %1 to i64
  %4 = lshr i64 %3, 32
  %5 = trunc nuw i64 %4 to i32
  %6 = and i32 %5, -2147483648
  %7 = lshr i64 %3, 52
  %8 = trunc nuw nsw i64 %7 to i32
  %9 = and i32 %8, 2047
  switch i32 %9, label %12 [
    i32 0, label %15
    i32 2047, label %10
  ]

10:                                               ; preds = %2
  %11 = or i32 %5, 2147483647
  br label %15

12:                                               ; preds = %2
  %13 = add nuw nsw i32 %9, 1073740800
  %14 = or disjoint i32 %13, %6
  br label %15

15:                                               ; preds = %2, %12, %10
  %.sink = phi i32 [ %14, %12 ], [ %11, %10 ], [ %6, %2 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %.sink, ptr %16, align 4, !tbaa !5
  %17 = lshr i64 %3, 20
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %0, align 4, !tbaa !10
  %.tr = trunc i64 %3 to i32
  %19 = shl i32 %.tr, 12
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %19, ptr %20, align 4, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(56) %21, i8 0, i64 56, i1 false)
  ret void
}

declare void @_ZN3lol4realC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 64}
!6 = !{!"_ZTSN3lol4realE", !7, i64 0, !9, i64 64}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}


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