; LLVM IR from aap/librw :: src/base.ll (ZN2rw9strcmp_ciEPKcS1_)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN2rw9strcmp_ciEPKcS1_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  br label %9

9:                                                ; preds = %36, %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = sext i8 %11 to i32
  %13 = call i32 @tolower(i32 noundef %12) #4
  %14 = trunc i32 %13 to i8
  store i8 %14, ptr %6, align 1, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = call i32 @tolower(i32 noundef %17) #4
  %19 = trunc i32 %18 to i8
  store i8 %19, ptr %7, align 1, !tbaa !9
  %20 = load i8, ptr %6, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = load i8, ptr %7, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp ne i32 %21, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %9
  %26 = load i8, ptr %6, align 1, !tbaa !9
  %27 = sext i8 %26 to i32
  %28 = load i8, ptr %7, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = sub nsw i32 %27, %29
  store i32 %30, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %41

31:                                               ; preds = %9
  %32 = load i8, ptr %6, align 1, !tbaa !9
  %33 = sext i8 %32 to i32
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %41

36:                                               ; preds = %31
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 1
  store ptr %38, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr %5, align 8, !tbaa !5
  br label %9, !llvm.loop !10

41:                                               ; preds = %35, %25
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %42 = load i32, ptr %3, align 4
  ret i32 %42
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #2

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

attributes #0 = { mustprogress 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 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 #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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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(read) uwtable
define dso_local noundef range(i32 -255, 256) i32 @_ZN2rw9strcmp_ciEPKcS1_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %4 = sext i8 %3 to i32
  %5 = tail call i32 @tolower(i32 noundef %4) #2
  %6 = load i8, ptr %1, align 1, !tbaa !5
  %7 = sext i8 %6 to i32
  %8 = tail call i32 @tolower(i32 noundef %7) #2
  %sext17 = shl i32 %5, 24
  %9 = ashr exact i32 %sext17, 24
  %sext1318 = shl i32 %8, 24
  %10 = ashr exact i32 %sext1318, 24
  %.not19 = icmp eq i32 %9, %10
  br i1 %.not19, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %13, %2
  %.lcssa15 = phi i32 [ %9, %2 ], [ %22, %13 ]
  %.lcssa = phi i32 [ %10, %2 ], [ %23, %13 ]
  %11 = sub nsw i32 %.lcssa15, %.lcssa
  br label %.loopexit

.lr.ph:                                           ; preds = %2, %13
  %sext22 = phi i32 [ %sext, %13 ], [ %sext17, %2 ]
  %.0921 = phi ptr [ %14, %13 ], [ %0, %2 ]
  %.01020 = phi ptr [ %15, %13 ], [ %1, %2 ]
  %12 = icmp eq i32 %sext22, 0
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %.lr.ph
  %14 = getelementptr inbounds i8, ptr %.0921, i64 1
  %15 = getelementptr inbounds i8, ptr %.01020, i64 1
  %16 = load i8, ptr %14, align 1, !tbaa !5
  %17 = sext i8 %16 to i32
  %18 = tail call i32 @tolower(i32 noundef %17) #2
  %19 = load i8, ptr %15, align 1, !tbaa !5
  %20 = sext i8 %19 to i32
  %21 = tail call i32 @tolower(i32 noundef %20) #2
  %sext = shl i32 %18, 24
  %22 = ashr exact i32 %sext, 24
  %sext13 = shl i32 %21, 24
  %23 = ashr exact i32 %sext13, 24
  %.not = icmp eq i32 %22, %23
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !8

.loopexit:                                        ; preds = %.lr.ph, %._crit_edge
  %.0 = phi i32 [ %11, %._crit_edge ], [ 0, %.lr.ph ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(read) 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 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 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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