; 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.31 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [2 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 void @XLog_Display(i32 noundef, i8 noundef zeroext, ptr noundef, ...) #1

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

16:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %37

17:                                               ; preds = %1
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.xhttp_, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 8, !tbaa !22
  %21 = call ptr @XHTTP_GetMethodStr(i32 noundef %20)
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.xhttp_, ptr %22, i32 0, i32 4
  %24 = getelementptr inbounds %struct.XByteBuffer, ptr %23, i32 0, i32 2
  %25 = load i64, ptr %24, align 8, !tbaa !23
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 16, i8 noundef zeroext 1, ptr noundef @.str.33, ptr noundef %21, i64 noundef %25)
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.xhttp_, ptr %26, i32 0, i32 4
  %28 = getelementptr inbounds %struct.XByteBuffer, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !24
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.31, ptr noundef %29)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = call i64 @XHTTP_GetBodySize(ptr noundef %31)
  %33 = icmp ne i64 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %17
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.34)
  br label %36

36:                                               ; preds = %34, %17
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %37

37:                                               ; preds = %36, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %38 = load i32, ptr %2, align 4
  ret i32 %38
}

declare i32 @XTime_Get(ptr noundef) #1

declare ptr @XHTTP_GetMethodStr(i32 noundef) #1

declare i64 @XHTTP_GetBodySize(ptr noundef) #1

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, !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 = !{!17, !7, i64 867}
!17 = !{!"xhttp_args_", !12, i64 0, !18, i64 8, !6, i64 848, !21, 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}
!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 = !{!"XTime", !11, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7}
!22 = !{!10, !12, i64 24}
!23 = !{!10, !14, i64 48}
!24 = !{!10, !6, i64 32}


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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare void @XLog_Display(i32 noundef, i8 noundef zeroext, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @XHTTPApp_DisplayRequest(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 856
  %5 = tail call i32 @XTime_Get(ptr noundef nonnull %4) #3
  %6 = getelementptr inbounds i8, ptr %3, i64 867
  %7 = load i8, ptr %6, align 1, !tbaa !15
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %20, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i32, ptr %9, align 8, !tbaa !21
  %11 = tail call ptr @XHTTP_GetMethodStr(i32 noundef %10) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = load i64, ptr %13, align 8, !tbaa !22
  tail call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 16, i8 noundef zeroext 1, ptr noundef nonnull @.str.33, ptr noundef %11, i64 noundef %14) #3
  %15 = load ptr, ptr %12, align 8, !tbaa !23
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31, ptr noundef %15)
  %17 = tail call i64 @XHTTP_GetBodySize(ptr noundef nonnull %0) #3
  %.not7 = icmp eq i64 %17, 0
  br i1 %.not7, label %20, label %18

18:                                               ; preds = %8
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.34)
  br label %20

20:                                               ; preds = %8, %18, %1
  ret i32 1
}

declare i32 @XTime_Get(ptr noundef) local_unnamed_addr #1

declare ptr @XHTTP_GetMethodStr(i32 noundef) local_unnamed_addr #1

declare i64 @XHTTP_GetBodySize(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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, !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 = !{!16, !8, i64 867}
!16 = !{!"xhttp_args_", !11, i64 0, !17, i64 8, !7, i64 848, !20, 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}
!17 = !{!"xcli_bar_", !18, 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, !19, 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}
!18 = !{!"xcli_size_", !13, i64 0, !13, i64 8}
!19 = !{!"double", !8, i64 0}
!20 = !{!"XTime", !10, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7}
!21 = !{!6, !11, i64 24}
!22 = !{!6, !13, i64 48}
!23 = !{!6, !7, i64 32}


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