; LLVM IR from holzschu/ios_system :: text_cmds/comm (comm)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @wcsicoll(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [2049 x i32], align 16
  %7 = alloca [2049 x i32], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8196, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8196, ptr %7) #3
  %8 = getelementptr inbounds [2049 x i32], ptr %6, i64 0, i64 0
  store ptr %8, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %19, %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %22

13:                                               ; preds = %9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = call i32 @towlower(i32 noundef %15) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %17, i32 1
  store ptr %18, ptr %5, align 8, !tbaa !5
  store i32 %16, ptr %17, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds i32, ptr %20, i32 1
  store ptr %21, ptr %3, align 8, !tbaa !5
  br label %9, !llvm.loop !11

22:                                               ; preds = %9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds [2049 x i32], ptr %7, i64 0, i64 0
  store ptr %24, ptr %5, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %35, %22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %38

29:                                               ; preds = %25
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = call i32 @towlower(i32 noundef %31) #3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds i32, ptr %33, i32 1
  store ptr %34, ptr %5, align 8, !tbaa !5
  store i32 %32, ptr %33, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %29
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds i32, ptr %36, i32 1
  store ptr %37, ptr %4, align 8, !tbaa !5
  br label %25, !llvm.loop !13

38:                                               ; preds = %25
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %39, align 4, !tbaa !9
  %40 = getelementptr inbounds [2049 x i32], ptr %6, i64 0, i64 0
  %41 = getelementptr inbounds [2049 x i32], ptr %7, i64 0, i64 0
  %42 = call i32 @wcscoll(ptr noundef %40, ptr noundef %41) #3
  call void @llvm.lifetime.end.p0(i64 8196, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8196, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 %42
}

; Function Attrs: nounwind
declare i32 @wcscoll(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind
declare i32 @towlower(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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)"}
!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @wcsicoll(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca [2049 x i32], align 16
  %4 = alloca [2049 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 8196, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8196, ptr nonnull %4) #3
  %5 = load i32, ptr %0, align 4, !tbaa !5
  %.not15 = icmp eq i32 %5, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %6 = phi i32 [ %10, %.lr.ph ], [ %5, %2 ]
  %.017 = phi ptr [ %8, %.lr.ph ], [ %3, %2 ]
  %.01116 = phi ptr [ %9, %.lr.ph ], [ %0, %2 ]
  %7 = tail call i32 @towlower(i32 noundef %6) #3
  %8 = getelementptr inbounds i8, ptr %.017, i64 4
  store i32 %7, ptr %.017, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %.01116, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.0.lcssa = phi ptr [ %3, %2 ], [ %8, %.lr.ph ]
  store i32 0, ptr %.0.lcssa, align 4, !tbaa !5
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %.not1418 = icmp eq i32 %11, 0
  br i1 %.not1418, label %._crit_edge23, label %.lr.ph22

.lr.ph22:                                         ; preds = %._crit_edge, %.lr.ph22
  %12 = phi i32 [ %16, %.lr.ph22 ], [ %11, %._crit_edge ]
  %.120 = phi ptr [ %14, %.lr.ph22 ], [ %4, %._crit_edge ]
  %.01019 = phi ptr [ %15, %.lr.ph22 ], [ %1, %._crit_edge ]
  %13 = tail call i32 @towlower(i32 noundef %12) #3
  %14 = getelementptr inbounds i8, ptr %.120, i64 4
  store i32 %13, ptr %.120, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.01019, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %.not14 = icmp eq i32 %16, 0
  br i1 %.not14, label %._crit_edge23, label %.lr.ph22, !llvm.loop !11

._crit_edge23:                                    ; preds = %.lr.ph22, %._crit_edge
  %.1.lcssa = phi ptr [ %4, %._crit_edge ], [ %14, %.lr.ph22 ]
  store i32 0, ptr %.1.lcssa, align 4, !tbaa !5
  %17 = call i32 @wcscoll(ptr noundef nonnull %3, ptr noundef nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8196, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8196, ptr nonnull %3) #3
  ret i32 %17
}

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

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

; Function Attrs: nounwind
declare i32 @towlower(i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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