; LLVM IR from kala13x/libxutils :: tools (xhttp)

; 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.xhttp_ = type { ptr, i16, ptr, i32, %struct.XByteBuffer, i32, %struct.XMap, i16, i16, i64, i64, i64, i64, i64, i8, i8, i8, [256 x i8], [128 x i8], [2048 x i8] }
%struct.XByteBuffer = type { ptr, i64, i64, i16, i16, i32 }
%struct.XMap = type { ptr, ptr, ptr, i64, i64, i32 }
%struct.xhttp_args_ = type { i32, %struct.xcli_bar_, ptr, %struct.XTime, i8, i8, i8, i8, i8, i64, i64, i64, %struct.XByteBuffer, [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8] }
%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 }
%struct.XTime = type { i16, i8, i8, i8, i8, i8, i8 }

@.str.35 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.36 = 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

; 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
define dso_local void @XHTTPApp_UpdateProgress(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [128 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.xhttp_, ptr %6, i32 0, i32 2
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.xhttp_args_, ptr %9, i32 0, i32 1
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr %5) #3
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.xhttp_, ptr %11, i32 0, i32 9
  %13 = load i64, ptr %12, align 8, !tbaa !16
  %14 = icmp ne i64 %13, 0
  br i1 %14, label %18, label %15

15:                                               ; preds = %1
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.xcli_bar_, ptr %16, i32 0, i32 9
  store double -1.000000e+00, ptr %17, align 8, !tbaa !17
  br label %31

18:                                               ; preds = %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.xhttp_, ptr %19, i32 0, i32 9
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = uitofp i64 %21 to double
  %23 = fdiv double 1.000000e+02, %22
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.xhttp_args_, ptr %24, i32 0, i32 11
  %26 = load i64, ptr %25, align 8, !tbaa !21
  %27 = uitofp i64 %26 to double
  %28 = fmul double %23, %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.xcli_bar_, ptr %29, i32 0, i32 9
  store double %28, ptr %30, align 8, !tbaa !17
  br label %31

31:                                               ; preds = %18, %15
  %32 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.xhttp_args_, ptr %33, i32 0, i32 11
  %35 = load i64, ptr %34, align 8, !tbaa !21
  %36 = call i64 @XBytesToUnit(ptr noundef %32, i64 noundef 128, i64 noundef %35, i8 noundef zeroext 0)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.xcli_bar_, ptr %37, i32 0, i32 18
  %39 = getelementptr inbounds [256 x i8], ptr %38, i64 0, i64 0
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.xhttp_args_, ptr %40, i32 0, i32 18
  %42 = getelementptr inbounds [2048 x i8], ptr %41, i64 0, i64 0
  %43 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %39, i64 noundef 256, ptr noundef @.str.35, ptr noundef %42)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.xcli_bar_, ptr %44, i32 0, i32 19
  %46 = getelementptr inbounds [256 x i8], ptr %45, i64 0, i64 0
  %47 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %48 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %46, i64 noundef 256, ptr noundef @.str.36, ptr noundef %47)
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  call void @XProgBar_Update(ptr noundef %49)
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare i64 @XBytesToUnit(ptr noundef, i64 noundef, i64 noundef, i8 noundef zeroext) #2

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #2

declare void @XProgBar_Update(ptr 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 = { "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, !6, i64 16}
!10 = !{!"xhttp_", !6, i64 0, !11, i64 8, !6, i64 16, !12, i64 24, !13, i64 32, !12, i64 64, !15, i64 72, !11, i64 120, !11, i64 122, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !7, i64 168, !7, i64 169, !7, i64 170, !7, i64 171, !7, i64 427, !7, i64 555}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"XByteBuffer", !6, i64 0, !14, i64 8, !14, i64 16, !11, i64 24, !11, i64 26, !12, i64 28}
!14 = !{!"long", !7, i64 0}
!15 = !{!"XMap", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !14, i64 32, !12, i64 40}
!16 = !{!10, !14, i64 128}
!17 = !{!18, !20, i64 48}
!18 = !{!"xcli_bar_", !19, i64 0, !14, i64 16, !14, i64 24, !12, i64 32, !12, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !20, i64 48, !12, 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}
!19 = !{!"xcli_size_", !14, i64 0, !14, i64 8}
!20 = !{!"double", !7, i64 0}
!21 = !{!22, !14, i64 888}
!22 = !{!"xhttp_args_", !12, i64 0, !18, i64 8, !6, i64 848, !23, i64 856, !7, i64 864, !7, i64 865, !7, i64 866, !7, i64 867, !7, i64 868, !14, i64 872, !14, i64 880, !14, i64 888, !13, i64 896, !7, i64 928, !7, i64 2976, !7, i64 5024, !7, i64 7072, !7, i64 9120, !7, i64 11168}
!23 = !{!"XTime", !11, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7}


; 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.35 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.36 = 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @XHTTPApp_UpdateProgress(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca [128 x i8], align 16
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %2) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  %6 = load i64, ptr %5, align 8, !tbaa !15
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %7, label %8

7:                                                ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %4, i64 888
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !16
  br label %15

8:                                                ; preds = %1
  %9 = uitofp i64 %6 to double
  %10 = fdiv double 1.000000e+02, %9
  %11 = getelementptr inbounds i8, ptr %4, i64 888
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = uitofp i64 %12 to double
  %14 = fmul double %10, %13
  br label %15

15:                                               ; preds = %8, %7
  %16 = phi i64 [ %.pre, %7 ], [ %12, %8 ]
  %.sink = phi double [ -1.000000e+00, %7 ], [ %14, %8 ]
  %17 = getelementptr inbounds i8, ptr %4, i64 56
  store double %.sink, ptr %17, align 8
  %18 = getelementptr inbounds i8, ptr %4, i64 8
  %19 = call i64 @XBytesToUnit(ptr noundef nonnull %2, i64 noundef 128, i64 noundef %16, i8 noundef zeroext 0) #3
  %20 = getelementptr inbounds i8, ptr %4, i64 330
  %21 = getelementptr inbounds i8, ptr %4, i64 11168
  %22 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %20, i64 noundef 256, ptr noundef nonnull @.str.35, ptr noundef nonnull %21) #3
  %23 = getelementptr inbounds i8, ptr %4, i64 586
  %24 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %23, i64 noundef 256, ptr noundef nonnull @.str.36, ptr noundef nonnull %2) #3
  call void @XProgBar_Update(ptr noundef nonnull %18) #3
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %2) #3
  ret void
}

declare i64 @XBytesToUnit(ptr noundef, i64 noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #2

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

declare void @XProgBar_Update(ptr 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 = { "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, !7, i64 16}
!6 = !{!"xhttp_", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !12, i64 32, !11, i64 64, !14, i64 72, !10, i64 120, !10, i64 122, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152, !13, i64 160, !8, i64 168, !8, i64 169, !8, i64 170, !8, i64 171, !8, i64 427, !8, i64 555}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"XByteBuffer", !7, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !10, i64 26, !11, i64 28}
!13 = !{!"long", !8, i64 0}
!14 = !{!"XMap", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !13, i64 32, !11, i64 40}
!15 = !{!6, !13, i64 128}
!16 = !{!17, !13, i64 888}
!17 = !{!"xhttp_args_", !11, i64 0, !18, i64 8, !7, i64 848, !21, i64 856, !8, i64 864, !8, i64 865, !8, i64 866, !8, i64 867, !8, i64 868, !13, i64 872, !13, i64 880, !13, i64 888, !12, i64 896, !8, i64 928, !8, i64 2976, !8, i64 5024, !8, i64 7072, !8, i64 9120, !8, i64 11168}
!18 = !{!"xcli_bar_", !19, i64 0, !13, i64 16, !13, i64 24, !11, i64 32, !11, i64 36, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !20, i64 48, !11, i64 56, !8, i64 60, !8, i64 61, !8, i64 62, !8, i64 63, !8, i64 64, !8, i64 65, !8, i64 66, !8, i64 322, !8, i64 578}
!19 = !{!"xcli_size_", !13, i64 0, !13, i64 8}
!20 = !{!"double", !8, i64 0}
!21 = !{!"XTime", !10, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass