; LLVM IR from NVIDIA/DALI :: dali/operators/decoder/jpeg (jpeg_handle)

; 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.jpeg_compress_struct = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x i32], [4 x ptr], [4 x ptr], [16 x i8], [16 x i8], [16 x i8], i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i8, i8, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.jpeg_memory_mgr = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64 }
%"struct.dali::jpeg::MemDestMgr" = type { %struct.jpeg_destination_mgr, ptr, i32, i32, ptr }
%struct.jpeg_destination_mgr = type { ptr, i64, ptr, ptr, ptr }

; 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 @_ZN4dali4jpeg18MemInitDestinationEP20jpeg_compress_struct(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4dali4jpeg20MemEmptyOutputBufferEP20jpeg_compress_struct(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali4jpeg18MemTermDestinationEP20jpeg_compress_struct(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali4jpeg7SetDestEP20jpeg_compress_structPviPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %10, i32 0, i32 6
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %24

14:                                               ; preds = %4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds %struct.jpeg_memory_mgr, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call noundef ptr %19(ptr noundef %20, i32 noundef 0, i64 noundef 64)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %22, i32 0, i32 6
  store ptr %21, ptr %23, align 8, !tbaa !11
  br label %24

24:                                               ; preds = %14, %4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %25, i32 0, i32 6
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  store ptr %27, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %29, i32 0, i32 2
  store i32 %28, ptr %30, align 8, !tbaa !21
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %32, i32 0, i32 1
  store ptr %31, ptr %33, align 8, !tbaa !24
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %35, i32 0, i32 4
  store ptr %34, ptr %36, align 8, !tbaa !25
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.jpeg_destination_mgr, ptr %38, i32 0, i32 2
  store ptr @_ZN4dali4jpeg18MemInitDestinationEP20jpeg_compress_struct, ptr %39, align 8, !tbaa !26
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.jpeg_destination_mgr, ptr %41, i32 0, i32 3
  store ptr @_ZN4dali4jpeg20MemEmptyOutputBufferEP20jpeg_compress_struct, ptr %42, align 8, !tbaa !27
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.dali::jpeg::MemDestMgr", ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.jpeg_destination_mgr, ptr %44, i32 0, i32 4
  store ptr @_ZN4dali4jpeg18MemTermDestinationEP20jpeg_compress_struct, ptr %45, align 8, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"_ZTS20jpeg_compress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !13, i64 60, !14, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !13, i64 96, !6, i64 104, !7, i64 112, !7, i64 144, !7, i64 160, !7, i64 192, !7, i64 224, !7, i64 240, !7, i64 256, !10, i64 272, !6, i64 280, !10, i64 288, !10, i64 292, !10, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !15, i64 312, !10, i64 316, !10, i64 320, !10, i64 324, !7, i64 328, !7, i64 329, !7, i64 330, !16, i64 332, !16, i64 334, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !7, i64 376, !10, i64 408, !10, i64 412, !10, i64 416, !7, i64 420, !10, i64 460, !10, i64 464, !10, i64 468, !10, i64 472, !10, i64 476, !6, i64 480, !10, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !10, i64 576}
!13 = !{!"_ZTS13J_COLOR_SPACE", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTS12J_DCT_METHOD", !7, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!12, !6, i64 8}
!18 = !{!19, !6, i64 0}
!19 = !{!"_ZTS15jpeg_memory_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !20, i64 88, !20, i64 96}
!20 = !{!"long", !7, i64 0}
!21 = !{!22, !10, i64 48}
!22 = !{!"_ZTSN4dali4jpeg10MemDestMgrE", !23, i64 0, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56}
!23 = !{!"_ZTS20jpeg_destination_mgr", !6, i64 0, !20, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!24 = !{!22, !6, i64 40}
!25 = !{!22, !6, i64 56}
!26 = !{!22, !6, i64 16}
!27 = !{!22, !6, i64 24}
!28 = !{!22, !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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4dali4jpeg18MemInitDestinationEP20jpeg_compress_struct(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4dali4jpeg20MemEmptyOutputBufferEP20jpeg_compress_struct(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali4jpeg18MemTermDestinationEP20jpeg_compress_struct(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali4jpeg7SetDestEP20jpeg_compress_structPviPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %13

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = tail call noundef ptr %11(ptr noundef nonnull %0, i32 noundef 0, i64 noundef 64)
  store ptr %12, ptr %5, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %8, %4
  %14 = phi ptr [ %12, %8 ], [ %6, %4 ]
  %15 = getelementptr inbounds i8, ptr %14, i64 48
  store i32 %2, ptr %15, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %14, i64 40
  store ptr %1, ptr %16, align 8, !tbaa !22
  %17 = getelementptr inbounds i8, ptr %14, i64 56
  store ptr %3, ptr %17, align 8, !tbaa !23
  %18 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr @_ZN4dali4jpeg18MemInitDestinationEP20jpeg_compress_struct, ptr %18, align 8, !tbaa !24
  %19 = getelementptr inbounds i8, ptr %14, i64 24
  store ptr @_ZN4dali4jpeg20MemEmptyOutputBufferEP20jpeg_compress_struct, ptr %19, align 8, !tbaa !25
  %20 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr @_ZN4dali4jpeg18MemTermDestinationEP20jpeg_compress_struct, ptr %20, align 8, !tbaa !26
  ret void
}

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 = { mustprogress 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, !7, i64 40}
!6 = !{!"_ZTS20jpeg_compress_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !11, i64 60, !12, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !11, i64 96, !7, i64 104, !8, i64 112, !8, i64 144, !8, i64 160, !8, i64 192, !8, i64 224, !8, i64 240, !8, i64 256, !10, i64 272, !7, i64 280, !10, i64 288, !10, i64 292, !10, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !13, i64 312, !10, i64 316, !10, i64 320, !10, i64 324, !8, i64 328, !8, i64 329, !8, i64 330, !14, i64 332, !14, i64 334, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !8, i64 376, !10, i64 408, !10, i64 412, !10, i64 416, !8, i64 420, !10, i64 460, !10, i64 464, !10, i64 468, !10, i64 472, !10, i64 476, !7, i64 480, !10, i64 488, !7, i64 496, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !7, i64 536, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !10, i64 576}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS13J_COLOR_SPACE", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!"_ZTS12J_DCT_METHOD", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!17, !7, i64 0}
!17 = !{!"_ZTS15jpeg_memory_mgr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !18, i64 88, !18, i64 96}
!18 = !{!"long", !8, i64 0}
!19 = !{!20, !10, i64 48}
!20 = !{!"_ZTSN4dali4jpeg10MemDestMgrE", !21, i64 0, !7, i64 40, !10, i64 48, !10, i64 52, !7, i64 56}
!21 = !{!"_ZTS20jpeg_destination_mgr", !7, i64 0, !18, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!22 = !{!20, !7, i64 40}
!23 = !{!20, !7, i64 56}
!24 = !{!20, !7, i64 16}
!25 = !{!20, !7, i64 24}
!26 = !{!20, !7, i64 32}


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