; LLVM IR from seung-lab/fpzip :: fpzip-1.3.0/src/rcdecoder.ll (ZN9RCdecoder9normalizeEv)

; 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.RCdecoder = type { ptr, i8, i32, i32, i32 }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9RCdecoder9normalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  br label %4

4:                                                ; preds = %16, %1
  %5 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 2
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 3
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %11 = add i32 %8, %10
  %12 = xor i32 %6, %11
  %13 = lshr i32 %12, 24
  %14 = icmp ne i32 %13, 0
  %15 = xor i1 %14, true
  br i1 %15, label %16, label %20

16:                                               ; preds = %4
  call void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef 1)
  %17 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 3
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = shl i32 %18, 8
  store i32 %19, ptr %17, align 8, !tbaa !13
  br label %4, !llvm.loop !14

20:                                               ; preds = %4
  %21 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = lshr i32 %22, 16
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %30, label %25

25:                                               ; preds = %20
  call void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef 2)
  %26 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 2
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = sub i32 0, %27
  %29 = getelementptr inbounds %class.RCdecoder, ptr %3, i32 0, i32 3
  store i32 %28, ptr %29, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %25, %20
  ret void
}

attributes #0 = { inlinehint 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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 12}
!10 = !{!"_ZTS9RCdecoder", !11, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 16}
!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: inlinehint mustprogress uwtable
declare dso_local void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9RCdecoder9normalizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 8, !tbaa !11
  %6 = add i32 %5, %4
  %7 = xor i32 %6, %4
  %.not4 = icmp ult i32 %7, 16777216
  br i1 %.not4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  tail call void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef 1)
  %8 = load i32, ptr %3, align 8, !tbaa !11
  %9 = shl i32 %8, 8
  store i32 %9, ptr %3, align 8, !tbaa !11
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = add i32 %9, %10
  %12 = xor i32 %11, %10
  %.not = icmp ult i32 %12, 16777216
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.lcssa = phi i32 [ %5, %1 ], [ %9, %.lr.ph ]
  %.not1 = icmp ult i32 %.lcssa, 65536
  br i1 %.not1, label %13, label %16

13:                                               ; preds = %._crit_edge
  tail call void @_ZN9RCdecoder3getEj(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef 2)
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sub i32 0, %14
  store i32 %15, ptr %3, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %13, %._crit_edge
  ret void
}

attributes #0 = { inlinehint 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 = { 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, !10, i64 12}
!6 = !{!"_ZTS9RCdecoder", !7, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass