; LLVM IR from jedisct1/charm :: src (charm)

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

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

; Function Attrs: nounwind uwtable
declare hidden void @permute(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @endian_swap_rate(ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @xor128(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mem_cpy(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @squeeze_permute(ptr noundef, ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @uc_decrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca [16 x i8], align 16
  %13 = alloca [16 x i8], align 16
  %14 = alloca [17 x i8], align 16
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i64 %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 17, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = icmp ugt i64 %18, 16
  br i1 %19, label %20, label %44

20:                                               ; preds = %5
  br label %21

21:                                               ; preds = %40, %20
  %22 = load i64, ptr %15, align 8, !tbaa !9
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = sub i64 %23, 16
  %25 = icmp ult i64 %22, %24
  br i1 %25, label %26, label %43

26:                                               ; preds = %21
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %27)
  %28 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %28, ptr align 4 %29, i64 16, i1 false)
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %15, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  call void @xor128(ptr noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i64, ptr %15, align 8, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %35, i64 %36
  call void @xor128(ptr noundef %34, ptr noundef %37)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %38)
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  call void @permute(ptr noundef %39)
  br label %40

40:                                               ; preds = %26
  %41 = load i64, ptr %15, align 8, !tbaa !9
  %42 = add i64 %41, 16
  store i64 %42, ptr %15, align 8, !tbaa !9
  br label %21, !llvm.loop !11

43:                                               ; preds = %21
  br label %44

44:                                               ; preds = %43, %5
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = load i64, ptr %15, align 8, !tbaa !9
  %47 = sub i64 %45, %46
  store i64 %47, ptr %16, align 8, !tbaa !9
  %48 = getelementptr inbounds [17 x i8], ptr %14, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %48, i8 0, i64 16, i1 false)
  %49 = getelementptr inbounds [17 x i8], ptr %14, i64 0, i64 0
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %15, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = load i64, ptr %16, align 8, !tbaa !9
  call void @mem_cpy(ptr noundef %49, ptr noundef %52, i64 noundef %53)
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %54)
  %55 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %55, i8 0, i64 16, i1 false)
  %56 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i64, ptr %16, align 8, !tbaa !9
  call void @mem_cpy(ptr noundef %56, ptr noundef %57, i64 noundef %58)
  %59 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  call void @xor128(ptr noundef %14, ptr noundef %59)
  %60 = load i64, ptr %16, align 8, !tbaa !9
  %61 = getelementptr inbounds [17 x i8], ptr %14, i64 0, i64 %60
  store i8 -128, ptr %61, align 1, !tbaa !13
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds [17 x i8], ptr %14, i64 0, i64 0
  call void @xor128(ptr noundef %62, ptr noundef %63)
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %64)
  %65 = load i64, ptr %16, align 8, !tbaa !9
  %66 = trunc i64 %65 to i32
  %67 = lshr i32 %66, 4
  %68 = shl i32 %67, 25
  %69 = zext i32 %68 to i64
  %70 = or i64 16777216, %69
  %71 = or i64 %70, 67108864
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds i32, ptr %72, i64 11
  %74 = load i32, ptr %73, align 4, !tbaa !14
  %75 = zext i32 %74 to i64
  %76 = xor i64 %75, %71
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %73, align 4, !tbaa !14
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = load i64, ptr %15, align 8, !tbaa !9
  %80 = getelementptr inbounds i8, ptr %78, i64 %79
  %81 = getelementptr inbounds [17 x i8], ptr %14, i64 0, i64 0
  %82 = load i64, ptr %16, align 8, !tbaa !9
  call void @mem_cpy(ptr noundef %80, ptr noundef %81, i64 noundef %82)
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  call void @permute(ptr noundef %83)
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  call void @squeeze_permute(ptr noundef %84, ptr noundef %85)
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %88 = load i64, ptr %11, align 8, !tbaa !9
  %89 = call i32 @equals(ptr noundef %86, ptr noundef %87, i64 noundef %88)
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %44
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %92, i8 0, i64 %93, i1 false)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %95

94:                                               ; preds = %44
  store i32 0, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %95

95:                                               ; preds = %94, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 17, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  %96 = load i32, ptr %6, align 4
  ret i32 %96
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @equals(ptr noundef, ptr noundef, i64 noundef) #4

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

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

; Function Attrs: nounwind uwtable
declare hidden void @permute(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @endian_swap_rate(ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @xor128(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mem_cpy(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @squeeze_permute(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @uc_decrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #2 {
  %6 = alloca [16 x i8], align 16
  %7 = alloca [16 x i8], align 16
  %8 = alloca [17 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 17, ptr nonnull %8) #5
  %9 = icmp ugt i64 %2, 16
  br i1 %9, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %5
  %10 = add i64 %2, -16
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.03536 = phi i64 [ %12, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  call void @endian_swap_rate(ptr noundef %0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(16) %0, i64 16, i1 false)
  %11 = getelementptr inbounds i8, ptr %1, i64 %.03536
  call void @xor128(ptr noundef %11, ptr noundef nonnull %7)
  call void @xor128(ptr noundef %0, ptr noundef %11)
  call void @endian_swap_rate(ptr noundef %0)
  call void @permute(ptr noundef %0)
  %12 = add i64 %.03536, 16
  %13 = icmp ult i64 %12, %10
  br i1 %13, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %.lr.ph, %5
  %.1 = phi i64 [ 0, %5 ], [ %12, %.lr.ph ]
  %14 = sub i64 %2, %.1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  %15 = getelementptr inbounds i8, ptr %1, i64 %.1
  call void @mem_cpy(ptr noundef nonnull %8, ptr noundef %15, i64 noundef %14)
  call void @endian_swap_rate(ptr noundef %0)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  call void @mem_cpy(ptr noundef nonnull %7, ptr noundef %0, i64 noundef %14)
  call void @xor128(ptr noundef nonnull %8, ptr noundef nonnull %7)
  %16 = getelementptr inbounds [17 x i8], ptr %8, i64 0, i64 %14
  store i8 -128, ptr %16, align 1, !tbaa !7
  call void @xor128(ptr noundef %0, ptr noundef nonnull %8)
  call void @endian_swap_rate(ptr noundef %0)
  %17 = getelementptr inbounds i8, ptr %0, i64 44
  %18 = load i32, ptr %17, align 4, !tbaa !10
  %.tr = trunc i64 %14 to i32
  %19 = shl i32 %.tr, 21
  %20 = and i32 %19, -100663296
  %21 = or disjoint i32 %20, 83886080
  %22 = xor i32 %18, %21
  store i32 %22, ptr %17, align 4, !tbaa !10
  call void @mem_cpy(ptr noundef %15, ptr noundef nonnull %8, i64 noundef %14)
  call void @permute(ptr noundef %0)
  call void @squeeze_permute(ptr noundef %0, ptr noundef nonnull %6)
  %23 = call i32 @equals(ptr noundef %3, ptr noundef nonnull %6, i64 noundef %4)
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %.loopexit
  call void @llvm.memset.p0.i64(ptr align 1 %1, i8 0, i64 %2, i1 false)
  br label %26

26:                                               ; preds = %.loopexit, %25
  %.0 = phi i32 [ -1, %25 ], [ 0, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 17, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @equals(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #5 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}


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