; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/Common/IntToString.ll (Z17RawLeGuidToStringPKhPc)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z25ConvertUInt32ToHex8DigitsjPc(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_Z17RawLeGuidToStringPKhPc(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z25ConvertUInt32ToHex8DigitsjPc(i32 noundef %7, ptr noundef %8) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i32 1
  store ptr %12, ptr %4, align 8, !tbaa !5
  store i8 45, ptr %11, align 1, !tbaa !11
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 4
  %15 = load i16, ptr %14, align 2, !tbaa !12
  %16 = zext i16 %15 to i32
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef %16, ptr noundef %17) #2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  store ptr %19, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i32 1
  store ptr %21, ptr %4, align 8, !tbaa !5
  store i8 45, ptr %20, align 1, !tbaa !11
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 6
  %24 = load i16, ptr %23, align 2, !tbaa !12
  %25 = zext i16 %24 to i32
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef %25, ptr noundef %26) #2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i32 1
  store ptr %30, ptr %4, align 8, !tbaa !5
  store i8 45, ptr %29, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %52, %2
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = icmp ult i32 %32, 8
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %55

35:                                               ; preds = %31
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 2
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr %4, align 8, !tbaa !5
  store i8 45, ptr %39, align 1, !tbaa !11
  br label %41

41:                                               ; preds = %38, %35
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = add i32 8, %43
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %42, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = zext i8 %47 to i32
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %48, ptr noundef %49) #2
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 2
  store ptr %51, ptr %4, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %41
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !9
  br label %31, !llvm.loop !14

55:                                               ; preds = %34
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 0, ptr %56, align 1, !tbaa !11
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %57
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nounwind uwtable
declare dso_local void @_Z25ConvertUInt32ToHex8DigitsjPc(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull ptr @_Z17RawLeGuidToStringPKhPc(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  tail call void @_Z25ConvertUInt32ToHex8DigitsjPc(i32 noundef %3, ptr noundef %1) #1
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 45, ptr %4, align 1, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i16, ptr %6, align 2, !tbaa !10
  %8 = zext i16 %7 to i32
  tail call void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef %8, ptr noundef nonnull %5) #1
  %9 = getelementptr inbounds i8, ptr %1, i64 13
  %10 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 45, ptr %9, align 1, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %0, i64 6
  %12 = load i16, ptr %11, align 2, !tbaa !10
  %13 = zext i16 %12 to i32
  tail call void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef %13, ptr noundef nonnull %10) #1
  %14 = getelementptr inbounds i8, ptr %1, i64 18
  %15 = getelementptr inbounds i8, ptr %1, i64 19
  store i8 45, ptr %14, align 1, !tbaa !9
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load i8, ptr %.phi.trans.insert, align 1, !tbaa !9
  %16 = zext i8 %.pre to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %16, ptr noundef nonnull %15) #1
  %17 = getelementptr inbounds i8, ptr %1, i64 21
  %.phi.trans.insert26 = getelementptr inbounds i8, ptr %0, i64 9
  %.pre27 = load i8, ptr %.phi.trans.insert26, align 1, !tbaa !9
  %18 = zext i8 %.pre27 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %18, ptr noundef nonnull %17) #1
  %19 = getelementptr inbounds i8, ptr %1, i64 23
  store i8 45, ptr %19, align 1, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %1, i64 24
  %21 = getelementptr inbounds i8, ptr %0, i64 10
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = zext i8 %22 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %23, ptr noundef nonnull %20) #1
  %24 = getelementptr inbounds i8, ptr %1, i64 26
  %.phi.trans.insert30 = getelementptr inbounds i8, ptr %0, i64 11
  %.pre31 = load i8, ptr %.phi.trans.insert30, align 1, !tbaa !9
  %25 = zext i8 %.pre31 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %25, ptr noundef nonnull %24) #1
  %26 = getelementptr inbounds i8, ptr %1, i64 28
  %.phi.trans.insert33 = getelementptr inbounds i8, ptr %0, i64 12
  %.pre34 = load i8, ptr %.phi.trans.insert33, align 1, !tbaa !9
  %27 = zext i8 %.pre34 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %27, ptr noundef nonnull %26) #1
  %28 = getelementptr inbounds i8, ptr %1, i64 30
  %.phi.trans.insert36 = getelementptr inbounds i8, ptr %0, i64 13
  %.pre37 = load i8, ptr %.phi.trans.insert36, align 1, !tbaa !9
  %29 = zext i8 %.pre37 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %29, ptr noundef nonnull %28) #1
  %30 = getelementptr inbounds i8, ptr %1, i64 32
  %.phi.trans.insert39 = getelementptr inbounds i8, ptr %0, i64 14
  %.pre40 = load i8, ptr %.phi.trans.insert39, align 1, !tbaa !9
  %31 = zext i8 %.pre40 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %31, ptr noundef nonnull %30) #1
  %.phi.trans.insert42 = getelementptr inbounds i8, ptr %0, i64 15
  %.pre43 = load i8, ptr %.phi.trans.insert42, align 1, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %1, i64 34
  %33 = zext i8 %.pre43 to i32
  tail call void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef %33, ptr noundef nonnull %32) #1
  %34 = getelementptr inbounds i8, ptr %1, i64 36
  store i8 0, ptr %34, align 1, !tbaa !9
  ret ptr %34
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL25ConvertUInt16ToHex4DigitsjPc(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL23ConvertByteToHex2DigitsjPc(i32 noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { mustprogress 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass