; LLVM IR from JessonYue/LeetCodeLearning :: Array/wuchao/other/9-5 dns解析 (DnsParser)

; 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.Header = type { i16, i16, i16, i16, i16, i16 }

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 ptr @parseResponseHeader(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %5 = call noalias ptr @malloc(i64 noundef 12) #7
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 2 %6, i8 0, i64 12, i1 false)
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.Header, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %8, ptr align 1 %9, i64 2, i1 false)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Header, ptr %10, i32 0, i32 0
  %12 = load i16, ptr %11, align 2, !tbaa !9
  %13 = call zeroext i16 @__bswap_16(i16 noundef zeroext %12)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Header, ptr %14, i32 0, i32 0
  store i16 %13, ptr %15, align 2, !tbaa !9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 2
  store ptr %17, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #6
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load i16, ptr %18, align 2, !tbaa !12
  store i16 %19, ptr %4, align 2, !tbaa !12
  %20 = load i16, ptr %4, align 2, !tbaa !12
  %21 = zext i16 %20 to i32
  %22 = ashr i32 %21, 15
  %23 = trunc i32 %22 to i16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Header, ptr %24, i32 0, i32 1
  %26 = load i16, ptr %25, align 2
  %27 = and i16 %23, 1
  %28 = and i16 %26, -2
  %29 = or i16 %28, %27
  store i16 %29, ptr %25, align 2
  %30 = load i16, ptr %4, align 2, !tbaa !12
  %31 = zext i16 %30 to i32
  %32 = shl i32 %31, 1
  %33 = ashr i32 %32, 12
  %34 = trunc i32 %33 to i16
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Header, ptr %35, i32 0, i32 1
  %37 = load i16, ptr %36, align 2
  %38 = and i16 %34, 15
  %39 = shl i16 %38, 1
  %40 = and i16 %37, -31
  %41 = or i16 %40, %39
  store i16 %41, ptr %36, align 2
  %42 = load i16, ptr %4, align 2, !tbaa !12
  %43 = zext i16 %42 to i32
  %44 = shl i32 %43, 5
  %45 = ashr i32 %44, 15
  %46 = trunc i32 %45 to i16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Header, ptr %47, i32 0, i32 1
  %49 = load i16, ptr %48, align 2
  %50 = and i16 %46, 1
  %51 = shl i16 %50, 5
  %52 = and i16 %49, -33
  %53 = or i16 %52, %51
  store i16 %53, ptr %48, align 2
  %54 = load i16, ptr %4, align 2, !tbaa !12
  %55 = zext i16 %54 to i32
  %56 = shl i32 %55, 6
  %57 = ashr i32 %56, 15
  %58 = trunc i32 %57 to i16
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Header, ptr %59, i32 0, i32 1
  %61 = load i16, ptr %60, align 2
  %62 = and i16 %58, 1
  %63 = shl i16 %62, 6
  %64 = and i16 %61, -65
  %65 = or i16 %64, %63
  store i16 %65, ptr %60, align 2
  %66 = load i16, ptr %4, align 2, !tbaa !12
  %67 = zext i16 %66 to i32
  %68 = shl i32 %67, 7
  %69 = ashr i32 %68, 15
  %70 = trunc i32 %69 to i16
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Header, ptr %71, i32 0, i32 1
  %73 = load i16, ptr %72, align 2
  %74 = and i16 %70, 1
  %75 = shl i16 %74, 7
  %76 = and i16 %73, -129
  %77 = or i16 %76, %75
  store i16 %77, ptr %72, align 2
  %78 = load i16, ptr %4, align 2, !tbaa !12
  %79 = zext i16 %78 to i32
  %80 = shl i32 %79, 8
  %81 = ashr i32 %80, 15
  %82 = trunc i32 %81 to i16
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Header, ptr %83, i32 0, i32 1
  %85 = load i16, ptr %84, align 2
  %86 = and i16 %82, 1
  %87 = shl i16 %86, 8
  %88 = and i16 %85, -257
  %89 = or i16 %88, %87
  store i16 %89, ptr %84, align 2
  %90 = load i16, ptr %4, align 2, !tbaa !12
  %91 = zext i16 %90 to i32
  %92 = shl i32 %91, 9
  %93 = ashr i32 %92, 13
  %94 = trunc i32 %93 to i16
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.Header, ptr %95, i32 0, i32 1
  %97 = load i16, ptr %96, align 2
  %98 = and i16 %94, 7
  %99 = shl i16 %98, 9
  %100 = and i16 %97, -3585
  %101 = or i16 %100, %99
  store i16 %101, ptr %96, align 2
  %102 = load i16, ptr %4, align 2, !tbaa !12
  %103 = zext i16 %102 to i32
  %104 = shl i32 %103, 12
  %105 = ashr i32 %104, 12
  %106 = trunc i32 %105 to i16
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.Header, ptr %107, i32 0, i32 1
  %109 = load i16, ptr %108, align 2
  %110 = and i16 %106, 15
  %111 = shl i16 %110, 12
  %112 = and i16 %109, 4095
  %113 = or i16 %112, %111
  store i16 %113, ptr %108, align 2
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds i8, ptr %114, i64 2
  store ptr %115, ptr %2, align 8, !tbaa !5
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.Header, ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %117, ptr align 1 %118, i64 2, i1 false)
  %119 = load ptr, ptr %2, align 8, !tbaa !5
  %120 = getelementptr inbounds i8, ptr %119, i64 2
  store ptr %120, ptr %2, align 8, !tbaa !5
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.Header, ptr %121, i32 0, i32 3
  %123 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %122, ptr align 1 %123, i64 2, i1 false)
  %124 = load ptr, ptr %2, align 8, !tbaa !5
  %125 = getelementptr inbounds i8, ptr %124, i64 2
  store ptr %125, ptr %2, align 8, !tbaa !5
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.Header, ptr %126, i32 0, i32 4
  %128 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %127, ptr align 1 %128, i64 2, i1 false)
  %129 = load ptr, ptr %2, align 8, !tbaa !5
  %130 = getelementptr inbounds i8, ptr %129, i64 2
  store ptr %130, ptr %2, align 8, !tbaa !5
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.Header, ptr %131, i32 0, i32 5
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %132, ptr align 1 %133, i64 2, i1 false)
  %134 = load ptr, ptr %3, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.Header, ptr %134, i32 0, i32 2
  %136 = load i16, ptr %135, align 2, !tbaa !13
  %137 = call zeroext i16 @__bswap_16(i16 noundef zeroext %136)
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.Header, ptr %138, i32 0, i32 2
  store i16 %137, ptr %139, align 2, !tbaa !13
  %140 = load ptr, ptr %3, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.Header, ptr %140, i32 0, i32 3
  %142 = load i16, ptr %141, align 2, !tbaa !14
  %143 = call zeroext i16 @__bswap_16(i16 noundef zeroext %142)
  %144 = load ptr, ptr %3, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.Header, ptr %144, i32 0, i32 3
  store i16 %143, ptr %145, align 2, !tbaa !14
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.Header, ptr %146, i32 0, i32 4
  %148 = load i16, ptr %147, align 2, !tbaa !15
  %149 = call zeroext i16 @__bswap_16(i16 noundef zeroext %148)
  %150 = load ptr, ptr %3, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.Header, ptr %150, i32 0, i32 4
  store i16 %149, ptr %151, align 2, !tbaa !15
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.Header, ptr %152, i32 0, i32 5
  %154 = load i16, ptr %153, align 2, !tbaa !16
  %155 = call zeroext i16 @__bswap_16(i16 noundef zeroext %154)
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.Header, ptr %156, i32 0, i32 5
  store i16 %155, ptr %157, align 2, !tbaa !16
  %158 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret ptr %158
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind allocsize(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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !11, i64 0}
!10 = !{!"Header", !11, i64 0, !11, i64 2, !11, i64 2, !11, i64 2, !11, i64 2, !11, i64 2, !11, i64 3, !11, i64 3, !11, i64 3, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10}
!11 = !{!"short", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 6}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !11, i64 10}


; 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: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @parseResponseHeader(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %calloc = tail call dereferenceable_or_null(12) ptr @calloc(i64 1, i64 12)
  %2 = load i16, ptr %0, align 1
  %3 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %2)
  store i16 %3, ptr %calloc, align 2, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 2
  %5 = load i16, ptr %4, align 2, !tbaa !10
  %6 = lshr i16 %5, 15
  %7 = getelementptr inbounds i8, ptr %calloc, i64 2
  %8 = lshr i16 %5, 10
  %9 = and i16 %8, 30
  %10 = lshr i16 %5, 5
  %11 = and i16 %10, 32
  %12 = lshr i16 %5, 3
  %13 = and i16 %12, 64
  %14 = lshr i16 %5, 1
  %15 = and i16 %14, 128
  %16 = shl i16 %5, 1
  %17 = and i16 %16, 256
  %18 = shl i16 %5, 5
  %19 = and i16 %18, 3584
  %20 = shl i16 %5, 12
  %21 = or disjoint i16 %20, %6
  %22 = or disjoint i16 %21, %9
  %23 = or disjoint i16 %22, %11
  %.masked.masked = or disjoint i16 %23, %13
  %.masked44 = or disjoint i16 %.masked.masked, %15
  %24 = or i16 %.masked44, %17
  %25 = or i16 %24, %19
  store i16 %25, ptr %7, align 2
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  %27 = getelementptr inbounds i8, ptr %calloc, i64 4
  %28 = load i16, ptr %26, align 1
  %29 = getelementptr inbounds i8, ptr %0, i64 6
  %30 = getelementptr inbounds i8, ptr %calloc, i64 6
  %31 = load i16, ptr %29, align 1
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = getelementptr inbounds i8, ptr %calloc, i64 8
  %34 = load i16, ptr %32, align 1
  %35 = getelementptr inbounds i8, ptr %0, i64 10
  %36 = getelementptr inbounds i8, ptr %calloc, i64 10
  %37 = load i16, ptr %35, align 1
  %38 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %28)
  store i16 %38, ptr %27, align 2, !tbaa !11
  %39 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %31)
  store i16 %39, ptr %30, align 2, !tbaa !12
  %40 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %34)
  store i16 %40, ptr %33, align 2, !tbaa !13
  %41 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %37)
  store i16 %41, ptr %36, align 2, !tbaa !14
  ret ptr %calloc
}

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { inlinehint 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 = { 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }

!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 0}
!6 = !{!"Header", !7, i64 0, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 3, !7, i64 3, !7, i64 3, !7, i64 4, !7, i64 6, !7, i64 8, !7, i64 10}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 6}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 10}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass