; LLVM IR from tum-i4/obfuscation-benchmarks :: tigress-generated-programs (RandomFunc)

; 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: nounwind uwtable
define dso_local void @RandomFunc(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [1 x i64], align 8
  %6 = alloca i64, align 8
  %7 = alloca i16, align 2
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds i64, ptr %9, i64 0
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = add i64 %11, 914778474
  %13 = xor i64 %12, -832765941
  %14 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  store i64 %13, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %54, %2
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i64, ptr %17, i64 1
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp ult i64 %16, %19
  br i1 %20, label %21, label %57

21:                                               ; preds = %15
  %22 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp ugt i64 %23, %24
  br i1 %25, label %26, label %42

26:                                               ; preds = %21
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %27
  %29 = getelementptr inbounds i16, ptr %28, i64 0
  %30 = load i16, ptr %29, align 2, !tbaa !11
  store i16 %30, ptr %7, align 2, !tbaa !11
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %31
  %33 = getelementptr inbounds i16, ptr %32, i64 1
  %34 = load i16, ptr %33, align 2, !tbaa !11
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %35
  %37 = getelementptr inbounds i16, ptr %36, i64 0
  store i16 %34, ptr %37, align 2, !tbaa !11
  %38 = load i16, ptr %7, align 2, !tbaa !11
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %39
  %41 = getelementptr inbounds i16, ptr %40, i64 1
  store i16 %38, ptr %41, align 2, !tbaa !11
  br label %54

42:                                               ; preds = %21
  %43 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %44 = getelementptr inbounds i32, ptr %43, i64 1
  %45 = load i32, ptr %44, align 4, !tbaa !13
  store i32 %45, ptr %8, align 4, !tbaa !13
  %46 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %47 = getelementptr inbounds i32, ptr %46, i64 0
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %50 = getelementptr inbounds i32, ptr %49, i64 1
  store i32 %48, ptr %50, align 4, !tbaa !13
  %51 = load i32, ptr %8, align 4, !tbaa !13
  %52 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %53 = getelementptr inbounds i32, ptr %52, i64 0
  store i32 %51, ptr %53, align 4, !tbaa !13
  br label %54

54:                                               ; preds = %42, %26
  %55 = load i64, ptr %6, align 8, !tbaa !9
  %56 = add i64 %55, 1
  store i64 %56, ptr %6, align 8, !tbaa !9
  br label %15, !llvm.loop !15

57:                                               ; preds = %15
  %58 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = mul i64 %59, 238420169
  %61 = or i64 %60, 7962364141192960077
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds i64, ptr %62, i64 0
  store i64 %61, ptr %63, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

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

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @RandomFunc(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = alloca [1 x i64], align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = add i64 %4, 914778474
  %6 = xor i64 %5, -832765941
  store i64 %6, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 2
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  %xtraiter = and i64 %8, 1
  %10 = icmp eq i64 %8, 1
  br i1 %10, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %8, -2
  br label %11

11:                                               ; preds = %32, %.lr.ph.new
  %.011 = phi i64 [ 0, %.lr.ph.new ], [ %33, %32 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %32 ]
  %12 = load i64, ptr %3, align 8
  %13 = icmp ugt i64 %12, %.011
  br i1 %13, label %14, label %17

14:                                               ; preds = %11
  %15 = trunc i64 %12 to i16
  %gep = getelementptr [1 x i64], ptr %invariant.gep, i64 0, i64 %.011
  %16 = load i16, ptr %gep, align 2, !tbaa !9
  store i16 %16, ptr %3, align 8, !tbaa !9
  store i16 %15, ptr %gep, align 2, !tbaa !9
  br label %21

17:                                               ; preds = %11
  %18 = trunc i64 %12 to i32
  %19 = lshr i64 %12, 32
  %20 = trunc nuw i64 %19 to i32
  store i32 %18, ptr %9, align 4, !tbaa !11
  store i32 %20, ptr %3, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %17, %14
  %22 = or disjoint i64 %.011, 1
  %23 = load i64, ptr %3, align 8
  %24 = icmp ugt i64 %23, %22
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  %26 = trunc i64 %23 to i32
  %27 = lshr i64 %23, 32
  %28 = trunc nuw i64 %27 to i32
  store i32 %26, ptr %9, align 4, !tbaa !11
  store i32 %28, ptr %3, align 8, !tbaa !11
  br label %32

29:                                               ; preds = %21
  %30 = trunc i64 %23 to i16
  %gep.1 = getelementptr [1 x i64], ptr %invariant.gep, i64 0, i64 %22
  %31 = load i16, ptr %gep.1, align 2, !tbaa !9
  store i16 %31, ptr %3, align 8, !tbaa !9
  store i16 %30, ptr %gep.1, align 2, !tbaa !9
  br label %32

32:                                               ; preds = %29, %25
  %33 = add nuw i64 %.011, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %11, !llvm.loop !13

._crit_edge.loopexit.unr-lcssa:                   ; preds = %32, %.lr.ph
  %.011.unr = phi i64 [ 0, %.lr.ph ], [ %33, %32 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %34 = load i64, ptr %3, align 8
  %35 = icmp ugt i64 %34, %.011.unr
  br i1 %35, label %40, label %36

36:                                               ; preds = %.epil.preheader
  %37 = trunc i64 %34 to i32
  %38 = lshr i64 %34, 32
  %39 = trunc nuw i64 %38 to i32
  store i32 %37, ptr %9, align 4, !tbaa !11
  store i32 %39, ptr %3, align 8, !tbaa !11
  br label %._crit_edge.loopexit

40:                                               ; preds = %.epil.preheader
  %41 = trunc i64 %34 to i16
  %gep.epil = getelementptr [1 x i64], ptr %invariant.gep, i64 0, i64 %.011.unr
  %42 = load i16, ptr %gep.epil, align 2, !tbaa !9
  store i16 %42, ptr %3, align 8, !tbaa !9
  store i16 %41, ptr %gep.epil, align 2, !tbaa !9
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %36, %40, %._crit_edge.loopexit.unr-lcssa
  %.pre = load i64, ptr %3, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %43 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %6, %2 ]
  %44 = mul i64 %43, 238420169
  %45 = or i64 %44, 7962364141192960077
  store i64 %45, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret void
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass