; 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_bar_ = type { %struct.xcli_size_, i64, i64, i32, i32, i8, i8, i8, i8, double, i32, i8, i8, i8, i8, i8, i8, [256 x i8], [256 x i8], [256 x i8] }
%struct.xcli_size_ = type { i64, i64 }

@stdout = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [4 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

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

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

declare i32 @fflush(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @XProgBar_Finish(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @XProgBar_MakeMove(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @XProgBar_GetOutput(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @XProgBar_Update(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca [2048 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.xcli_bar_, ptr %4, i32 0, i32 9
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = fcmp olt double %6, 0.000000e+00
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @XProgBar_MakeMove(ptr noundef %9)
  br label %30

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2048, ptr %3) #3
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call i32 @XProgBar_UpdateWindowSize(ptr noundef %11)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds [2048 x i8], ptr %3, i64 0, i64 0
  %15 = call i64 @XProgBar_GetOutput(ptr noundef %13, ptr noundef %14, i64 noundef 2048)
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %10
  %18 = getelementptr inbounds [2048 x i8], ptr %3, i64 0, i64 0
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, ptr noundef %18)
  br label %20

20:                                               ; preds = %17, %10
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.xcli_bar_, ptr %21, i32 0, i32 9
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = fcmp oeq double %23, 1.000000e+02
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  call void @XProgBar_Finish(ptr noundef %26)
  br label %27

27:                                               ; preds = %25, %20
  %28 = load ptr, ptr @stdout, align 8, !tbaa !5
  %29 = call i32 @fflush(ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %3) #3
  br label %30

30:                                               ; preds = %27, %8
  ret void
}

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

!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, !14, i64 48}
!10 = !{!"xcli_bar_", !11, i64 0, !12, i64 16, !12, i64 24, !13, i64 32, !13, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !14, i64 48, !13, i64 56, !7, i64 60, !7, i64 61, !7, i64 62, !7, i64 63, !7, i64 64, !7, i64 65, !7, i64 66, !7, i64 322, !7, i64 578}
!11 = !{!"xcli_size_", !12, i64 0, !12, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, 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"

@stdout = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [4 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @XProgBar_Finish(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @XProgBar_MakeMove(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @XProgBar_GetOutput(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @XProgBar_Update(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca [2048 x i8], align 16
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fcmp olt double %4, 0.000000e+00
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  tail call void @XProgBar_MakeMove(ptr noundef nonnull %0)
  br label %19

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %2) #3
  %8 = tail call i32 @XProgBar_UpdateWindowSize(ptr noundef nonnull %0)
  %9 = call i64 @XProgBar_GetOutput(ptr noundef nonnull %0, ptr noundef nonnull %2, i64 noundef 2048)
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %12, label %10

10:                                               ; preds = %7
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef nonnull %2)
  br label %12

12:                                               ; preds = %10, %7
  %13 = load double, ptr %3, align 8, !tbaa !5
  %14 = fcmp oeq double %13, 1.000000e+02
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  call void @XProgBar_Finish(ptr noundef nonnull %0)
  br label %16

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr @stdout, align 8, !tbaa !13
  %18 = call i32 @fflush(ptr noundef %17)
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %2) #3
  br label %19

19:                                               ; preds = %16, %6
  ret void
}

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

!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, !12, i64 48}
!6 = !{!"xcli_bar_", !7, i64 0, !8, i64 16, !8, i64 24, !11, i64 32, !11, i64 36, !9, i64 40, !9, i64 41, !9, i64 42, !9, i64 43, !12, i64 48, !11, i64 56, !9, i64 60, !9, i64 61, !9, i64 62, !9, i64 63, !9, i64 64, !9, i64 65, !9, i64 66, !9, i64 322, !9, i64 578}
!7 = !{!"xcli_size_", !8, i64 0, !8, i64 8}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !9, i64 0}


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