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

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

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

25:                                               ; preds = %20
  %26 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = load i64, ptr %6, align 8, !tbaa !9
  %29 = icmp ne i64 %27, %28
  br i1 %29, label %30, label %36

30:                                               ; preds = %25
  %31 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = add i64 %34, %32
  store i64 %35, ptr %33, align 8, !tbaa !9
  br label %48

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

48:                                               ; preds = %36, %30
  br label %49

49:                                               ; preds = %48, %20
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = add i64 %50, 1
  store i64 %51, ptr %6, align 8, !tbaa !9
  br label %14, !llvm.loop !12

52:                                               ; preds = %14
  %53 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = sub i64 %54, 348226201
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds i64, ptr %56, i64 0
  store i64 %55, ptr %57, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, 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.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 = !{!"long", !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 i64, ptr %0, align 8, !tbaa !5
  %4 = mul i64 %3, 67330564296145686
  %5 = add i64 %4, -2350340661842412260
  %.sroa.0.0.extract.trunc = trunc i64 %5 to i8
  %.sroa.9.0.extract.shift = lshr i64 %5, 8
  %.sroa.9.0.extract.trunc = trunc i64 %.sroa.9.0.extract.shift to i8
  %.sroa.11.0.extract.shift = lshr i64 %5, 16
  %.sroa.11.0.extract.trunc = trunc i64 %.sroa.11.0.extract.shift to i40
  %.sroa.1166.0.extract.shift = lshr i64 %5, 56
  %.sroa.1166.0.extract.trunc = trunc nuw i64 %.sroa.1166.0.extract.shift to i8
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %11
  %.sroa.11.sroa.0.099 = phi i40 [ %.sroa.11.sroa.0.1, %11 ], [ %.sroa.11.0.extract.trunc, %2 ]
  %.098 = phi i64 [ %12, %11 ], [ 0, %2 ]
  %.sroa.0.097 = phi i8 [ %.sroa.0.1, %11 ], [ %.sroa.0.0.extract.trunc, %2 ]
  %.sroa.9.096 = phi i8 [ %.sroa.9.1, %11 ], [ %.sroa.9.0.extract.trunc, %2 ]
  %.sroa.1166.095 = phi i8 [ %.sroa.1166.1, %11 ], [ %.sroa.1166.0.extract.trunc, %2 ]
  %.sroa.1166.0.insert.ext = zext i8 %.sroa.1166.095 to i64
  %.sroa.1166.0.insert.shift = shl nuw i64 %.sroa.1166.0.insert.ext, 56
  %.sroa.11.0.insert.ext = zext i40 %.sroa.11.sroa.0.099 to i64
  %.sroa.11.0.insert.shift = shl nuw nsw i64 %.sroa.11.0.insert.ext, 16
  %.sroa.11.0.insert.insert = or disjoint i64 %.sroa.11.0.insert.shift, %.sroa.1166.0.insert.shift
  %.sroa.9.0.insert.ext = zext i8 %.sroa.9.096 to i64
  %.sroa.9.0.insert.shift = shl nuw nsw i64 %.sroa.9.0.insert.ext, 8
  %.sroa.9.0.insert.insert = or disjoint i64 %.sroa.11.0.insert.insert, %.sroa.9.0.insert.shift
  %.sroa.0.0.insert.ext = zext i8 %.sroa.0.097 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.9.0.insert.insert, %.sroa.0.0.insert.ext
  %8 = icmp ult i64 %.sroa.0.0.insert.insert, %.098
  br i1 %8, label %9, label %11

9:                                                ; preds = %.lr.ph
  %10 = shl i64 %.sroa.0.0.insert.insert, 1
  %.sroa.0.0.extract.trunc17 = trunc i64 %10 to i8
  %.sroa.9.0.extract.shift37 = lshr i64 %10, 8
  %.sroa.9.0.extract.trunc38 = trunc i64 %.sroa.9.0.extract.shift37 to i8
  %.sroa.11.0.extract.shift59 = lshr i64 %10, 16
  %.sroa.11.0.extract.trunc60 = trunc i64 %.sroa.11.0.extract.shift59 to i40
  %.sroa.1166.0.extract.shift82 = lshr i64 %10, 56
  %.sroa.1166.0.extract.trunc83 = trunc nuw i64 %.sroa.1166.0.extract.shift82 to i8
  br label %11

11:                                               ; preds = %9, %.lr.ph
  %.sroa.1166.1 = phi i8 [ %.sroa.1166.0.extract.trunc83, %9 ], [ %.sroa.1166.095, %.lr.ph ]
  %.sroa.9.1 = phi i8 [ %.sroa.9.0.extract.trunc38, %9 ], [ %.sroa.9.096, %.lr.ph ]
  %.sroa.0.1 = phi i8 [ %.sroa.0.0.extract.trunc17, %9 ], [ %.sroa.0.097, %.lr.ph ]
  %.sroa.11.sroa.0.1 = phi i40 [ %.sroa.11.0.extract.trunc60, %9 ], [ %.sroa.11.sroa.0.099, %.lr.ph ]
  %12 = add nuw i64 %.098, 1
  %exitcond.not = icmp eq i64 %12, %7
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %11, %2
  %.sroa.1166.0.lcssa = phi i8 [ %.sroa.1166.0.extract.trunc, %2 ], [ %.sroa.1166.1, %11 ]
  %.sroa.9.0.lcssa = phi i8 [ %.sroa.9.0.extract.trunc, %2 ], [ %.sroa.9.1, %11 ]
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.1, %11 ]
  %.sroa.11.sroa.0.0.lcssa = phi i40 [ %.sroa.11.0.extract.trunc, %2 ], [ %.sroa.11.sroa.0.1, %11 ]
  %.sroa.1166.0.insert.ext85 = zext i8 %.sroa.1166.0.lcssa to i64
  %.sroa.1166.0.insert.shift86 = shl nuw i64 %.sroa.1166.0.insert.ext85, 56
  %.sroa.11.0.insert.ext62 = zext i40 %.sroa.11.sroa.0.0.lcssa to i64
  %.sroa.11.0.insert.shift63 = shl nuw nsw i64 %.sroa.11.0.insert.ext62, 16
  %.sroa.9.0.insert.ext40 = zext i8 %.sroa.9.0.lcssa to i64
  %.sroa.9.0.insert.shift41 = shl nuw nsw i64 %.sroa.9.0.insert.ext40, 8
  %.sroa.0.0.insert.ext19 = zext i8 %.sroa.0.0.lcssa to i64
  %.sroa.11.0.insert.insert65 = add i64 %.sroa.1166.0.insert.shift86, -348226201
  %.sroa.9.0.insert.insert43 = add nuw nsw i64 %.sroa.11.0.insert.insert65, %.sroa.0.0.insert.ext19
  %.sroa.0.0.insert.insert21 = add nuw nsw i64 %.sroa.9.0.insert.insert43, %.sroa.9.0.insert.shift41
  %13 = add i64 %.sroa.0.0.insert.insert21, %.sroa.11.0.insert.shift63
  store i64 %13, ptr %1, align 8, !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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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