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

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

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

; 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 i64 @buildQuestion(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %50, %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = add i64 %9, %10
  %12 = getelementptr inbounds i8, ptr %8, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %51

16:                                               ; preds = %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i64, ptr %5, align 8, !tbaa !9
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = add i64 %18, %19
  %21 = getelementptr inbounds i8, ptr %17, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp ne i32 %23, 46
  br i1 %24, label %25, label %40

25:                                               ; preds = %16
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = load i64, ptr %6, align 8, !tbaa !9
  %29 = add i64 %27, %28
  %30 = getelementptr inbounds i8, ptr %26, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = add i64 %33, %34
  %36 = add i64 %35, 1
  %37 = getelementptr inbounds i8, ptr %32, i64 %36
  store i8 %31, ptr %37, align 1, !tbaa !11
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = add i64 %38, 1
  store i64 %39, ptr %6, align 8, !tbaa !9
  br label %50

40:                                               ; preds = %16
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = trunc i64 %41 to i8
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %43, i64 %44
  store i8 %42, ptr %45, align 1, !tbaa !11
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = add i64 %46, 1
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = add i64 %48, %47
  store i64 %49, ptr %5, align 8, !tbaa !9
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %40, %25
  br label %7, !llvm.loop !12

51:                                               ; preds = %7
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = trunc i64 %52 to i8
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load i64, ptr %5, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %54, i64 %55
  store i8 %53, ptr %56, align 1, !tbaa !11
  %57 = load i64, ptr %6, align 8, !tbaa !9
  %58 = add i64 %57, 1
  %59 = load i64, ptr %5, align 8, !tbaa !9
  %60 = add i64 %59, %58
  store i64 %60, ptr %5, align 8, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = add i64 %62, 1
  store i64 %63, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds i8, ptr %61, i64 %62
  store i8 0, ptr %64, align 1, !tbaa !11
  %65 = call zeroext i16 @__bswap_16(i16 noundef zeroext 1)
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load i64, ptr %5, align 8, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  store i16 %65, ptr %68, align 2, !tbaa !14
  %69 = load i64, ptr %5, align 8, !tbaa !9
  %70 = add i64 %69, 2
  store i64 %70, ptr %5, align 8, !tbaa !9
  %71 = call zeroext i16 @__bswap_16(i16 noundef zeroext 1)
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load i64, ptr %5, align 8, !tbaa !9
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  store i16 %71, ptr %74, align 2, !tbaa !14
  %75 = load i64, ptr %5, align 8, !tbaa !9
  %76 = add i64 %75, 2
  store i64 %76, ptr %5, align 8, !tbaa !9
  %77 = load i64, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %77
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !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"

; 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 i64 @buildQuestion(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %invariant.gep = getelementptr i8, ptr %1, i64 1
  br label %.outer

.outer:                                           ; preds = %9, %2
  %.031.ph = phi i64 [ %13, %9 ], [ 0, %2 ]
  br label %3

3:                                                ; preds = %.outer, %7
  %.0 = phi i64 [ %8, %7 ], [ 0, %.outer ]
  %4 = add i64 %.0, %.031.ph
  %5 = getelementptr inbounds i8, ptr %0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5
  switch i8 %6, label %7 [
    i8 0, label %14
    i8 46, label %9
  ]

7:                                                ; preds = %3
  %gep = getelementptr i8, ptr %invariant.gep, i64 %4
  store i8 %6, ptr %gep, align 1, !tbaa !5
  %8 = add i64 %.0, 1
  br label %3, !llvm.loop !8

9:                                                ; preds = %3
  %10 = trunc i64 %.0 to i8
  %11 = getelementptr inbounds i8, ptr %1, i64 %.031.ph
  store i8 %10, ptr %11, align 1, !tbaa !5
  %12 = add i64 %.0, 1
  %13 = add i64 %12, %.031.ph
  br label %.outer, !llvm.loop !8

14:                                               ; preds = %3
  %15 = trunc i64 %.0 to i8
  %16 = getelementptr inbounds i8, ptr %1, i64 %.031.ph
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = add i64 %.0, 1
  %18 = add i64 %17, %.031.ph
  %19 = getelementptr inbounds i8, ptr %1, i64 %18
  store i8 0, ptr %19, align 1, !tbaa !5
  %20 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext 1)
  %21 = getelementptr i8, ptr %19, i64 1
  store i16 %20, ptr %21, align 2, !tbaa !10
  %22 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext 1)
  %23 = getelementptr i8, ptr %19, i64 3
  store i16 %22, ptr %23, align 2, !tbaa !10
  %24 = add i64 %18, 5
  ret i64 %24
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass