; LLVM IR from kojiba/purge :: evasion (evasionRand)

; 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"

@evasionAmplificationConstants = external hidden constant [8 x i64], align 16
@evasionSubstitutionBlock = external hidden constant [256 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @substituteEvasion(i64 noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @rotateBytesEvasion(ptr noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local void @evasionRand(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i8 0, ptr %3, align 1, !tbaa !9
  br label %5

5:                                                ; preds = %165, %1
  %6 = load i8, ptr %3, align 1, !tbaa !9
  %7 = zext i8 %6 to i32
  %8 = icmp slt i32 %7, 17
  br i1 %8, label %9, label %168

9:                                                ; preds = %5
  %10 = load i64, ptr @evasionAmplificationConstants, align 16, !tbaa !10
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds i64, ptr %11, i64 0
  %13 = load i64, ptr %12, align 8, !tbaa !10
  %14 = add i64 %13, %10
  store i64 %14, ptr %12, align 8, !tbaa !10
  %15 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 1), align 8, !tbaa !10
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds i64, ptr %16, i64 1
  %18 = load i64, ptr %17, align 8, !tbaa !10
  %19 = xor i64 %18, %15
  store i64 %19, ptr %17, align 8, !tbaa !10
  %20 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 2), align 16, !tbaa !10
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %21, i64 2
  %23 = load i64, ptr %22, align 8, !tbaa !10
  %24 = add i64 %23, %20
  store i64 %24, ptr %22, align 8, !tbaa !10
  %25 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 3), align 8, !tbaa !10
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %26, i64 3
  %28 = load i64, ptr %27, align 8, !tbaa !10
  %29 = xor i64 %28, %25
  store i64 %29, ptr %27, align 8, !tbaa !10
  %30 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 4), align 16, !tbaa !10
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds i64, ptr %31, i64 4
  %33 = load i64, ptr %32, align 8, !tbaa !10
  %34 = add i64 %33, %30
  store i64 %34, ptr %32, align 8, !tbaa !10
  %35 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 5), align 8, !tbaa !10
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %36, i64 5
  %38 = load i64, ptr %37, align 8, !tbaa !10
  %39 = xor i64 %38, %35
  store i64 %39, ptr %37, align 8, !tbaa !10
  %40 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 6), align 16, !tbaa !10
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds i64, ptr %41, i64 6
  %43 = load i64, ptr %42, align 8, !tbaa !10
  %44 = add i64 %43, %40
  store i64 %44, ptr %42, align 8, !tbaa !10
  %45 = load i64, ptr getelementptr inbounds ([8 x i64], ptr @evasionAmplificationConstants, i64 0, i64 7), align 8, !tbaa !10
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds i64, ptr %46, i64 7
  %48 = load i64, ptr %47, align 8, !tbaa !10
  %49 = xor i64 %48, %45
  store i64 %49, ptr %47, align 8, !tbaa !10
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds i64, ptr %50, i64 0
  %52 = load i64, ptr %51, align 8, !tbaa !10
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds i64, ptr %53, i64 1
  %55 = load i64, ptr %54, align 8, !tbaa !10
  %56 = add i64 %55, %52
  store i64 %56, ptr %54, align 8, !tbaa !10
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds i64, ptr %57, i64 2
  %59 = load i64, ptr %58, align 8, !tbaa !10
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds i64, ptr %60, i64 3
  %62 = load i64, ptr %61, align 8, !tbaa !10
  %63 = add i64 %62, %59
  store i64 %63, ptr %61, align 8, !tbaa !10
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds i64, ptr %64, i64 4
  %66 = load i64, ptr %65, align 8, !tbaa !10
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds i64, ptr %67, i64 5
  %69 = load i64, ptr %68, align 8, !tbaa !10
  %70 = add i64 %69, %66
  store i64 %70, ptr %68, align 8, !tbaa !10
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds i64, ptr %71, i64 6
  %73 = load i64, ptr %72, align 8, !tbaa !10
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds i64, ptr %74, i64 7
  %76 = load i64, ptr %75, align 8, !tbaa !10
  %77 = add i64 %76, %73
  store i64 %77, ptr %75, align 8, !tbaa !10
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds i64, ptr %78, i64 0
  %80 = load i64, ptr %79, align 8, !tbaa !10
  %81 = shl i64 %80, 7
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds i64, ptr %82, i64 0
  %84 = load i64, ptr %83, align 8, !tbaa !10
  %85 = lshr i64 %84, 57
  %86 = or i64 %81, %85
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds i64, ptr %87, i64 0
  store i64 %86, ptr %88, align 8, !tbaa !10
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds i64, ptr %89, i64 1
  %91 = load i64, ptr %90, align 8, !tbaa !10
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds i64, ptr %92, i64 2
  %94 = load i64, ptr %93, align 8, !tbaa !10
  %95 = xor i64 %94, %91
  store i64 %95, ptr %93, align 8, !tbaa !10
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds i64, ptr %96, i64 3
  %98 = load i64, ptr %97, align 8, !tbaa !10
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = getelementptr inbounds i64, ptr %99, i64 4
  %101 = load i64, ptr %100, align 8, !tbaa !10
  %102 = xor i64 %101, %98
  store i64 %102, ptr %100, align 8, !tbaa !10
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds i64, ptr %103, i64 5
  %105 = load i64, ptr %104, align 8, !tbaa !10
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  %107 = getelementptr inbounds i64, ptr %106, i64 6
  %108 = load i64, ptr %107, align 8, !tbaa !10
  %109 = xor i64 %108, %105
  store i64 %109, ptr %107, align 8, !tbaa !10
  %110 = load ptr, ptr %2, align 8, !tbaa !5
  %111 = getelementptr inbounds i64, ptr %110, i64 0
  %112 = load i64, ptr %111, align 8, !tbaa !10
  %113 = shl i64 %112, 13
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds i64, ptr %114, i64 0
  %116 = load i64, ptr %115, align 8, !tbaa !10
  %117 = lshr i64 %116, 51
  %118 = or i64 %113, %117
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  %120 = getelementptr inbounds i64, ptr %119, i64 7
  store i64 %118, ptr %120, align 8, !tbaa !10
  %121 = load ptr, ptr %2, align 8, !tbaa !5
  %122 = getelementptr inbounds i64, ptr %121, i64 1
  %123 = load i64, ptr %122, align 8, !tbaa !10
  %124 = call i64 @substituteEvasion(i64 noundef %123, ptr noundef @evasionSubstitutionBlock)
  %125 = load ptr, ptr %2, align 8, !tbaa !5
  %126 = getelementptr inbounds i64, ptr %125, i64 1
  store i64 %124, ptr %126, align 8, !tbaa !10
  %127 = load ptr, ptr %2, align 8, !tbaa !5
  %128 = getelementptr inbounds i64, ptr %127, i64 3
  %129 = load i64, ptr %128, align 8, !tbaa !10
  %130 = call i64 @substituteEvasion(i64 noundef %129, ptr noundef @evasionSubstitutionBlock)
  %131 = load ptr, ptr %2, align 8, !tbaa !5
  %132 = getelementptr inbounds i64, ptr %131, i64 3
  store i64 %130, ptr %132, align 8, !tbaa !10
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  %134 = getelementptr inbounds i64, ptr %133, i64 5
  %135 = load i64, ptr %134, align 8, !tbaa !10
  %136 = call i64 @substituteEvasion(i64 noundef %135, ptr noundef @evasionSubstitutionBlock)
  %137 = load ptr, ptr %2, align 8, !tbaa !5
  %138 = getelementptr inbounds i64, ptr %137, i64 5
  store i64 %136, ptr %138, align 8, !tbaa !10
  %139 = load ptr, ptr %2, align 8, !tbaa !5
  %140 = getelementptr inbounds i64, ptr %139, i64 7
  %141 = load i64, ptr %140, align 8, !tbaa !10
  store i64 %141, ptr %4, align 8, !tbaa !10
  %142 = load ptr, ptr %2, align 8, !tbaa !5
  %143 = getelementptr inbounds i64, ptr %142, i64 2
  %144 = load i64, ptr %143, align 8, !tbaa !10
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = getelementptr inbounds i64, ptr %145, i64 7
  store i64 %144, ptr %146, align 8, !tbaa !10
  %147 = load ptr, ptr %2, align 8, !tbaa !5
  %148 = getelementptr inbounds i64, ptr %147, i64 5
  %149 = load i64, ptr %148, align 8, !tbaa !10
  %150 = load ptr, ptr %2, align 8, !tbaa !5
  %151 = getelementptr inbounds i64, ptr %150, i64 2
  store i64 %149, ptr %151, align 8, !tbaa !10
  %152 = load ptr, ptr %2, align 8, !tbaa !5
  %153 = getelementptr inbounds i64, ptr %152, i64 0
  %154 = load i64, ptr %153, align 8, !tbaa !10
  %155 = load ptr, ptr %2, align 8, !tbaa !5
  %156 = getelementptr inbounds i64, ptr %155, i64 5
  store i64 %154, ptr %156, align 8, !tbaa !10
  %157 = load i64, ptr %4, align 8, !tbaa !10
  %158 = load ptr, ptr %2, align 8, !tbaa !5
  %159 = getelementptr inbounds i64, ptr %158, i64 0
  store i64 %157, ptr %159, align 8, !tbaa !10
  store i64 0, ptr %4, align 8, !tbaa !10
  %160 = load ptr, ptr %2, align 8, !tbaa !5
  %161 = load i8, ptr %3, align 1, !tbaa !9
  %162 = zext i8 %161 to i32
  %163 = add nsw i32 %162, 1
  %164 = trunc i32 %163 to i8
  call void @rotateBytesEvasion(ptr noundef %160, i8 noundef zeroext %164)
  br label %165

165:                                              ; preds = %9
  %166 = load i8, ptr %3, align 1, !tbaa !9
  %167 = add i8 %166, 1
  store i8 %167, ptr %3, align 1, !tbaa !9
  br label %5, !llvm.loop !12

168:                                              ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret void
}

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

@evasionAmplificationConstants = external hidden local_unnamed_addr constant [8 x i64], align 16
@evasionSubstitutionBlock = external hidden constant [256 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @substituteEvasion(i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @rotateBytesEvasion(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @evasionRand(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i64, ptr @evasionAmplificationConstants, align 16, !tbaa !5
  %3 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 8), align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 16), align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 24), align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 32), align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 40), align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load i64, ptr getelementptr inbounds (i8, ptr @evasionAmplificationConstants, i64 48), align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  br label %16

16:                                               ; preds = %1, %16
  %.047 = phi i8 [ 0, %1 ], [ %narrow, %16 ]
  %17 = load i64, ptr %0, align 8, !tbaa !5
  %18 = add i64 %17, %2
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = xor i64 %19, %3
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = add i64 %21, %5
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %24 = xor i64 %23, %7
  %25 = load i64, ptr %10, align 8, !tbaa !5
  %26 = add i64 %25, %9
  %27 = load i64, ptr %12, align 8, !tbaa !5
  %28 = xor i64 %27, %11
  %29 = load i64, ptr %14, align 8, !tbaa !5
  %30 = add i64 %29, %13
  %31 = add i64 %20, %18
  store i64 %31, ptr %4, align 8, !tbaa !5
  %32 = add i64 %24, %22
  store i64 %32, ptr %8, align 8, !tbaa !5
  %33 = add i64 %28, %26
  store i64 %33, ptr %12, align 8, !tbaa !5
  %34 = tail call i64 @llvm.fshl.i64(i64 %18, i64 %18, i64 7)
  store i64 %34, ptr %0, align 8, !tbaa !5
  %35 = xor i64 %22, %31
  store i64 %35, ptr %6, align 8, !tbaa !5
  %36 = xor i64 %26, %32
  store i64 %36, ptr %10, align 8, !tbaa !5
  %37 = xor i64 %30, %33
  store i64 %37, ptr %14, align 8, !tbaa !5
  %38 = tail call i64 @llvm.fshl.i64(i64 %34, i64 %34, i64 13)
  store i64 %38, ptr %15, align 8, !tbaa !5
  %39 = tail call i64 @substituteEvasion(i64 noundef %31, ptr noundef nonnull @evasionSubstitutionBlock)
  store i64 %39, ptr %4, align 8, !tbaa !5
  %40 = load i64, ptr %8, align 8, !tbaa !5
  %41 = tail call i64 @substituteEvasion(i64 noundef %40, ptr noundef nonnull @evasionSubstitutionBlock)
  store i64 %41, ptr %8, align 8, !tbaa !5
  %42 = load i64, ptr %12, align 8, !tbaa !5
  %43 = tail call i64 @substituteEvasion(i64 noundef %42, ptr noundef nonnull @evasionSubstitutionBlock)
  %44 = load i64, ptr %15, align 8, !tbaa !5
  %45 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %45, ptr %15, align 8, !tbaa !5
  store i64 %43, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %0, align 8, !tbaa !5
  store i64 %46, ptr %12, align 8, !tbaa !5
  store i64 %44, ptr %0, align 8, !tbaa !5
  %narrow = add nuw nsw i8 %.047, 1
  tail call void @rotateBytesEvasion(ptr noundef nonnull %0, i8 noundef zeroext %narrow)
  %exitcond.not = icmp eq i8 %narrow, 17
  br i1 %exitcond.not, label %47, label %16, !llvm.loop !9

47:                                               ; preds = %16
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.fshl.i64(i64, i64, i64) #1

attributes #0 = { 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 #1 = { 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 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass