; LLVM IR from zeux/meshoptimizer :: gltf/image.ll (Z16adjustDimensionsRiS_fib)

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

; 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 uwtable
define dso_local void @_Z16adjustDimensionsRiS_fib(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, float noundef %2, i32 noundef %3, i1 noundef zeroext %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  %12 = zext i1 %4 to i8
  store i8 %12, ptr %10, align 1, !tbaa !13
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = sitofp i32 %14 to float
  %16 = load float, ptr %8, align 4, !tbaa !9
  %17 = fmul float %15, %16
  %18 = fptosi float %17 to i32
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %18, ptr %19, align 4, !tbaa !11
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = sitofp i32 %21 to float
  %23 = load float, ptr %8, align 4, !tbaa !9
  %24 = fmul float %22, %23
  %25 = fptosi float %24 to i32
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %25, ptr %26, align 4, !tbaa !11
  %27 = load i32, ptr %9, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %71

29:                                               ; preds = %5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = load i32, ptr %9, align 4, !tbaa !11
  %33 = icmp sgt i32 %31, %32
  br i1 %33, label %39, label %34

34:                                               ; preds = %29
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = load i32, ptr %9, align 4, !tbaa !11
  %38 = icmp sgt i32 %36, %37
  br i1 %38, label %39, label %71

39:                                               ; preds = %34, %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %40 = load i32, ptr %9, align 4, !tbaa !11
  %41 = sitofp i32 %40 to float
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = icmp sgt i32 %43, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %39
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 4, !tbaa !11
  br label %53

50:                                               ; preds = %39
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load i32, ptr %51, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %50, %47
  %54 = phi i32 [ %49, %47 ], [ %52, %50 ]
  %55 = sitofp i32 %54 to float
  %56 = fdiv float %41, %55
  store float %56, ptr %11, align 4, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = sitofp i32 %58 to float
  %60 = load float, ptr %11, align 4, !tbaa !9
  %61 = fmul float %59, %60
  %62 = fptosi float %61 to i32
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %62, ptr %63, align 4, !tbaa !11
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = sitofp i32 %65 to float
  %67 = load float, ptr %11, align 4, !tbaa !9
  %68 = fmul float %66, %67
  %69 = fptosi float %68 to i32
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %69, ptr %70, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %71

71:                                               ; preds = %53, %34, %5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i32, ptr %72, align 4, !tbaa !11
  %74 = load i8, ptr %10, align 1, !tbaa !13, !range !15, !noundef !16
  %75 = trunc i8 %74 to i1
  %76 = call noundef i32 @_ZL10roundBlockib(i32 noundef %73, i1 noundef zeroext %75)
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %76, ptr %77, align 4, !tbaa !11
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = load i8, ptr %10, align 1, !tbaa !13, !range !15, !noundef !16
  %81 = trunc i8 %80 to i1
  %82 = call noundef i32 @_ZL10roundBlockib(i32 noundef %79, i1 noundef zeroext %81)
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %82, ptr %83, align 4, !tbaa !11
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL10roundBlockib(i32 noundef, i1 noundef zeroext) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 uwtable
define dso_local void @_Z16adjustDimensionsRiS_fib(ptr nocapture noundef nonnull align 4 dereferenceable(4) %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1, float noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %0, align 4, !tbaa !5
  %7 = sitofp i32 %6 to float
  %8 = fmul float %7, %2
  %9 = fptosi float %8 to i32
  store i32 %9, ptr %0, align 4, !tbaa !5
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sitofp i32 %10 to float
  %12 = fmul float %11, %2
  %13 = fptosi float %12 to i32
  store i32 %13, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  %.pre29 = load i32, ptr %0, align 4, !tbaa !5
  br i1 %.not, label %28, label %14

14:                                               ; preds = %5
  %15 = icmp sgt i32 %.pre29, %3
  %16 = icmp sgt i32 %13, %3
  %or.cond = select i1 %15, i1 true, i1 %16
  br i1 %or.cond, label %17, label %28

17:                                               ; preds = %14
  %18 = sitofp i32 %3 to float
  %. = tail call i32 @llvm.smax.i32(i32 %.pre29, i32 %13)
  %19 = sitofp i32 %. to float
  %20 = fdiv float %18, %19
  %21 = sitofp i32 %.pre29 to float
  %22 = fmul float %20, %21
  %23 = fptosi float %22 to i32
  store i32 %23, ptr %0, align 4, !tbaa !5
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sitofp i32 %24 to float
  %26 = fmul float %20, %25
  %27 = fptosi float %26 to i32
  store i32 %27, ptr %1, align 4, !tbaa !5
  %.pre = load i32, ptr %0, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %14, %17, %5
  %29 = phi i32 [ %.pre29, %14 ], [ %.pre, %17 ], [ %.pre29, %5 ]
  %30 = tail call noundef i32 @_ZL10roundBlockib(i32 noundef %29, i1 noundef zeroext %4)
  store i32 %30, ptr %0, align 4, !tbaa !5
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = tail call noundef i32 @_ZL10roundBlockib(i32 noundef %31, i1 noundef zeroext %4)
  store i32 %32, ptr %1, align 4, !tbaa !5
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL10roundBlockib(i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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"}


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