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

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

23:                                               ; preds = %17
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %55, %23
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 1
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp ult i32 %25, %28
  br i1 %29, label %30, label %60

30:                                               ; preds = %24
  %31 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = mul i32 %33, %34
  %36 = icmp eq i32 %32, %35
  br i1 %36, label %37, label %49

37:                                               ; preds = %30
  %38 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = load i8, ptr %39, align 1, !tbaa !11
  store i8 %40, ptr %8, align 1, !tbaa !11
  %41 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %42 = getelementptr inbounds i8, ptr %41, i64 0
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %45 = getelementptr inbounds i8, ptr %44, i64 1
  store i8 %43, ptr %45, align 1, !tbaa !11
  %46 = load i8, ptr %8, align 1, !tbaa !11
  %47 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %48 = getelementptr inbounds i8, ptr %47, i64 0
  store i8 %46, ptr %48, align 1, !tbaa !11
  br label %55

49:                                               ; preds = %30
  %50 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = add i32 %53, %51
  store i32 %54, ptr %52, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %49, %37
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = add i64 %57, 2
  %59 = trunc i64 %58 to i32
  store i32 %59, ptr %6, align 4, !tbaa !9
  br label %24, !llvm.loop !12

60:                                               ; preds = %24
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %7, align 4, !tbaa !9
  br label %17, !llvm.loop !14

63:                                               ; preds = %17
  %64 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = mul i64 %66, 792485636
  %68 = trunc i64 %67 to i32
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds i32, ptr %69, i64 0
  store i32 %68, ptr %70, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, 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.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 = !{!"int", !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: 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 i32, ptr %0, align 4, !tbaa !5
  %4 = add i32 %3, -390364520
  %.sroa.0.0.extract.trunc = trunc i32 %4 to i8
  %.sroa.10.0.extract.shift = lshr i32 %4, 8
  %.sroa.10.0.extract.trunc = trunc i32 %.sroa.10.0.extract.shift to i8
  %.sroa.12.0.extract.shift = lshr i32 %4, 16
  %.sroa.12.0.extract.trunc = trunc nuw i32 %.sroa.12.0.extract.shift to i16
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %2, %13
  %.sroa.12.066 = phi i16 [ %.sroa.12.2, %13 ], [ %.sroa.12.0.extract.trunc, %2 ]
  %.065 = phi i32 [ %14, %13 ], [ 0, %2 ]
  %.sroa.0.064 = phi i8 [ %.sroa.0.2, %13 ], [ %.sroa.0.0.extract.trunc, %2 ]
  %.sroa.10.063 = phi i8 [ %.sroa.10.2, %13 ], [ %.sroa.10.0.extract.trunc, %2 ]
  br label %7

7:                                                ; preds = %.preheader, %7
  %.sroa.12.162 = phi i16 [ %.sroa.12.066, %.preheader ], [ %.sroa.12.2, %7 ]
  %.05861 = phi i32 [ 0, %.preheader ], [ %11, %7 ]
  %.sroa.0.160 = phi i8 [ %.sroa.0.064, %.preheader ], [ %.sroa.0.2, %7 ]
  %.sroa.10.159 = phi i8 [ %.sroa.10.063, %.preheader ], [ %.sroa.10.2, %7 ]
  %.sroa.12.0.insert.ext = zext i16 %.sroa.12.162 to i32
  %.sroa.12.0.insert.shift = shl nuw i32 %.sroa.12.0.insert.ext, 16
  %.sroa.10.0.insert.ext = zext i8 %.sroa.10.159 to i32
  %.sroa.10.0.insert.shift = shl nuw nsw i32 %.sroa.10.0.insert.ext, 8
  %.sroa.10.0.insert.insert = or disjoint i32 %.sroa.12.0.insert.shift, %.sroa.10.0.insert.shift
  %.sroa.0.0.insert.ext = zext i8 %.sroa.0.160 to i32
  %.sroa.0.0.insert.insert = or disjoint i32 %.sroa.10.0.insert.insert, %.sroa.0.0.insert.ext
  %8 = mul i32 %.05861, %.065
  %9 = icmp eq i32 %.sroa.0.0.insert.insert, %8
  %10 = shl i32 %.sroa.0.0.insert.insert, 1
  %.sroa.0.0.extract.trunc16 = trunc i32 %10 to i8
  %.sroa.10.0.extract.shift31 = lshr i32 %10, 8
  %.sroa.10.0.extract.trunc32 = trunc i32 %.sroa.10.0.extract.shift31 to i8
  %.sroa.12.0.extract.shift48 = lshr i32 %10, 16
  %.sroa.12.0.extract.trunc49 = trunc nuw i32 %.sroa.12.0.extract.shift48 to i16
  %.sroa.10.2 = select i1 %9, i8 %.sroa.0.160, i8 %.sroa.10.0.extract.trunc32
  %.sroa.0.2 = select i1 %9, i8 %.sroa.10.159, i8 %.sroa.0.0.extract.trunc16
  %.sroa.12.2 = select i1 %9, i16 %.sroa.12.162, i16 %.sroa.12.0.extract.trunc49
  %11 = add nuw i32 %.05861, 2
  %12 = icmp ult i32 %11, %6
  br i1 %12, label %7, label %13, !llvm.loop !9

13:                                               ; preds = %7
  %14 = add nuw i32 %.065, 1
  %exitcond.not = icmp eq i32 %14, %6
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %13, %2
  %.sroa.10.0.lcssa = phi i8 [ %.sroa.10.0.extract.trunc, %2 ], [ %.sroa.10.2, %13 ]
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.2, %13 ]
  %.sroa.12.0.lcssa = phi i16 [ %.sroa.12.0.extract.trunc, %2 ], [ %.sroa.12.2, %13 ]
  %.sroa.12.0.insert.ext51 = zext i16 %.sroa.12.0.lcssa to i32
  %.sroa.12.0.insert.shift52 = shl nuw i32 %.sroa.12.0.insert.ext51, 16
  %.sroa.10.0.insert.ext34 = zext i8 %.sroa.10.0.lcssa to i32
  %.sroa.10.0.insert.shift35 = shl nuw nsw i32 %.sroa.10.0.insert.ext34, 8
  %.sroa.10.0.insert.insert37 = or disjoint i32 %.sroa.12.0.insert.shift52, %.sroa.10.0.insert.shift35
  %.sroa.0.0.insert.ext18 = zext i8 %.sroa.0.0.lcssa to i32
  %.sroa.0.0.insert.insert20 = or disjoint i32 %.sroa.10.0.insert.insert37, %.sroa.0.0.insert.ext18
  %15 = mul i32 %.sroa.0.0.insert.insert20, 792485636
  store i32 %15, ptr %1, align 4, !tbaa !5
  ret void
}

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

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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