; LLVM IR from Water-Melon/Melon :: src (mln_string)

; 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.mln_string_t = type { ptr, i64, i32 }

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_string_const_strcmp(ptr noundef nonnull %0, ptr noundef %1) #2 {
  %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
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mln_string_t, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %14, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %83

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i64 @strlen(ptr noundef %19) #4
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %6, align 4, !tbaa !12
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mln_string_t, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = load i32, ptr %6, align 4, !tbaa !12
  %26 = zext i32 %25 to i64
  %27 = icmp ugt i64 %24, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %18
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %82

29:                                               ; preds = %18
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mln_string_t, ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !14
  %33 = load i32, ptr %6, align 4, !tbaa !12
  %34 = zext i32 %33 to i64
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %82

37:                                               ; preds = %29
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mln_string_t, ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !14
  %41 = icmp ugt i64 %40, 280
  br i1 %41, label %47, label %42

42:                                               ; preds = %37
  %43 = load i32, ptr %6, align 4, !tbaa !12
  %44 = zext i32 %43 to i64
  %45 = urem i64 %44, 4
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %55

47:                                               ; preds = %42, %37
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mln_string_t, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !12
  %53 = zext i32 %52 to i64
  %54 = call i32 @memcmp(ptr noundef %50, ptr noundef %51, i64 noundef %53) #4
  store i32 %54, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %82

55:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_string_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  store ptr %58, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %59, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %60

60:                                               ; preds = %75, %55
  %61 = load i32, ptr %10, align 4, !tbaa !12
  %62 = load i32, ptr %6, align 4, !tbaa !12
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %64, label %80

64:                                               ; preds = %60
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds i32, ptr %65, i32 1
  store ptr %66, ptr %8, align 8, !tbaa !5
  %67 = load i32, ptr %65, align 4, !tbaa !12
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %68, i32 1
  store ptr %69, ptr %9, align 8, !tbaa !5
  %70 = load i32, ptr %68, align 4, !tbaa !12
  %71 = sub i32 %67, %70
  store i32 %71, ptr %11, align 4, !tbaa !12
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %64
  %74 = load i32, ptr %11, align 4, !tbaa !12
  store i32 %74, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %81

75:                                               ; preds = %64
  %76 = load i32, ptr %10, align 4, !tbaa !12
  %77 = zext i32 %76 to i64
  %78 = add i64 %77, 4
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %10, align 4, !tbaa !12
  br label %60, !llvm.loop !15

80:                                               ; preds = %60
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %81

81:                                               ; preds = %80, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %82

82:                                               ; preds = %81, %47, %36, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %83

83:                                               ; preds = %82, %17
  %84 = load i32, ptr %3, align 4
  ret i32 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 16, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !11, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @memcmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @mln_string_const_strcmp(ptr nocapture noundef nonnull readonly %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = icmp eq ptr %3, %1
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %2
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #2
  %7 = trunc i64 %6 to i32
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = and i64 %6, 4294967295
  %11 = icmp ugt i64 %9, %10
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %5
  %13 = icmp ult i64 %9, %10
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %12
  %15 = icmp ult i64 %9, 281
  %16 = and i64 %6, 3
  %.not = icmp eq i64 %16, 0
  %or.cond = and i1 %15, %.not
  br i1 %or.cond, label %.preheader, label %17

.preheader:                                       ; preds = %14
  %.not34 = icmp eq i32 %7, 0
  br i1 %.not34, label %.loopexit, label %.lr.ph

17:                                               ; preds = %14
  %18 = tail call i32 @memcmp(ptr noundef %3, ptr noundef %1, i64 noundef %10) #2
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %22
  %.02031 = phi i32 [ %25, %22 ], [ 0, %.preheader ]
  %.02130 = phi ptr [ %23, %22 ], [ %1, %.preheader ]
  %.02229 = phi ptr [ %24, %22 ], [ %3, %.preheader ]
  %19 = load i32, ptr %.02229, align 4, !tbaa !12
  %20 = load i32, ptr %.02130, align 4, !tbaa !12
  %21 = sub i32 %19, %20
  %.not28 = icmp eq i32 %21, 0
  br i1 %.not28, label %22, label %.loopexit

22:                                               ; preds = %.lr.ph
  %23 = getelementptr inbounds i8, ptr %.02130, i64 4
  %24 = getelementptr inbounds i8, ptr %.02229, i64 4
  %25 = add i32 %.02031, 4
  %26 = icmp ult i32 %25, %7
  br i1 %26, label %.lr.ph, label %.loopexit, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph, %22, %.preheader, %17, %5, %12, %2
  %.2 = phi i32 [ 0, %2 ], [ %18, %17 ], [ 1, %5 ], [ -1, %12 ], [ 0, %.preheader ], [ %21, %.lr.ph ], [ 0, %22 ]
  ret i32 %.2
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #1 = { nofree nounwind memory(read, inaccessiblemem: none) 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 willreturn memory(read) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass