; 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: nounwind uwtable
define dso_local void @uc_encrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [16 x i8], align 16
  %10 = alloca [17 x i8], align 16
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 17, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp ugt i64 %13, 16
  br i1 %14, label %15, label %39

15:                                               ; preds = %4
  br label %16

16:                                               ; preds = %35, %15
  %17 = load i64, ptr %11, align 8, !tbaa !9
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = sub i64 %18, 16
  %20 = icmp ult i64 %17, %19
  br i1 %20, label %21, label %38

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %22)
  %23 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %23, ptr align 4 %24, i64 16, i1 false)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %26, i64 %27
  call void @xor128(ptr noundef %25, ptr noundef %28)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %29)
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  call void @xor128(ptr noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @permute(ptr noundef %34)
  br label %35

35:                                               ; preds = %21
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = add i64 %36, 16
  store i64 %37, ptr %11, align 8, !tbaa !9
  br label %16, !llvm.loop !11

38:                                               ; preds = %16
  br label %39

39:                                               ; preds = %38, %4
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = sub i64 %40, %41
  store i64 %42, ptr %12, align 8, !tbaa !9
  %43 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %43, i8 0, i64 16, i1 false)
  %44 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 0
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %11, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  %48 = load i64, ptr %12, align 8, !tbaa !9
  call void @mem_cpy(ptr noundef %44, ptr noundef %47, i64 noundef %48)
  %49 = load i64, ptr %12, align 8, !tbaa !9
  %50 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 %49
  store i8 -128, ptr %50, align 1, !tbaa !13
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %51)
  %52 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %52, ptr align 4 %53, i64 16, i1 false)
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 0
  call void @xor128(ptr noundef %54, ptr noundef %55)
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  call void @endian_swap_rate(ptr noundef %56)
  %57 = load i64, ptr %12, align 8, !tbaa !9
  %58 = trunc i64 %57 to i32
  %59 = lshr i32 %58, 4
  %60 = shl i32 %59, 25
  %61 = zext i32 %60 to i64
  %62 = or i64 16777216, %61
  %63 = or i64 %62, 67108864
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds i32, ptr %64, i64 11
  %66 = load i32, ptr %65, align 4, !tbaa !14
  %67 = zext i32 %66 to i64
  %68 = xor i64 %67, %63
  %69 = trunc i64 %68 to i32
  store i32 %69, ptr %65, align 4, !tbaa !14
  %70 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 0
  %71 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  call void @xor128(ptr noundef %70, ptr noundef %71)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i64, ptr %11, align 8, !tbaa !9
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  %75 = getelementptr inbounds [17 x i8], ptr %10, i64 0, i64 0
  %76 = load i64, ptr %12, align 8, !tbaa !9
  call void @mem_cpy(ptr noundef %74, ptr noundef %75, i64 noundef %76)
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  call void @permute(ptr noundef %77)
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  call void @squeeze_permute(ptr noundef %78, ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 17, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  ret void
}

; 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

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: nounwind uwtable
define dso_local void @uc_encrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca [16 x i8], align 16
  %6 = alloca [17 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 17, ptr nonnull %6) #5
  %7 = icmp ugt i64 %2, 16
  br i1 %7, label %.lr.ph.preheader, label %.loopexit

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.030 = phi i64 [ %10, %.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) %5, ptr noundef nonnull align 4 dereferenceable(16) %0, i64 16, i1 false)
  %9 = getelementptr inbounds i8, ptr %1, i64 %.030
  call void @xor128(ptr noundef %0, ptr noundef %9)
  call void @endian_swap_rate(ptr noundef %0)
  call void @xor128(ptr noundef %9, ptr noundef nonnull %5)
  call void @permute(ptr noundef %0)
  %10 = add i64 %.030, 16
  %11 = icmp ult i64 %10, %8
  br i1 %11, label %.lr.ph, label %.loopexit, !llvm.loop !5

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

; 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

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