; LLVM IR from kala13x/libxutils :: src/sys (cli)

; 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.xcli_wind_ = type { i32, %struct.xcli_size_, %struct.XArray_, i8 }
%struct.xcli_size_ = type { i64, i64 }
%struct.XArray_ = type { ptr, ptr, i32, ptr, i8, i8, i8, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @XWindow_UpdateSize(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @XWindow_AddLineFmt(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @XWindow_AddAligned(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca [2048 x i8], align 16
  %14 = alloca [2048 x i8], align 16
  %15 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i8 %3, ptr %9, align 1, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call i32 @XWindow_UpdateSize(ptr noundef %16)
  %18 = icmp eq i32 %17, -1
  br i1 %18, label %19, label %20

19:                                               ; preds = %4
  store i32 -1, ptr %5, align 4
  br label %98

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.xcli_wind_, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.xcli_size_, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !10
  store i64 %24, ptr %10, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i64 @strlen(ptr noundef %25) #5
  store i64 %26, ptr %11, align 8, !tbaa !16
  %27 = load i64, ptr %11, align 8, !tbaa !16
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %20
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %97

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 2048, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store i64 0, ptr %15, align 8, !tbaa !16
  %31 = load i8, ptr %9, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = load i64, ptr %10, align 8, !tbaa !16
  %36 = load i64, ptr %11, align 8, !tbaa !16
  %37 = sub i64 %35, %36
  %38 = udiv i64 %37, 2
  store i64 %38, ptr %15, align 8, !tbaa !16
  br label %48

39:                                               ; preds = %30
  %40 = load i8, ptr %9, align 1, !tbaa !9
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %47

43:                                               ; preds = %39
  %44 = load i64, ptr %10, align 8, !tbaa !16
  %45 = load i64, ptr %11, align 8, !tbaa !16
  %46 = sub i64 %44, %45
  store i64 %46, ptr %15, align 8, !tbaa !16
  br label %47

47:                                               ; preds = %43, %39
  br label %48

48:                                               ; preds = %47, %34
  %49 = getelementptr inbounds [2048 x i8], ptr %14, i64 0, i64 0
  %50 = load i64, ptr %15, align 8, !tbaa !16
  %51 = call i64 @xstrnfill(ptr noundef %49, i64 noundef 2048, i64 noundef %50, i8 noundef signext 32)
  %52 = load i8, ptr %9, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %48
  store i64 0, ptr %15, align 8, !tbaa !16
  br label %77

56:                                               ; preds = %48
  %57 = load i8, ptr %9, align 1, !tbaa !9
  %58 = zext i8 %57 to i32
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %67

60:                                               ; preds = %56
  %61 = load i64, ptr %10, align 8, !tbaa !16
  %62 = urem i64 %61, 2
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %60
  %65 = load i64, ptr %15, align 8, !tbaa !16
  %66 = add i64 %65, 1
  store i64 %66, ptr %15, align 8, !tbaa !16
  br label %76

67:                                               ; preds = %60, %56
  %68 = load i8, ptr %9, align 1, !tbaa !9
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %69, 2
  br i1 %70, label %71, label %75

71:                                               ; preds = %67
  %72 = load i64, ptr %10, align 8, !tbaa !16
  %73 = load i64, ptr %11, align 8, !tbaa !16
  %74 = sub i64 %72, %73
  store i64 %74, ptr %15, align 8, !tbaa !16
  br label %75

75:                                               ; preds = %71, %67
  br label %76

76:                                               ; preds = %75, %64
  br label %77

77:                                               ; preds = %76, %55
  %78 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %79 = load i64, ptr %15, align 8, !tbaa !16
  %80 = call i64 @xstrnfill(ptr noundef %78, i64 noundef 2048, i64 noundef %79, i8 noundef signext 32)
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = icmp eq ptr %81, null
  br i1 %82, label %83, label %89

83:                                               ; preds = %77
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds [2048 x i8], ptr %14, i64 0, i64 0
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %88 = call i32 (ptr, ptr, ...) @XWindow_AddLineFmt(ptr noundef %84, ptr noundef @.str.1, ptr noundef %85, ptr noundef %86, ptr noundef %87)
  store i32 %88, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %96

89:                                               ; preds = %77
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds [2048 x i8], ptr %14, i64 0, i64 0
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %95 = call i32 (ptr, ptr, ...) @XWindow_AddLineFmt(ptr noundef %90, ptr noundef @.str.2, ptr noundef %91, ptr noundef %92, ptr noundef %93, ptr noundef %94, ptr noundef @.str.3)
  store i32 %95, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %96

96:                                               ; preds = %89, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %13) #4
  br label %97

97:                                               ; preds = %96, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %98

98:                                               ; preds = %97, %19
  %99 = load i32, ptr %5, align 4
  ret i32 %99
}

declare i64 @xstrnfill(ptr noundef, i64 noundef, i64 noundef, i8 noundef signext) #3

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 = { "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 = { nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !14, i64 8}
!11 = !{!"xcli_wind_", !12, i64 0, !13, i64 8, !15, i64 24, !7, i64 80}
!12 = !{!"int", !7, i64 0}
!13 = !{!"xcli_size_", !14, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!"XArray_", !6, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !7, i64 32, !7, i64 33, !7, i64 34, !14, i64 40, !14, i64 48}
!16 = !{!14, !14, i64 0}


; 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.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

; 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 uwtable
declare dso_local i32 @XWindow_UpdateSize(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @XWindow_AddLineFmt(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @XWindow_AddAligned(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) local_unnamed_addr #2 {
  %5 = alloca [2048 x i8], align 16
  %6 = alloca [2048 x i8], align 16
  %7 = tail call i32 @XWindow_UpdateSize(ptr noundef %0)
  %8 = icmp eq i32 %7, -1
  br i1 %8, label %35, label %9

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #4
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %35, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %6) #5
  %14 = icmp eq i8 %3, 0
  br i1 %14, label %19, label %15

15:                                               ; preds = %13
  %16 = icmp eq i8 %3, 1
  %17 = sub i64 %11, %12
  %spec.select = select i1 %16, i64 %17, i64 0
  %18 = call i64 @xstrnfill(ptr noundef nonnull %6, i64 noundef 2048, i64 noundef %spec.select, i8 noundef signext 32) #5
  br i1 %16, label %27, label %.thread36

19:                                               ; preds = %13
  %20 = sub i64 %11, %12
  %21 = lshr i64 %20, 1
  %22 = call i64 @xstrnfill(ptr noundef nonnull %6, i64 noundef 2048, i64 noundef %21, i8 noundef signext 32) #5
  %23 = and i64 %11, 1
  %.not31 = icmp eq i64 %23, 0
  br i1 %.not31, label %.thread36, label %24

24:                                               ; preds = %19
  %25 = add nuw i64 %21, 1
  br label %27

.thread36:                                        ; preds = %15, %19
  %.pre-phi = phi i64 [ %17, %15 ], [ %20, %19 ]
  %.03541 = phi i64 [ 0, %15 ], [ %21, %19 ]
  %26 = icmp eq i8 %3, 2
  %spec.select33 = select i1 %26, i64 %.pre-phi, i64 %.03541
  br label %27

27:                                               ; preds = %.thread36, %15, %24
  %.1 = phi i64 [ %25, %24 ], [ 0, %15 ], [ %spec.select33, %.thread36 ]
  %28 = call i64 @xstrnfill(ptr noundef nonnull %5, i64 noundef 2048, i64 noundef %.1, i8 noundef signext 32) #5
  %29 = icmp eq ptr %2, null
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = call i32 (ptr, ptr, ...) @XWindow_AddLineFmt(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %6, ptr noundef %1, ptr noundef nonnull %5)
  br label %34

32:                                               ; preds = %27
  %33 = call i32 (ptr, ptr, ...) @XWindow_AddLineFmt(ptr noundef nonnull %0, ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %6, ptr noundef %1, ptr noundef nonnull %5, ptr noundef nonnull @.str.3)
  br label %34

34:                                               ; preds = %32, %30
  %.025 = phi i32 [ %31, %30 ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %5) #5
  br label %35

35:                                               ; preds = %34, %9, %4
  %.2 = phi i32 [ -1, %4 ], [ %.025, %34 ], [ -1, %9 ]
  ret i32 %.2
}

declare i64 @xstrnfill(ptr noundef, i64 noundef, i64 noundef, i8 noundef signext) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = { nounwind willreturn memory(read) }
attributes #5 = { 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, !11, i64 8}
!6 = !{!"xcli_wind_", !7, i64 0, !10, i64 8, !12, i64 24, !8, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"xcli_size_", !11, i64 0, !11, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"XArray_", !13, i64 0, !13, i64 8, !7, i64 16, !13, i64 24, !8, i64 32, !8, i64 33, !8, i64 34, !11, i64 40, !11, i64 48}
!13 = !{!"any pointer", !8, i64 0}


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