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

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

22:                                               ; preds = %16
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = and i32 %28, %26
  store i32 %29, ptr %27, align 4, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = add i32 %30, 1
  store i32 %31, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !11

32:                                               ; preds = %16
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %39, %32
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds i32, ptr %35, i64 1
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = icmp ult i32 %34, %37
  br i1 %38, label %39, label %74

39:                                               ; preds = %33
  %40 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = lshr i32 %43, 3
  %45 = and i32 %44, 7
  %46 = zext i32 %45 to i64
  %47 = or i64 %46, 1
  %48 = trunc i64 %47 to i32
  %49 = lshr i32 %41, %48
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %51
  store i32 %49, ptr %52, align 4, !tbaa !9
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %54
  %56 = getelementptr inbounds i16, ptr %55, i64 0
  %57 = load i16, ptr %56, align 2, !tbaa !13
  store i16 %57, ptr %7, align 2, !tbaa !13
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %59
  %61 = getelementptr inbounds i16, ptr %60, i64 1
  %62 = load i16, ptr %61, align 2, !tbaa !13
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %64
  %66 = getelementptr inbounds i16, ptr %65, i64 0
  store i16 %62, ptr %66, align 2, !tbaa !13
  %67 = load i16, ptr %7, align 2, !tbaa !13
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %69
  %71 = getelementptr inbounds i16, ptr %70, i64 1
  store i16 %67, ptr %71, align 2, !tbaa !13
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = add i32 %72, 1
  store i32 %73, ptr %6, align 4, !tbaa !9
  br label %33, !llvm.loop !15

74:                                               ; preds = %33
  %75 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = or i32 %76, 538181890
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds i32, ptr %78, i64 0
  store i32 %77, ptr %79, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !12}


; 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 {
.preheader:
  %2 = alloca [1 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = shl i32 %3, 7
  %5 = and i32 %4, 1127527680
  store i32 %5, ptr %2, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %2, i64 2
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext i32 %7 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %8 = icmp eq i32 %7, 1
  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 i64 %wide.trip.count, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = lshr i32 %9, 3
  %11 = and i32 %10, 6
  %12 = or disjoint i32 %11, 1
  %13 = lshr i32 %9, %12
  store i32 %13, ptr %2, align 4, !tbaa !5
  %14 = trunc i32 %13 to i16
  %gep = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv
  %15 = load i16, ptr %gep, align 2, !tbaa !9
  store i16 %15, ptr %2, align 4, !tbaa !9
  store i16 %14, ptr %gep, align 2, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = lshr i32 %16, 3
  %18 = and i32 %17, 6
  %19 = or disjoint i32 %18, 1
  %20 = lshr i32 %16, %19
  store i32 %20, ptr %2, align 4, !tbaa !5
  %21 = trunc i32 %20 to i16
  %gep.1 = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.next
  %22 = load i16, ptr %gep.1, align 2, !tbaa !9
  store i16 %22, ptr %2, align 4, !tbaa !9
  store i16 %21, ptr %gep.1, align 2, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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 %.lr.ph, !llvm.loop !11

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

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = lshr i32 %23, 3
  %25 = and i32 %24, 6
  %26 = or disjoint i32 %25, 1
  %27 = lshr i32 %23, %26
  store i32 %27, ptr %2, align 4, !tbaa !5
  %28 = trunc i32 %27 to i16
  %gep.epil = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.unr
  %29 = load i16, ptr %gep.epil, align 2, !tbaa !9
  store i16 %29, ptr %2, align 4, !tbaa !9
  store i16 %28, ptr %gep.epil, align 2, !tbaa !9
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %30 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %.preheader ]
  %31 = or i32 %30, 538181890
  store i32 %31, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress 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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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