; LLVM IR from facebook/redex :: libredex/IRInstruction.ll (ZNK13IRInstruction4hashEv)

; 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.IRInstruction = type { i16, i16, i32, %union.anon.0, %union.anon.1 }
%union.anon.0 = type { i64 }
%union.anon.1 = type { ptr, [8 x i8] }

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN6opcode3refE8IROpcode(i16 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13DexOpcodeData9data_sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK13DexOpcodeData4dataEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZNK13IRInstruction4hashEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %10 = call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %11 = zext i16 %10 to i64
  store i64 %11, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %24, %1
  %13 = load i64, ptr %4, align 8, !tbaa !9
  %14 = call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %27

17:                                               ; preds = %12
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = trunc i64 %18 to i16
  %20 = call noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32) %9, i16 noundef zeroext %19)
  %21 = zext i32 %20 to i64
  %22 = load i64, ptr %3, align 8, !tbaa !9
  %23 = xor i64 %22, %21
  store i64 %23, ptr %3, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %17
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = add i64 %25, 1
  store i64 %26, ptr %4, align 8, !tbaa !9
  br label %12, !llvm.loop !11

27:                                               ; preds = %16
  %28 = call noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br i1 %28, label %29, label %34

29:                                               ; preds = %27
  %30 = call noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %31 = zext i32 %30 to i64
  %32 = load i64, ptr %3, align 8, !tbaa !9
  %33 = xor i64 %32, %31
  store i64 %33, ptr %3, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %29, %27
  %35 = call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %36 = call noundef i32 @_ZN6opcode3refE8IROpcode(i16 noundef zeroext %35)
  switch i32 %36, label %65 [
    i32 8, label %37
    i32 9, label %60
    i32 6, label %60
    i32 7, label %60
    i32 4, label %60
    i32 5, label %60
    i32 1, label %60
    i32 2, label %60
    i32 3, label %60
    i32 0, label %65
  ]

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %38 = call noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %39 = call noundef i64 @_ZNK13DexOpcodeData9data_sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %38)
  store i64 %39, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %40 = call noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %41 = call noundef ptr @_ZNK13DexOpcodeData4dataEv(ptr noundef nonnull align 8 dereferenceable(40) %40)
  store ptr %41, ptr %7, align 8, !tbaa !5
  store ptr %7, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %56, %37
  %43 = load i64, ptr %8, align 8, !tbaa !9
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %59

47:                                               ; preds = %42
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = getelementptr inbounds i16, ptr %49, i64 %50
  %52 = load i16, ptr %51, align 2, !tbaa !13
  %53 = zext i16 %52 to i64
  %54 = load i64, ptr %3, align 8, !tbaa !9
  %55 = xor i64 %54, %53
  store i64 %55, ptr %3, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %47
  %57 = load i64, ptr %8, align 8, !tbaa !9
  %58 = add i64 %57, 1
  store i64 %58, ptr %8, align 8, !tbaa !9
  br label %42, !llvm.loop !15

59:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %65

60:                                               ; preds = %34, %34, %34, %34, %34, %34, %34, %34
  %61 = getelementptr inbounds %class.IRInstruction, ptr %9, i32 0, i32 3
  %62 = load i64, ptr %61, align 8, !tbaa !16
  %63 = load i64, ptr %3, align 8, !tbaa !9
  %64 = xor i64 %63, %62
  store i64 %64, ptr %3, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %60, %59, %34, %34
  %66 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret i64 %66
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = !{!7, !7, 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN6opcode3refE8IROpcode(i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13DexOpcodeData9data_sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK13DexOpcodeData4dataEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZNK13IRInstruction4hashEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #2 align 2 {
  %2 = tail call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %3 = zext i16 %2 to i64
  %4 = tail call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.013.lcssa = phi i64 [ %3, %1 ], [ %9, %.lr.ph ]
  %5 = tail call noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br i1 %5, label %13, label %17

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.01316 = phi i64 [ %9, %.lr.ph ], [ %3, %1 ]
  %.01415 = phi i64 [ %10, %.lr.ph ], [ 0, %1 ]
  %6 = trunc i64 %.01415 to i16
  %7 = tail call noundef i32 @_ZNK13IRInstruction3srcEt(ptr noundef nonnull align 8 dereferenceable(32) %0, i16 noundef zeroext %6)
  %8 = zext i32 %7 to i64
  %9 = xor i64 %.01316, %8
  %10 = add nuw i64 %.01415, 1
  %11 = tail call noundef i64 @_ZNK13IRInstruction9srcs_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %12 = icmp ult i64 %10, %11
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !5

13:                                               ; preds = %._crit_edge
  %14 = tail call noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %15 = zext i32 %14 to i64
  %16 = xor i64 %.013.lcssa, %15
  br label %17

17:                                               ; preds = %13, %._crit_edge
  %.1 = phi i64 [ %16, %13 ], [ %.013.lcssa, %._crit_edge ]
  %18 = tail call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %19 = tail call noundef i32 @_ZN6opcode3refE8IROpcode(i16 noundef zeroext %18)
  switch i32 %19, label %.loopexit [
    i32 8, label %20
    i32 9, label %39
    i32 6, label %39
    i32 7, label %39
    i32 4, label %39
    i32 5, label %39
    i32 1, label %39
    i32 2, label %39
    i32 3, label %39
  ]

20:                                               ; preds = %17
  %21 = tail call noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %22 = tail call noundef i64 @_ZNK13DexOpcodeData9data_sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %21)
  %23 = tail call noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %24 = tail call noundef ptr @_ZNK13DexOpcodeData4dataEv(ptr noundef nonnull align 8 dereferenceable(40) %23)
  %.not22 = icmp eq i64 %22, 0
  br i1 %.not22, label %.loopexit, label %.lr.ph20.preheader

.lr.ph20.preheader:                               ; preds = %20
  %min.iters.check = icmp ult i64 %22, 4
  br i1 %min.iters.check, label %.lr.ph20.preheader28, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph20.preheader
  %n.vec = and i64 %22, -4
  %25 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %.1, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ %25, %vector.ph ], [ %30, %vector.body ]
  %vec.phi26 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %31, %vector.body ]
  %26 = getelementptr inbounds i16, ptr %24, i64 %index
  %27 = getelementptr inbounds i8, ptr %26, i64 4
  %wide.load = load <2 x i16>, ptr %26, align 2, !tbaa !7
  %wide.load27 = load <2 x i16>, ptr %27, align 2, !tbaa !7
  %28 = zext <2 x i16> %wide.load to <2 x i64>
  %29 = zext <2 x i16> %wide.load27 to <2 x i64>
  %30 = xor <2 x i64> %vec.phi, %28
  %31 = xor <2 x i64> %vec.phi26, %29
  %index.next = add nuw i64 %index, 4
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = xor <2 x i64> %31, %30
  %33 = tail call i64 @llvm.vector.reduce.xor.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %22, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph20.preheader28

.lr.ph20.preheader28:                             ; preds = %middle.block, %.lr.ph20.preheader
  %.018.ph = phi i64 [ 0, %.lr.ph20.preheader ], [ %n.vec, %middle.block ]
  %.217.ph = phi i64 [ %.1, %.lr.ph20.preheader ], [ %33, %middle.block ]
  br label %.lr.ph20

.lr.ph20:                                         ; preds = %.lr.ph20.preheader28, %.lr.ph20
  %.018 = phi i64 [ %38, %.lr.ph20 ], [ %.018.ph, %.lr.ph20.preheader28 ]
  %.217 = phi i64 [ %37, %.lr.ph20 ], [ %.217.ph, %.lr.ph20.preheader28 ]
  %34 = getelementptr inbounds i16, ptr %24, i64 %.018
  %35 = load i16, ptr %34, align 2, !tbaa !7
  %36 = zext i16 %35 to i64
  %37 = xor i64 %.217, %36
  %38 = add nuw i64 %.018, 1
  %exitcond.not = icmp eq i64 %38, %22
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph20, !llvm.loop !14

39:                                               ; preds = %17, %17, %17, %17, %17, %17, %17, %17
  %40 = getelementptr inbounds i8, ptr %0, i64 8
  %41 = load i64, ptr %40, align 8, !tbaa !15
  %42 = xor i64 %41, %.1
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph20, %middle.block, %20, %39, %17
  %.3 = phi i64 [ %.1, %17 ], [ %42, %39 ], [ %.1, %20 ], [ %33, %middle.block ], [ %37, %.lr.ph20 ]
  ret i64 %.3
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK13IRInstruction8get_dataEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.xor.v2i64(<2 x i64>) #3

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 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 = { 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 #3 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"short", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !6, !13, !12}
!15 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass