; LLVM IR from kala13x/libxutils :: src/net (http)

; 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 }

; 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 i32 @XHTTP_Init(ptr noundef %0, i32 noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !11
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.xhttp_, ptr %8, i32 0, i32 9
  store i64 0, ptr %9, align 8, !tbaa !13
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.xhttp_, ptr %10, i32 0, i32 10
  store i64 0, ptr %11, align 8, !tbaa !18
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.xhttp_, ptr %12, i32 0, i32 7
  store i16 0, ptr %13, align 8, !tbaa !19
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.xhttp_, ptr %14, i32 0, i32 8
  store i16 0, ptr %15, align 2, !tbaa !20
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.xhttp_, ptr %16, i32 0, i32 16
  store i8 0, ptr %17, align 2, !tbaa !21
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.xhttp_, ptr %18, i32 0, i32 15
  store i8 0, ptr %19, align 1, !tbaa !22
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.xhttp_, ptr %20, i32 0, i32 19
  %22 = getelementptr inbounds [2048 x i8], ptr %21, i64 0, i64 0
  store i8 0, ptr %22, align 1, !tbaa !23
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.xhttp_, ptr %23, i32 0, i32 18
  %25 = getelementptr inbounds [128 x i8], ptr %24, i64 0, i64 0
  store i8 0, ptr %25, align 1, !tbaa !23
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.xhttp_, ptr %26, i32 0, i32 17
  %28 = getelementptr inbounds [256 x i8], ptr %27, i64 0, i64 0
  store i8 0, ptr %28, align 1, !tbaa !23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.xhttp_, ptr %29, i32 0, i32 0
  store ptr null, ptr %30, align 8, !tbaa !24
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.xhttp_, ptr %31, i32 0, i32 2
  store ptr null, ptr %32, align 8, !tbaa !25
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.xhttp_, ptr %33, i32 0, i32 14
  store i8 0, ptr %34, align 8, !tbaa !26
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.xhttp_, ptr %35, i32 0, i32 1
  store i16 0, ptr %36, align 8, !tbaa !27
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.xhttp_, ptr %37, i32 0, i32 13
  store i64 0, ptr %38, align 8, !tbaa !28
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.xhttp_, ptr %39, i32 0, i32 11
  store i64 5120000, ptr %40, align 8, !tbaa !29
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.xhttp_, ptr %41, i32 0, i32 12
  store i64 32768, ptr %42, align 8, !tbaa !30
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.xhttp_, ptr %44, i32 0, i32 3
  store i32 %43, ptr %45, align 8, !tbaa !31
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.xhttp_, ptr %46, i32 0, i32 5
  store i32 0, ptr %47, align 8, !tbaa !32
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.xhttp_, ptr %48, i32 0, i32 6
  %50 = call i32 @XMap_Init(ptr noundef %49, ptr noundef null, i64 noundef 0)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.xhttp_, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds %struct.XMap, ptr %52, i32 0, i32 0
  store ptr @XHTTP_HeaderClearCb, ptr %53, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.xhttp_, ptr %54, i32 0, i32 4
  store ptr %55, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i64, ptr %6, align 8, !tbaa !11
  %58 = call i32 @XByteBuffer_Init(ptr noundef %56, i64 noundef %57, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 %58
}

declare i32 @XMap_Init(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @XHTTP_HeaderClearCb(ptr noundef) #1

declare i32 @XByteBuffer_Init(ptr noundef, i64 noundef, 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 = { "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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 128}
!14 = !{!"xhttp_", !6, i64 0, !15, i64 8, !6, i64 16, !10, i64 24, !16, i64 32, !10, i64 64, !17, i64 72, !15, i64 120, !15, i64 122, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !7, i64 168, !7, i64 169, !7, i64 170, !7, i64 171, !7, i64 427, !7, i64 555}
!15 = !{!"short", !7, i64 0}
!16 = !{!"XByteBuffer", !6, i64 0, !12, i64 8, !12, i64 16, !15, i64 24, !15, i64 26, !10, i64 28}
!17 = !{!"XMap", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 32, !10, i64 40}
!18 = !{!14, !12, i64 136}
!19 = !{!14, !15, i64 120}
!20 = !{!14, !15, i64 122}
!21 = !{!14, !7, i64 170}
!22 = !{!14, !7, i64 169}
!23 = !{!7, !7, i64 0}
!24 = !{!14, !6, i64 0}
!25 = !{!14, !6, i64 16}
!26 = !{!14, !7, i64 168}
!27 = !{!14, !15, i64 8}
!28 = !{!14, !12, i64 160}
!29 = !{!14, !12, i64 144}
!30 = !{!14, !12, i64 152}
!31 = !{!14, !10, i64 24}
!32 = !{!14, !10, i64 64}
!33 = !{!14, !6, i64 72}


; 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: nounwind uwtable
define dso_local i32 @XHTTP_Init(ptr noundef %0, i32 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  store i16 0, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 122
  store i16 0, ptr %6, align 2, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 555
  store i8 0, ptr %7, align 1, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 427
  store i8 0, ptr %8, align 1, !tbaa !16
  store ptr null, ptr %0, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  store i16 0, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 160
  %12 = getelementptr inbounds i8, ptr %0, i64 144
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %11, i8 0, i64 12, i1 false)
  store i64 5120000, ptr %12, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 152
  store i64 32768, ptr %13, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %1, ptr %14, align 8, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 0, ptr %15, align 8, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  %17 = tail call i32 @XMap_Init(ptr noundef nonnull %16, ptr noundef null, i64 noundef 0) #3
  store ptr @XHTTP_HeaderClearCb, ptr %16, align 8, !tbaa !24
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = tail call i32 @XByteBuffer_Init(ptr noundef nonnull %18, i64 noundef %2, i32 noundef 0) #3
  ret i32 %19
}

declare i32 @XMap_Init(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @XHTTP_HeaderClearCb(ptr noundef) #0

declare i32 @XByteBuffer_Init(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 120}
!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, !10, i64 122}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 16}
!19 = !{!6, !10, i64 8}
!20 = !{!6, !13, i64 144}
!21 = !{!6, !13, i64 152}
!22 = !{!6, !11, i64 24}
!23 = !{!6, !11, i64 64}
!24 = !{!6, !7, i64 72}


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