; LLVM IR from xxtea/xxtea-c :: xxtea (xxtea_decrypt)

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 ptr @xxtea_decrypt(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca [16 x i8], align 16
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #3
  %11 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 1 %12, i64 16, i1 false)
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %25, %4
  %14 = load i64, ptr %9, align 8, !tbaa !9
  %15 = icmp ult i64 %14, 16
  br i1 %15, label %16, label %22

16:                                               ; preds = %13
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = icmp ne i32 %20, 0
  br label %22

22:                                               ; preds = %16, %13
  %23 = phi i1 [ false, %13 ], [ %21, %16 ]
  br i1 %23, label %24, label %28

24:                                               ; preds = %22
  br label %25

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

28:                                               ; preds = %22
  %29 = load i64, ptr %9, align 8, !tbaa !9
  %30 = add i64 %29, 1
  store i64 %30, ptr %9, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %37, %28
  %32 = load i64, ptr %9, align 8, !tbaa !9
  %33 = icmp ult i64 %32, 16
  br i1 %33, label %34, label %40

34:                                               ; preds = %31
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 %35
  store i8 0, ptr %36, align 1, !tbaa !11
  br label %37

37:                                               ; preds = %34
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = add i64 %38, 1
  store i64 %39, ptr %9, align 8, !tbaa !9
  br label %31, !llvm.loop !14

40:                                               ; preds = %31
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = call ptr @xxtea_ubyte_decrypt(ptr noundef %41, i64 noundef %42, ptr noundef %43, ptr noundef %44)
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %45
}

; Function Attrs: nounwind uwtable
declare hidden ptr @xxtea_ubyte_decrypt(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

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


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress 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 ptr @xxtea_decrypt(ptr noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 1 dereferenceable(16) %2, i64 16, i1 false)
  %6 = load i8, ptr %5, align 16, !tbaa !5
  %.not = icmp eq i8 %6, 0
  %.0.lcssa.ph.sroa.gep = getelementptr inbounds i8, ptr %5, i64 14
  %.0.lcssa.ph.sroa.gep14 = getelementptr inbounds i8, ptr %5, i64 13
  %.0.lcssa.ph.sroa.gep15 = getelementptr inbounds i8, ptr %5, i64 12
  %.0.lcssa.ph.sroa.gep16 = getelementptr inbounds i8, ptr %5, i64 11
  %.0.lcssa.ph.sroa.gep17 = getelementptr inbounds i8, ptr %5, i64 10
  %.0.lcssa.ph.sroa.gep18 = getelementptr inbounds i8, ptr %5, i64 9
  %.0.lcssa.ph.sroa.gep19 = getelementptr inbounds i8, ptr %5, i64 8
  %.0.lcssa.ph.sroa.gep20 = getelementptr inbounds i8, ptr %5, i64 7
  %.0.lcssa.ph.sroa.gep21 = getelementptr inbounds i8, ptr %5, i64 6
  %.0.lcssa.ph.sroa.gep22 = getelementptr inbounds i8, ptr %5, i64 5
  %.0.lcssa.ph.sroa.gep23 = getelementptr inbounds i8, ptr %5, i64 4
  %.0.lcssa.ph.sroa.gep24 = getelementptr inbounds i8, ptr %5, i64 3
  %.0.lcssa.ph.sroa.gep25 = getelementptr inbounds i8, ptr %5, i64 2
  br i1 %.not, label %.lr.ph.preheader, label %7

7:                                                ; preds = %4
  %.0.lcssa.ph.sroa.gep26 = getelementptr inbounds i8, ptr %5, i64 1
  %8 = getelementptr inbounds i8, ptr %5, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %.not.1 = icmp eq i8 %9, 0
  br i1 %.not.1, label %.lr.ph.preheader, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %5, i64 2
  %12 = load i8, ptr %11, align 2, !tbaa !5
  %.not.2 = icmp eq i8 %12, 0
  br i1 %.not.2, label %.lr.ph.preheader, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %5, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %.not.3 = icmp eq i8 %15, 0
  br i1 %.not.3, label %.lr.ph.preheader, label %16

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %5, i64 4
  %18 = load i8, ptr %17, align 4, !tbaa !5
  %.not.4 = icmp eq i8 %18, 0
  br i1 %.not.4, label %.lr.ph.preheader, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %5, i64 5
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not.5 = icmp eq i8 %21, 0
  br i1 %.not.5, label %.lr.ph.preheader, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %5, i64 6
  %24 = load i8, ptr %23, align 2, !tbaa !5
  %.not.6 = icmp eq i8 %24, 0
  br i1 %.not.6, label %.lr.ph.preheader, label %25

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %5, i64 7
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %.not.7 = icmp eq i8 %27, 0
  br i1 %.not.7, label %.lr.ph.preheader, label %28

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %5, i64 8
  %30 = load i8, ptr %29, align 8, !tbaa !5
  %.not.8 = icmp eq i8 %30, 0
  br i1 %.not.8, label %.lr.ph.preheader, label %31

31:                                               ; preds = %28
  %32 = getelementptr inbounds i8, ptr %5, i64 9
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %.not.9 = icmp eq i8 %33, 0
  br i1 %.not.9, label %.lr.ph.preheader, label %34

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %5, i64 10
  %36 = load i8, ptr %35, align 2, !tbaa !5
  %.not.10 = icmp eq i8 %36, 0
  br i1 %.not.10, label %.lr.ph.preheader, label %37

37:                                               ; preds = %34
  %38 = getelementptr inbounds i8, ptr %5, i64 11
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %.not.11 = icmp eq i8 %39, 0
  br i1 %.not.11, label %.lr.ph.preheader, label %40

40:                                               ; preds = %37
  %41 = getelementptr inbounds i8, ptr %5, i64 12
  %42 = load i8, ptr %41, align 4, !tbaa !5
  %.not.12 = icmp eq i8 %42, 0
  br i1 %.not.12, label %.lr.ph.preheader, label %43

43:                                               ; preds = %40
  %44 = getelementptr inbounds i8, ptr %5, i64 13
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %.not.13 = icmp eq i8 %45, 0
  br i1 %.not.13, label %.lr.ph.preheader, label %46

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %5, i64 14
  %48 = load i8, ptr %47, align 2, !tbaa !5
  %.not.14 = icmp eq i8 %48, 0
  br i1 %.not.14, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4, %7, %10, %13, %16, %19, %22, %25, %28, %31, %34, %37, %40, %43, %46
  %.0.lcssa.ph.sroa.phi = phi ptr [ %.0.lcssa.ph.sroa.gep, %46 ], [ %.0.lcssa.ph.sroa.gep14, %43 ], [ %.0.lcssa.ph.sroa.gep15, %40 ], [ %.0.lcssa.ph.sroa.gep16, %37 ], [ %.0.lcssa.ph.sroa.gep17, %34 ], [ %.0.lcssa.ph.sroa.gep18, %31 ], [ %.0.lcssa.ph.sroa.gep19, %28 ], [ %.0.lcssa.ph.sroa.gep20, %25 ], [ %.0.lcssa.ph.sroa.gep21, %22 ], [ %.0.lcssa.ph.sroa.gep22, %19 ], [ %.0.lcssa.ph.sroa.gep23, %16 ], [ %.0.lcssa.ph.sroa.gep24, %13 ], [ %.0.lcssa.ph.sroa.gep25, %10 ], [ %.0.lcssa.ph.sroa.gep26, %7 ], [ %5, %4 ]
  %.0.lcssa.ph = phi i64 [ 1, %46 ], [ 2, %43 ], [ 3, %40 ], [ 4, %37 ], [ 5, %34 ], [ 6, %31 ], [ 7, %28 ], [ 8, %25 ], [ 9, %22 ], [ 10, %19 ], [ 11, %16 ], [ 12, %13 ], [ 13, %10 ], [ 14, %7 ], [ 15, %4 ]
  %scevgep = getelementptr i8, ptr %.0.lcssa.ph.sroa.phi, i64 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %scevgep, i8 0, i64 %.0.lcssa.ph, i1 false), !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %46, %.lr.ph.preheader
  %49 = call ptr @xxtea_ubyte_decrypt(ptr noundef %0, i64 noundef %1, ptr noundef nonnull %5, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret ptr %49
}

; Function Attrs: nounwind uwtable
declare hidden ptr @xxtea_ubyte_decrypt(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass