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

; 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.0 = type { double }
%"class.lol::real" = type { [16 x i32], i32 }

; 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: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %union.anon.0, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %7 = getelementptr inbounds %"class.lol::real", ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = lshr i32 %8, 31
  %10 = zext i32 %9 to i64
  store i64 %10, ptr %3, align 8, !tbaa !12
  %11 = load i64, ptr %3, align 8, !tbaa !12
  %12 = shl i64 %11, 11
  store i64 %12, ptr %3, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %13 = getelementptr inbounds %"class.lol::real", ptr %6, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = shl i32 %14, 1
  %16 = lshr i32 %15, 1
  store i32 %16, ptr %4, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %17 = load i32, ptr %4, align 4, !tbaa !13
  %18 = sub nsw i32 %17, 1073741824
  %19 = add nsw i32 %18, 1024
  store i32 %19, ptr %5, align 4, !tbaa !13
  %20 = load i32, ptr %5, align 4, !tbaa !13
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %1
  %23 = load i64, ptr %3, align 8, !tbaa !12
  %24 = shl i64 %23, 52
  store i64 %24, ptr %3, align 8, !tbaa !12
  br label %64

25:                                               ; preds = %1
  %26 = load i32, ptr %5, align 4, !tbaa !13
  %27 = icmp sge i32 %26, 2047
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load i64, ptr %3, align 8, !tbaa !12
  %30 = or i64 %29, 2047
  store i64 %30, ptr %3, align 8, !tbaa !12
  %31 = load i64, ptr %3, align 8, !tbaa !12
  %32 = shl i64 %31, 52
  store i64 %32, ptr %3, align 8, !tbaa !12
  br label %63

33:                                               ; preds = %25
  %34 = load i32, ptr %5, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = load i64, ptr %3, align 8, !tbaa !12
  %37 = or i64 %36, %35
  store i64 %37, ptr %3, align 8, !tbaa !12
  %38 = load i64, ptr %3, align 8, !tbaa !12
  %39 = shl i64 %38, 32
  store i64 %39, ptr %3, align 8, !tbaa !12
  %40 = getelementptr inbounds %"class.lol::real", ptr %6, i32 0, i32 0
  %41 = getelementptr inbounds [16 x i32], ptr %40, i64 0, i64 0
  %42 = load i32, ptr %41, align 4, !tbaa !13
  %43 = zext i32 %42 to i64
  %44 = load i64, ptr %3, align 8, !tbaa !12
  %45 = or i64 %44, %43
  store i64 %45, ptr %3, align 8, !tbaa !12
  %46 = load i64, ptr %3, align 8, !tbaa !12
  %47 = shl i64 %46, 20
  store i64 %47, ptr %3, align 8, !tbaa !12
  %48 = getelementptr inbounds %"class.lol::real", ptr %6, i32 0, i32 0
  %49 = getelementptr inbounds [16 x i32], ptr %48, i64 0, i64 1
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = lshr i32 %50, 12
  %52 = zext i32 %51 to i64
  %53 = load i64, ptr %3, align 8, !tbaa !12
  %54 = or i64 %53, %52
  store i64 %54, ptr %3, align 8, !tbaa !12
  %55 = getelementptr inbounds %"class.lol::real", ptr %6, i32 0, i32 0
  %56 = getelementptr inbounds [16 x i32], ptr %55, i64 0, i64 1
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = lshr i32 %57, 11
  %59 = and i32 %58, 1
  %60 = zext i32 %59 to i64
  %61 = load i64, ptr %3, align 8, !tbaa !12
  %62 = add i64 %61, %60
  store i64 %62, ptr %3, align 8, !tbaa !12
  br label %63

63:                                               ; preds = %33, %28
  br label %64

64:                                               ; preds = %63, %22
  %65 = load double, ptr %3, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret double %65
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 64}
!10 = !{!"_ZTSN3lol4realE", !7, i64 0, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!11, !11, 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 noundef double @_ZNK3lol4realcvdEv(ptr nocapture noundef nonnull readonly align 4 dereferenceable(68) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = lshr i32 %3, 20
  %5 = and i32 %4, 2048
  %6 = zext nneg i32 %5 to i64
  %7 = and i32 %3, 2147483647
  %8 = add i32 %3, 1024
  %9 = icmp ult i32 %7, 1073740800
  br i1 %9, label %10, label %12

10:                                               ; preds = %1
  %11 = shl nuw i64 %6, 52
  br label %34

12:                                               ; preds = %1
  %13 = icmp ugt i32 %7, 1073742846
  br i1 %13, label %14, label %17

14:                                               ; preds = %12
  %15 = shl nuw i64 %6, 52
  %16 = or disjoint i64 %15, 9218868437227405312
  br label %34

17:                                               ; preds = %12
  %18 = or i32 %5, %8
  %19 = zext i32 %18 to i64
  %20 = load i32, ptr %0, align 4, !tbaa !10
  %21 = zext i32 %20 to i64
  %22 = shl i64 %19, 52
  %23 = shl nuw nsw i64 %21, 20
  %24 = or disjoint i64 %23, %22
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !10
  %27 = lshr i32 %26, 12
  %28 = zext nneg i32 %27 to i64
  %29 = or disjoint i64 %24, %28
  %30 = lshr i32 %26, 11
  %31 = and i32 %30, 1
  %32 = zext nneg i32 %31 to i64
  %33 = add i64 %29, %32
  br label %34

34:                                               ; preds = %14, %17, %10
  %.sroa.0.0.in = phi i64 [ %11, %10 ], [ %16, %14 ], [ %33, %17 ]
  %.sroa.0.0 = bitcast i64 %.sroa.0.0.in to double
  ret double %.sroa.0.0
}

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, !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,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass