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

16:                                               ; preds = %64, %2
  %17 = load i16, ptr %6, align 2, !tbaa !9
  %18 = zext i16 %17 to i32
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds i16, ptr %19, i64 1
  %21 = load i16, ptr %20, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = icmp slt i32 %18, %22
  br i1 %23, label %24, label %67

24:                                               ; preds = %16
  %25 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %26 = load i16, ptr %25, align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = load i16, ptr %6, align 2, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = icmp slt i32 %27, %29
  br i1 %30, label %31, label %55

31:                                               ; preds = %24
  %32 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %33 = getelementptr inbounds i8, ptr %32, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !11
  store i8 %34, ptr %7, align 1, !tbaa !11
  %35 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %36 = getelementptr inbounds i8, ptr %35, i64 0
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  store i8 %37, ptr %39, align 1, !tbaa !11
  %40 = load i8, ptr %7, align 1, !tbaa !11
  %41 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %42 = getelementptr inbounds i8, ptr %41, i64 0
  store i8 %40, ptr %42, align 1, !tbaa !11
  %43 = load i16, ptr %6, align 2, !tbaa !9
  %44 = zext i16 %43 to i64
  %45 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %44
  %46 = load i16, ptr %45, align 2, !tbaa !9
  %47 = zext i16 %46 to i32
  %48 = load i16, ptr %6, align 2, !tbaa !9
  %49 = zext i16 %48 to i64
  %50 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %49
  %51 = load i16, ptr %50, align 2, !tbaa !9
  %52 = zext i16 %51 to i32
  %53 = add nsw i32 %52, %47
  %54 = trunc i32 %53 to i16
  store i16 %54, ptr %50, align 2, !tbaa !9
  br label %64

55:                                               ; preds = %24
  %56 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %57 = load i16, ptr %56, align 2, !tbaa !9
  %58 = zext i16 %57 to i32
  %59 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %60 = load i16, ptr %59, align 2, !tbaa !9
  %61 = zext i16 %60 to i32
  %62 = add nsw i32 %61, %58
  %63 = trunc i32 %62 to i16
  store i16 %63, ptr %59, align 2, !tbaa !9
  br label %64

64:                                               ; preds = %55, %31
  %65 = load i16, ptr %6, align 2, !tbaa !9
  %66 = add i16 %65, 1
  store i16 %66, ptr %6, align 2, !tbaa !9
  br label %16, !llvm.loop !12

67:                                               ; preds = %16
  %68 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %69 = load i16, ptr %68, align 2, !tbaa !9
  %70 = zext i16 %69 to i64
  %71 = mul i64 %70, 166502562
  %72 = mul i64 %71, 34066
  %73 = trunc i64 %72 to i16
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds i16, ptr %74, i64 0
  store i16 %73, ptr %75, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  ret void
}

; 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

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 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!7, !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"

; 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 #0 {
  %3 = load i16, ptr %0, align 2, !tbaa !5
  %4 = mul i16 %3, -1258
  %5 = add i16 %4, -740
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %.not = icmp eq i16 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %xtraiter = and i16 %7, 3
  %8 = icmp ult i16 %7, 4
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i16 %7, -4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.033 = phi i16 [ 0, %.lr.ph.preheader.new ], [ %14, %.lr.ph ]
  %.sroa.9.0.in.in32 = phi i16 [ %5, %.lr.ph.preheader.new ], [ %storemerge.3, %.lr.ph ]
  %niter = phi i16 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %9 = icmp ult i16 %.sroa.9.0.in.in32, %.033
  %.sroa.0.0.insert.insert18 = tail call i16 @llvm.bswap.i16(i16 %.sroa.9.0.in.in32)
  %storemerge.in = select i1 %9, i16 %.sroa.0.0.insert.insert18, i16 %.sroa.9.0.in.in32
  %storemerge = shl i16 %storemerge.in, 1
  %.not35 = icmp ugt i16 %storemerge, %.033
  %.sroa.0.0.insert.insert18.1 = tail call i16 @llvm.bswap.i16(i16 %storemerge)
  %storemerge.in.1 = select i1 %.not35, i16 %storemerge, i16 %.sroa.0.0.insert.insert18.1
  %storemerge.1 = shl i16 %storemerge.in.1, 1
  %10 = or disjoint i16 %.033, 2
  %11 = icmp ult i16 %storemerge.1, %10
  %.sroa.0.0.insert.insert18.2 = tail call i16 @llvm.bswap.i16(i16 %storemerge.1)
  %storemerge.in.2 = select i1 %11, i16 %.sroa.0.0.insert.insert18.2, i16 %storemerge.1
  %storemerge.2 = shl i16 %storemerge.in.2, 1
  %12 = or disjoint i16 %.033, 3
  %13 = icmp ult i16 %storemerge.2, %12
  %.sroa.0.0.insert.insert18.3 = tail call i16 @llvm.bswap.i16(i16 %storemerge.2)
  %storemerge.in.3 = select i1 %13, i16 %.sroa.0.0.insert.insert18.3, i16 %storemerge.2
  %storemerge.3 = shl i16 %storemerge.in.3, 1
  %14 = add nuw i16 %.033, 4
  %niter.next.3 = add i16 %niter, 4
  %niter.ncmp.3 = icmp eq i16 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %storemerge.lcssa.ph = phi i16 [ poison, %.lr.ph.preheader ], [ %storemerge.3, %.lr.ph ]
  %.033.unr = phi i16 [ 0, %.lr.ph.preheader ], [ %14, %.lr.ph ]
  %.sroa.9.0.in.in32.unr = phi i16 [ %5, %.lr.ph.preheader ], [ %storemerge.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i16 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.033.epil = phi i16 [ %16, %.lr.ph.epil ], [ %.033.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.sroa.9.0.in.in32.epil = phi i16 [ %storemerge.epil, %.lr.ph.epil ], [ %.sroa.9.0.in.in32.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i16 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %15 = icmp ult i16 %.sroa.9.0.in.in32.epil, %.033.epil
  %.sroa.0.0.insert.insert18.epil = tail call i16 @llvm.bswap.i16(i16 %.sroa.9.0.in.in32.epil)
  %storemerge.in.epil = select i1 %15, i16 %.sroa.0.0.insert.insert18.epil, i16 %.sroa.9.0.in.in32.epil
  %storemerge.epil = shl i16 %storemerge.in.epil, 1
  %16 = add nuw i16 %.033.epil, 1
  %epil.iter.next = add i16 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i16 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %2
  %.sroa.9.0.in.in.lcssa = phi i16 [ %5, %2 ], [ %storemerge.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %storemerge.epil, %.lr.ph.epil ]
  %17 = mul i16 %.sroa.9.0.in.in.lcssa, 30052
  store i16 %17, ptr %1, align 2, !tbaa !5
  ret void
}

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

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


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