; LLVM IR from sslab-gatech/janus :: lkl/arch/parisc/math-emu (fcnvuf)

; 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.dblwd = type { 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: nounwind uwtable
define dso_local i32 @sgl_to_dbl_fcnvuf(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %17, ptr %11, align 4, !tbaa !9
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %27

20:                                               ; preds = %4
  store i32 0, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %13, align 4, !tbaa !9
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.dblwd, ptr %22, i32 0, i32 0
  store i32 %21, ptr %23, align 4, !tbaa !11
  %24 = load i32, ptr %13, align 4, !tbaa !9
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.dblwd, ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 4, !tbaa !13
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %88

27:                                               ; preds = %4
  store i32 16, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 8, ptr %15, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %46, %27
  %29 = load i32, ptr %15, align 4, !tbaa !9
  %30 = icmp sge i32 %29, 1
  br i1 %30, label %31, label %49

31:                                               ; preds = %28
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = sub nsw i32 32, %33
  %35 = lshr i32 %32, %34
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %31
  %38 = load i32, ptr %15, align 4, !tbaa !9
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sub nsw i32 %39, %38
  store i32 %40, ptr %10, align 4, !tbaa !9
  br label %45

41:                                               ; preds = %31
  %42 = load i32, ptr %15, align 4, !tbaa !9
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = add nsw i32 %43, %42
  store i32 %44, ptr %10, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %41, %37
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = ashr i32 %47, 1
  store i32 %48, ptr %15, align 4, !tbaa !9
  br label %28, !llvm.loop !14

49:                                               ; preds = %28
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = sub nsw i32 32, %51
  %53 = lshr i32 %50, %52
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %49
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %10, align 4, !tbaa !9
  br label %61

58:                                               ; preds = %49
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = sub nsw i32 %59, 2
  store i32 %60, ptr %10, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %58, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = shl i32 %64, %63
  store i32 %65, ptr %11, align 4, !tbaa !9
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = and i32 %66, -1048576
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = lshr i32 %68, 11
  %70 = and i32 %69, 1048575
  %71 = shl i32 %70, 0
  %72 = or i32 %67, %71
  store i32 %72, ptr %12, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = shl i32 %73, 21
  store i32 %74, ptr %13, align 4, !tbaa !9
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = and i32 %75, -2146435073
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = sub nsw i32 1053, %77
  %79 = and i32 %78, 2047
  %80 = shl i32 %79, 20
  %81 = or i32 %76, %80
  store i32 %81, ptr %12, align 4, !tbaa !9
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.dblwd, ptr %83, i32 0, i32 0
  store i32 %82, ptr %84, align 4, !tbaa !11
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.dblwd, ptr %86, i32 0, i32 1
  store i32 %85, ptr %87, align 4, !tbaa !13
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %88

88:                                               ; preds = %61, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %89 = load i32, ptr %5, align 4
  ret i32 %89
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"dblwd", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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: readwrite) uwtable
define dso_local noundef i32 @sgl_to_dbl_fcnvuf(ptr nocapture noundef readonly %0, ptr nocapture noundef readnone %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef readnone %3) local_unnamed_addr #0 {
  %5 = load i32, ptr %0, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %25, label %.preheader.preheader

.preheader.preheader:                             ; preds = %4
  %.not32 = icmp ult i32 %5, 65536
  %.1 = select i1 %.not32, i32 24, i32 8
  %7 = sub nuw nsw i32 32, %.1
  %8 = lshr i32 %5, %7
  %.not32.1 = icmp eq i32 %8, 0
  %.1.p.1 = select i1 %.not32.1, i32 4, i32 -4
  %.1.1 = add nsw i32 %.1.p.1, %.1
  %9 = sub nuw nsw i32 32, %.1.1
  %10 = lshr i32 %5, %9
  %.not32.2 = icmp eq i32 %10, 0
  %.1.p.2 = select i1 %.not32.2, i32 2, i32 -2
  %.1.2 = add nsw i32 %.1.p.2, %.1.1
  %11 = sub nuw nsw i32 32, %.1.2
  %12 = lshr i32 %5, %11
  %.not32.3 = icmp eq i32 %12, 0
  %.1.p.3 = select i1 %.not32.3, i32 1, i32 -1
  %.1.3 = add nsw i32 %.1.p.3, %.1.2
  %13 = sub nuw nsw i32 32, %.1.3
  %14 = lshr i32 %5, %13
  %15 = icmp eq i32 %14, 0
  %.2.v = select i1 %15, i32 -1, i32 -2
  %.2 = add nsw i32 %.2.v, %.1.3
  %16 = add nsw i32 %.2, 1
  %17 = shl i32 %5, %16
  %18 = lshr i32 %17, 11
  %19 = and i32 %18, 1048575
  %20 = shl i32 %17, 21
  %21 = shl nsw i32 %.2, 20
  %22 = sub i32 1104150528, %21
  %23 = and i32 %22, 2146435072
  %24 = or disjoint i32 %19, %23
  br label %25

25:                                               ; preds = %4, %.preheader.preheader
  %.sink36 = phi i32 [ %24, %.preheader.preheader ], [ 0, %4 ]
  %.sink = phi i32 [ %20, %.preheader.preheader ], [ 0, %4 ]
  store i32 %.sink36, ptr %2, align 4, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %.sink, ptr %26, align 4, !tbaa !11
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"dblwd", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass