; LLVM IR from ROCm/aomp :: test/smoke/memcmp (memcmp)

; 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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 128, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = mul i64 %9, 4
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = call noalias ptr @malloc(i64 noundef %13) #6
  store ptr %14, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = call noalias ptr @malloc(i64 noundef %16) #6
  store ptr %17, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %34, %0
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %37

23:                                               ; preds = %18
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %25, i64 %27
  store i32 %24, ptr %28, align 4, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %23
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %18, !llvm.loop !11

37:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = call i32 @memcmp(ptr noundef %38, ptr noundef %39, i64 noundef %41) #7
  store i32 %42, ptr %7, align 4, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %37
  br label %48

46:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 27, ptr noundef @__PRETTY_FUNCTION__.main) #8
  unreachable

47:                                               ; No predecessors!
  br label %48

48:                                               ; preds = %47, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

attributes #0 = { mustprogress norecurse 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 allocsize(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 #3 = { nounwind willreturn memory(read) "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 = { noreturn 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
vector.ph:
  %0 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #4
  %1 = tail call noalias dereferenceable_or_null(512) ptr @malloc(i64 noundef 512) #4
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, ptr %0, align 4, !tbaa !5
  store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, ptr %1, align 4, !tbaa !5
  store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, ptr %4, align 4, !tbaa !5
  store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = getelementptr inbounds i8, ptr %1, i64 48
  store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, ptr %6, align 4, !tbaa !5
  store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, ptr %7, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, ptr %8, align 4, !tbaa !5
  store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 64
  %11 = getelementptr inbounds i8, ptr %1, i64 80
  store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, ptr %10, align 4, !tbaa !5
  store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, ptr %12, align 4, !tbaa !5
  store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, ptr %13, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 96
  %15 = getelementptr inbounds i8, ptr %1, i64 112
  store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, ptr %14, align 4, !tbaa !5
  store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 128
  %17 = getelementptr inbounds i8, ptr %0, i64 144
  store <4 x i32> <i32 32, i32 33, i32 34, i32 35>, ptr %16, align 4, !tbaa !5
  store <4 x i32> <i32 36, i32 37, i32 38, i32 39>, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 128
  %19 = getelementptr inbounds i8, ptr %1, i64 144
  store <4 x i32> <i32 32, i32 33, i32 34, i32 35>, ptr %18, align 4, !tbaa !5
  store <4 x i32> <i32 36, i32 37, i32 38, i32 39>, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 160
  %21 = getelementptr inbounds i8, ptr %0, i64 176
  store <4 x i32> <i32 40, i32 41, i32 42, i32 43>, ptr %20, align 4, !tbaa !5
  store <4 x i32> <i32 44, i32 45, i32 46, i32 47>, ptr %21, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 160
  %23 = getelementptr inbounds i8, ptr %1, i64 176
  store <4 x i32> <i32 40, i32 41, i32 42, i32 43>, ptr %22, align 4, !tbaa !5
  store <4 x i32> <i32 44, i32 45, i32 46, i32 47>, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 192
  %25 = getelementptr inbounds i8, ptr %0, i64 208
  store <4 x i32> <i32 48, i32 49, i32 50, i32 51>, ptr %24, align 4, !tbaa !5
  store <4 x i32> <i32 52, i32 53, i32 54, i32 55>, ptr %25, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 192
  %27 = getelementptr inbounds i8, ptr %1, i64 208
  store <4 x i32> <i32 48, i32 49, i32 50, i32 51>, ptr %26, align 4, !tbaa !5
  store <4 x i32> <i32 52, i32 53, i32 54, i32 55>, ptr %27, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 224
  %29 = getelementptr inbounds i8, ptr %0, i64 240
  store <4 x i32> <i32 56, i32 57, i32 58, i32 59>, ptr %28, align 4, !tbaa !5
  store <4 x i32> <i32 60, i32 61, i32 62, i32 63>, ptr %29, align 4, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %1, i64 224
  %31 = getelementptr inbounds i8, ptr %1, i64 240
  store <4 x i32> <i32 56, i32 57, i32 58, i32 59>, ptr %30, align 4, !tbaa !5
  store <4 x i32> <i32 60, i32 61, i32 62, i32 63>, ptr %31, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 256
  %33 = getelementptr inbounds i8, ptr %0, i64 272
  store <4 x i32> <i32 64, i32 65, i32 66, i32 67>, ptr %32, align 4, !tbaa !5
  store <4 x i32> <i32 68, i32 69, i32 70, i32 71>, ptr %33, align 4, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 256
  %35 = getelementptr inbounds i8, ptr %1, i64 272
  store <4 x i32> <i32 64, i32 65, i32 66, i32 67>, ptr %34, align 4, !tbaa !5
  store <4 x i32> <i32 68, i32 69, i32 70, i32 71>, ptr %35, align 4, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 288
  %37 = getelementptr inbounds i8, ptr %0, i64 304
  store <4 x i32> <i32 72, i32 73, i32 74, i32 75>, ptr %36, align 4, !tbaa !5
  store <4 x i32> <i32 76, i32 77, i32 78, i32 79>, ptr %37, align 4, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %1, i64 288
  %39 = getelementptr inbounds i8, ptr %1, i64 304
  store <4 x i32> <i32 72, i32 73, i32 74, i32 75>, ptr %38, align 4, !tbaa !5
  store <4 x i32> <i32 76, i32 77, i32 78, i32 79>, ptr %39, align 4, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 320
  %41 = getelementptr inbounds i8, ptr %0, i64 336
  store <4 x i32> <i32 80, i32 81, i32 82, i32 83>, ptr %40, align 4, !tbaa !5
  store <4 x i32> <i32 84, i32 85, i32 86, i32 87>, ptr %41, align 4, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %1, i64 320
  %43 = getelementptr inbounds i8, ptr %1, i64 336
  store <4 x i32> <i32 80, i32 81, i32 82, i32 83>, ptr %42, align 4, !tbaa !5
  store <4 x i32> <i32 84, i32 85, i32 86, i32 87>, ptr %43, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 352
  %45 = getelementptr inbounds i8, ptr %0, i64 368
  store <4 x i32> <i32 88, i32 89, i32 90, i32 91>, ptr %44, align 4, !tbaa !5
  store <4 x i32> <i32 92, i32 93, i32 94, i32 95>, ptr %45, align 4, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 352
  %47 = getelementptr inbounds i8, ptr %1, i64 368
  store <4 x i32> <i32 88, i32 89, i32 90, i32 91>, ptr %46, align 4, !tbaa !5
  store <4 x i32> <i32 92, i32 93, i32 94, i32 95>, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %0, i64 384
  %49 = getelementptr inbounds i8, ptr %0, i64 400
  store <4 x i32> <i32 96, i32 97, i32 98, i32 99>, ptr %48, align 4, !tbaa !5
  store <4 x i32> <i32 100, i32 101, i32 102, i32 103>, ptr %49, align 4, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %1, i64 384
  %51 = getelementptr inbounds i8, ptr %1, i64 400
  store <4 x i32> <i32 96, i32 97, i32 98, i32 99>, ptr %50, align 4, !tbaa !5
  store <4 x i32> <i32 100, i32 101, i32 102, i32 103>, ptr %51, align 4, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %0, i64 416
  %53 = getelementptr inbounds i8, ptr %0, i64 432
  store <4 x i32> <i32 104, i32 105, i32 106, i32 107>, ptr %52, align 4, !tbaa !5
  store <4 x i32> <i32 108, i32 109, i32 110, i32 111>, ptr %53, align 4, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %1, i64 416
  %55 = getelementptr inbounds i8, ptr %1, i64 432
  store <4 x i32> <i32 104, i32 105, i32 106, i32 107>, ptr %54, align 4, !tbaa !5
  store <4 x i32> <i32 108, i32 109, i32 110, i32 111>, ptr %55, align 4, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %0, i64 448
  %57 = getelementptr inbounds i8, ptr %0, i64 464
  store <4 x i32> <i32 112, i32 113, i32 114, i32 115>, ptr %56, align 4, !tbaa !5
  store <4 x i32> <i32 116, i32 117, i32 118, i32 119>, ptr %57, align 4, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %1, i64 448
  %59 = getelementptr inbounds i8, ptr %1, i64 464
  store <4 x i32> <i32 112, i32 113, i32 114, i32 115>, ptr %58, align 4, !tbaa !5
  store <4 x i32> <i32 116, i32 117, i32 118, i32 119>, ptr %59, align 4, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %0, i64 480
  %61 = getelementptr inbounds i8, ptr %0, i64 496
  store <4 x i32> <i32 120, i32 121, i32 122, i32 123>, ptr %60, align 4, !tbaa !5
  store <4 x i32> <i32 124, i32 125, i32 126, i32 127>, ptr %61, align 4, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %1, i64 480
  %63 = getelementptr inbounds i8, ptr %1, i64 496
  store <4 x i32> <i32 120, i32 121, i32 122, i32 123>, ptr %62, align 4, !tbaa !5
  store <4 x i32> <i32 124, i32 125, i32 126, i32 127>, ptr %63, align 4, !tbaa !5
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(512) %0, ptr noundef nonnull dereferenceable(512) %1, i64 512)
  %64 = icmp eq i32 %bcmp, 0
  br i1 %64, label %66, label %65

65:                                               ; preds = %vector.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 27, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #5
  unreachable

66:                                               ; preds = %vector.ph
  ret i32 0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #0 = { mustprogress norecurse 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { noreturn 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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { nounwind allocsize(0) }
attributes #5 = { noreturn 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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass