; LLVM IR from Aeternum-Veritas/Merry :: tests/hosttest (randtest)

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

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [12 x i32], align 16
  %3 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @srand(i32 noundef 123) #4
  call void @llvm.lifetime.start.p0(i64 48, ptr %2) #4
  %4 = call i32 @rand() #4
  store i32 %4, ptr %2, align 4, !tbaa !5
  %5 = getelementptr inbounds i32, ptr %2, i64 1
  %6 = call i32 @rand() #4
  store i32 %6, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i32, ptr %2, i64 2
  %8 = call i32 @rand() #4
  store i32 %8, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds i32, ptr %2, i64 3
  %10 = call i32 @rand() #4
  store i32 %10, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i32, ptr %2, i64 4
  %12 = call i32 @rand() #4
  store i32 %12, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i32, ptr %2, i64 5
  %14 = call i32 @rand() #4
  store i32 %14, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %2, i64 6
  %16 = call i32 @rand() #4
  store i32 %16, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i32, ptr %2, i64 7
  %18 = call i32 @rand() #4
  store i32 %18, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %2, i64 8
  %20 = call i32 @rand() #4
  store i32 %20, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i32, ptr %2, i64 9
  %22 = call i32 @rand() #4
  store i32 %22, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %2, i64 10
  %24 = call i32 @rand() #4
  store i32 %24, ptr %23, align 4, !tbaa !5
  %25 = getelementptr inbounds i32, ptr %2, i64 11
  %26 = call i32 @rand() #4
  store i32 %26, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %36, %0
  %28 = load i64, ptr %3, align 8, !tbaa !9
  %29 = icmp slt i64 %28, 12
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %39

31:                                               ; preds = %27
  %32 = load i64, ptr %3, align 8, !tbaa !9
  %33 = getelementptr inbounds [12 x i32], ptr %2, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %34)
  br label %36

36:                                               ; preds = %31
  %37 = load i64, ptr %3, align 8, !tbaa !9
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %3, align 8, !tbaa !9
  br label %27, !llvm.loop !11

39:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 48, ptr %2) #4
  %40 = load i32, ptr %1, align 4
  ret i32 %40
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #1

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

; Function Attrs: nounwind
declare i32 @rand() #1

declare i32 @printf(ptr noundef, ...) #3

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

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 = { nounwind "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @srand(i32 noundef 123) #3
  %1 = tail call i32 @rand() #3
  %2 = tail call i32 @rand() #3
  %3 = tail call i32 @rand() #3
  %4 = tail call i32 @rand() #3
  %5 = tail call i32 @rand() #3
  %6 = tail call i32 @rand() #3
  %7 = tail call i32 @rand() #3
  %8 = tail call i32 @rand() #3
  %9 = tail call i32 @rand() #3
  %10 = tail call i32 @rand() #3
  %11 = tail call i32 @rand() #3
  %12 = tail call i32 @rand() #3
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %3)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %4)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %5)
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %6)
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %7)
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %8)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %9)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %10)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %11)
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %12)
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { nounwind "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 = { nofree nounwind "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 #3 = { 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)"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass