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

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

25:                                               ; preds = %17
  store i16 0, ptr %6, align 2, !tbaa !9
  br label %26

26:                                               ; preds = %64, %25
  %27 = load i16, ptr %6, align 2, !tbaa !9
  %28 = zext i16 %27 to i32
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds i16, ptr %29, i64 1
  %31 = load i16, ptr %30, align 2, !tbaa !9
  %32 = zext i16 %31 to i32
  %33 = icmp slt i32 %28, %32
  br i1 %33, label %34, label %67

34:                                               ; preds = %26
  %35 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %36 = load i16, ptr %35, align 2, !tbaa !9
  %37 = zext i16 %36 to i32
  %38 = load i16, ptr %6, align 2, !tbaa !9
  %39 = zext i16 %38 to i32
  %40 = load i16, ptr %7, align 2, !tbaa !9
  %41 = zext i16 %40 to i32
  %42 = add nsw i32 %39, %41
  %43 = icmp slt i32 %37, %42
  br i1 %43, label %44, label %64

44:                                               ; preds = %34
  %45 = load i16, ptr %7, align 2, !tbaa !9
  %46 = zext i16 %45 to i64
  %47 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %46
  %48 = getelementptr inbounds i8, ptr %47, i64 0
  %49 = load i8, ptr %48, align 1, !tbaa !11
  store i8 %49, ptr %8, align 1, !tbaa !11
  %50 = load i16, ptr %7, align 2, !tbaa !9
  %51 = zext i16 %50 to i64
  %52 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %51
  %53 = getelementptr inbounds i8, ptr %52, i64 1
  %54 = load i8, ptr %53, align 1, !tbaa !11
  %55 = load i16, ptr %7, align 2, !tbaa !9
  %56 = zext i16 %55 to i64
  %57 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %56
  %58 = getelementptr inbounds i8, ptr %57, i64 0
  store i8 %54, ptr %58, align 1, !tbaa !11
  %59 = load i8, ptr %8, align 1, !tbaa !11
  %60 = load i16, ptr %7, align 2, !tbaa !9
  %61 = zext i16 %60 to i64
  %62 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %61
  %63 = getelementptr inbounds i8, ptr %62, i64 1
  store i8 %59, ptr %63, align 1, !tbaa !11
  br label %64

64:                                               ; preds = %44, %34
  %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 %26, !llvm.loop !12

67:                                               ; preds = %26
  %68 = load i16, ptr %7, align 2, !tbaa !9
  %69 = add i16 %68, 1
  store i16 %69, ptr %7, align 2, !tbaa !9
  br label %17, !llvm.loop !14

70:                                               ; preds = %17
  %71 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %72 = load i16, ptr %71, align 2, !tbaa !9
  %73 = zext i16 %72 to i64
  %74 = mul i64 %73, 413141921
  %75 = trunc i64 %74 to i16
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds i16, ptr %76, i64 0
  store i16 %75, ptr %77, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 2, 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.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 = !{!"short", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 i16], align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #2
  %4 = load i16, ptr %0, align 2, !tbaa !5
  %5 = mul i16 %4, -1258
  %6 = add i16 %5, -740
  store i16 %6, ptr %3, align 2, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 2
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %.not = icmp eq i16 %8, 0
  br i1 %.not, label %._crit_edge, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %2
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 1
  %wide.trip.count22 = zext i16 %8 to i64
  %wide.trip.count = zext i16 %8 to i32
  %xtraiter = and i32 %wide.trip.count, 1
  %9 = icmp eq i16 %8, 1
  %unroll_iter = and i32 %wide.trip.count, 65534
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %.epilog-lcssa
  %indvars.iv20 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next21, %.epilog-lcssa ]
  %10 = phi i32 [ 0, %.preheader.lr.ph ], [ %34, %.epilog-lcssa ]
  %gep = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv20
  br i1 %9, label %.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader, %26
  %indvars.iv = phi i32 [ %indvars.iv.next.1, %26 ], [ 0, %.preheader ]
  %niter = phi i32 [ %niter.next.1, %26 ], [ 0, %.preheader ]
  %11 = load i16, ptr %3, align 2
  %12 = zext i16 %11 to i32
  %13 = add nuw nsw i32 %10, %indvars.iv
  %14 = icmp ugt i32 %13, %12
  br i1 %14, label %15, label %18

15:                                               ; preds = %.preheader.new
  %16 = trunc i16 %11 to i8
  %17 = load i8, ptr %gep, align 1, !tbaa !9
  store i8 %17, ptr %3, align 2, !tbaa !9
  store i8 %16, ptr %gep, align 1, !tbaa !9
  br label %18

18:                                               ; preds = %15, %.preheader.new
  %indvars.iv.next = or disjoint i32 %indvars.iv, 1
  %19 = load i16, ptr %3, align 2
  %20 = zext i16 %19 to i32
  %21 = add nuw nsw i32 %10, %indvars.iv.next
  %22 = icmp ugt i32 %21, %20
  br i1 %22, label %23, label %26

23:                                               ; preds = %18
  %24 = trunc i16 %19 to i8
  %25 = load i8, ptr %gep, align 1, !tbaa !9
  store i8 %25, ptr %3, align 2, !tbaa !9
  store i8 %24, ptr %gep, align 1, !tbaa !9
  br label %26

26:                                               ; preds = %23, %18
  %indvars.iv.next.1 = add nuw nsw i32 %indvars.iv, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.unr-lcssa, label %.preheader.new, !llvm.loop !10

.unr-lcssa:                                       ; preds = %26, %.preheader
  %indvars.iv.unr = phi i32 [ 0, %.preheader ], [ %indvars.iv.next.1, %26 ]
  br i1 %lcmp.mod.not, label %.epilog-lcssa, label %.epil.preheader

.epil.preheader:                                  ; preds = %.unr-lcssa
  %27 = load i16, ptr %3, align 2
  %28 = zext i16 %27 to i32
  %29 = add nuw nsw i32 %10, %indvars.iv.unr
  %30 = icmp ugt i32 %29, %28
  br i1 %30, label %31, label %.epilog-lcssa

31:                                               ; preds = %.epil.preheader
  %32 = trunc i16 %27 to i8
  %33 = load i8, ptr %gep, align 1, !tbaa !9
  store i8 %33, ptr %3, align 2, !tbaa !9
  store i8 %32, ptr %gep, align 1, !tbaa !9
  br label %.epilog-lcssa

.epilog-lcssa:                                    ; preds = %.epil.preheader, %31, %.unr-lcssa
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %34 = trunc nuw i64 %indvars.iv.next21 to i32
  %exitcond23.not = icmp eq i64 %indvars.iv.next21, %wide.trip.count22
  br i1 %exitcond23.not, label %._crit_edge.loopexit, label %.preheader, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %.epilog-lcssa
  %.pre = load i16, ptr %3, align 2, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %35 = phi i16 [ %.pre, %._crit_edge.loopexit ], [ %6, %2 ]
  %36 = mul i16 %35, 2977
  store i16 %36, ptr %1, align 2, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 2, 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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