; LLVM IR from LeoVen/C-Macro-Collections :: benchmarks/util (twister)

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

%struct.mt_state_s = type { [312 x i64], i32 }

; Function Attrs: nounwind uwtable
define dso_local void @twist_init(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.mt_state_s, ptr %5, i32 0, i32 1
  store i32 313, ptr %6, align 8, !tbaa !11
  %7 = load i64, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mt_state_s, ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds [312 x i64], ptr %9, i64 0, i64 0
  store i64 %7, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mt_state_s, ptr %11, i32 0, i32 1
  store i32 1, ptr %12, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %52, %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mt_state_s, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp slt i32 %16, 312
  br i1 %17, label %18, label %57

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mt_state_s, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mt_state_s, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [312 x i64], ptr %20, i64 0, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mt_state_s, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mt_state_s, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [312 x i64], ptr %29, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = lshr i64 %36, 62
  %38 = xor i64 %27, %37
  %39 = mul i64 6364136223846793005, %38
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mt_state_s, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = add i64 %39, %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mt_state_s, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mt_state_s, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [312 x i64], ptr %46, i64 0, i64 %50
  store i64 %44, ptr %51, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %18
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mt_state_s, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 8, !tbaa !11
  br label %13, !llvm.loop !14

57:                                               ; preds = %13
  ret void
}

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

!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 = !{!12, !13, i64 2496}
!12 = !{!"mt_state_s", !7, i64 0, !13, i64 2496}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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: write) uwtable
define dso_local void @twist_init(ptr nocapture noundef writeonly %0, i64 noundef %1) local_unnamed_addr #0 {
  store i64 %1, ptr %0, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %10, %2
  %4 = phi i64 [ %1, %2 ], [ %14, %10 ]
  %indvars.iv = phi i64 [ 1, %2 ], [ %indvars.iv.next.1, %10 ]
  %5 = lshr i64 %4, 62
  %6 = xor i64 %5, %4
  %7 = mul i64 %6, 6364136223846793005
  %8 = add i64 %7, %indvars.iv
  %9 = getelementptr inbounds [312 x i64], ptr %0, i64 0, i64 %indvars.iv
  store i64 %8, ptr %9, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 312
  br i1 %exitcond.not, label %16, label %10, !llvm.loop !9

10:                                               ; preds = %3
  %11 = lshr i64 %8, 62
  %12 = xor i64 %11, %8
  %13 = mul i64 %12, 6364136223846793005
  %14 = add i64 %13, %indvars.iv.next
  %15 = getelementptr inbounds [312 x i64], ptr %0, i64 0, i64 %indvars.iv.next
  store i64 %14, ptr %15, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %3

16:                                               ; preds = %3
  %17 = getelementptr inbounds i8, ptr %0, i64 2496
  store i32 312, ptr %17, align 8, !tbaa !11
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: write) 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"}
!11 = !{!12, !13, i64 2496}
!12 = !{!"mt_state_s", !7, i64 0, !13, i64 2496}
!13 = !{!"int", !7, i64 0}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass