; LLVM IR from mirohs/gc :: util (base_test_equal_s)

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

@base_check_count = external hidden global i32, align 4
@base_check_success_count = external hidden global i32, align 4
@.str.76 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [68 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @base_test_equal_s(ptr noundef %0, i32 noundef %1, ptr %2, i64 %3, ptr noundef %4) #1 {
  %6 = alloca i1, align 1
  %7 = alloca %struct.String, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  store ptr %2, ptr %11, align 8
  %12 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  store i64 %3, ptr %12, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @base_init()
  %13 = load i32, ptr @base_check_count, align 4, !tbaa !9
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr @base_check_count, align 4, !tbaa !9
  %15 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %37

18:                                               ; preds = %5
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %37

21:                                               ; preds = %18
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = call i64 @strlen(ptr noundef %22) #3
  %24 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = sext i32 %25 to i64
  %27 = icmp eq i64 %23, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %21
  %29 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = call i32 @strncmp(ptr noundef %30, ptr noundef %31, i64 noundef %34) #3
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %44, label %37

37:                                               ; preds = %28, %21, %18, %5
  %38 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %50

41:                                               ; preds = %37
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %50

44:                                               ; preds = %41, %28
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.76, ptr noundef %45, i32 noundef %46)
  %48 = load i32, ptr @base_check_success_count, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr @base_check_success_count, align 4, !tbaa !9
  store i1 true, ptr %6, align 1
  br label %59

50:                                               ; preds = %41, %37
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %54 = load i32, ptr %53, align 8, !tbaa !13
  %55 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.78, ptr noundef %51, i32 noundef %52, i32 noundef %54, ptr noundef %56, ptr noundef %57)
  store i1 false, ptr %6, align 1
  br label %59

59:                                               ; preds = %50, %44
  %60 = load i1, ptr %6, align 1
  ret i1 %60
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @base_init() #1

attributes #0 = { 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 #1 = { 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 #2 = { "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) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"String", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 8}


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

@base_check_count = external hidden local_unnamed_addr global i32, align 4
@base_check_success_count = external hidden local_unnamed_addr global i32, align 4
@.str.76 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [68 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @base_test_equal_s(ptr noundef %0, i32 noundef %1, ptr %2, i64 %3, ptr noundef %4) local_unnamed_addr #1 {
  %.sroa.5.8.extract.trunc = trunc i64 %3 to i32
  tail call void @base_init()
  %6 = load i32, ptr @base_check_count, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr @base_check_count, align 4, !tbaa !5
  %8 = icmp ne ptr %2, null
  %9 = icmp ne ptr %4, null
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %10, label %17

10:                                               ; preds = %5
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #3
  %sext = shl i64 %3, 32
  %12 = ashr exact i64 %sext, 32
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %14, label %.thread

14:                                               ; preds = %10
  %15 = tail call i32 @strncmp(ptr noundef nonnull %2, ptr noundef nonnull %4, i64 noundef %11) #3
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %20, label %.thread

17:                                               ; preds = %5
  %18 = icmp eq ptr %2, null
  %19 = icmp eq ptr %4, null
  %or.cond3 = and i1 %18, %19
  br i1 %or.cond3, label %20, label %.thread

20:                                               ; preds = %17, %14
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.76, ptr noundef %0, i32 noundef %1)
  %22 = load i32, ptr @base_check_success_count, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @base_check_success_count, align 4, !tbaa !5
  br label %25

.thread:                                          ; preds = %10, %14, %17
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.78, ptr noundef %0, i32 noundef %1, i32 noundef %.sroa.5.8.extract.trunc, ptr noundef %2, ptr noundef %4)
  br label %25

25:                                               ; preds = %.thread, %20
  %.0 = phi i1 [ true, %20 ], [ false, %.thread ]
  ret i1 %.0
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @base_init() local_unnamed_addr #1

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 = { 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 #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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass