; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (lodepng)

; 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.LodePNGInfo = type { i32, i32, i32, %struct.LodePNGColorMode, i32, i32, i32, i32, i64, ptr, ptr, i64, ptr, ptr, ptr, ptr, i32, %struct.LodePNGTime, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, [3 x ptr], [3 x i64] }
%struct.LodePNGColorMode = type { i32, i32, ptr, i64, i32, i32, i32, i32 }
%struct.LodePNGTime = type { i32, i32, i32, i32, i32, 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: mustprogress nounwind uwtable
declare hidden void @_ZL12lodepng_freePv(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL12alloc_stringPKc(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z17lodepng_add_itextP11LodePNGInfoPKcS2_S2_S2_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.LodePNGInfo, ptr %17, i32 0, i32 12
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.LodePNGInfo, ptr %20, i32 0, i32 11
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = add i64 %22, 1
  %24 = mul i64 8, %23
  %25 = call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %19, i64 noundef %24)
  store ptr %25, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.LodePNGInfo, ptr %26, i32 0, i32 13
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.LodePNGInfo, ptr %29, i32 0, i32 11
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = add i64 %31, 1
  %33 = mul i64 8, %32
  %34 = call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %28, i64 noundef %33)
  store ptr %34, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LodePNGInfo, ptr %35, i32 0, i32 14
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.LodePNGInfo, ptr %38, i32 0, i32 11
  %40 = load i64, ptr %39, align 8, !tbaa !16
  %41 = add i64 %40, 1
  %42 = mul i64 8, %41
  %43 = call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %37, i64 noundef %42)
  store ptr %43, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.LodePNGInfo, ptr %44, i32 0, i32 15
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.LodePNGInfo, ptr %47, i32 0, i32 11
  %49 = load i64, ptr %48, align 8, !tbaa !16
  %50 = add i64 %49, 1
  %51 = mul i64 8, %50
  %52 = call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %46, i64 noundef %51)
  store ptr %52, ptr %15, align 8, !tbaa !5
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %64

55:                                               ; preds = %5
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %69, label %64

64:                                               ; preds = %61, %58, %55, %5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %65)
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %66)
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %67)
  %68 = load ptr, ptr %15, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %68)
  store i32 83, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %126

69:                                               ; preds = %61
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.LodePNGInfo, ptr %70, i32 0, i32 11
  %72 = load i64, ptr %71, align 8, !tbaa !16
  %73 = add i64 %72, 1
  store i64 %73, ptr %71, align 8, !tbaa !16
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.LodePNGInfo, ptr %75, i32 0, i32 12
  store ptr %74, ptr %76, align 8, !tbaa !9
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.LodePNGInfo, ptr %78, i32 0, i32 13
  store ptr %77, ptr %79, align 8, !tbaa !17
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.LodePNGInfo, ptr %81, i32 0, i32 14
  store ptr %80, ptr %82, align 8, !tbaa !18
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.LodePNGInfo, ptr %84, i32 0, i32 15
  store ptr %83, ptr %85, align 8, !tbaa !19
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %86)
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.LodePNGInfo, ptr %88, i32 0, i32 12
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.LodePNGInfo, ptr %91, i32 0, i32 11
  %93 = load i64, ptr %92, align 8, !tbaa !16
  %94 = sub i64 %93, 1
  %95 = getelementptr inbounds ptr, ptr %90, i64 %94
  store ptr %87, ptr %95, align 8, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %96)
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.LodePNGInfo, ptr %98, i32 0, i32 13
  %100 = load ptr, ptr %99, align 8, !tbaa !17
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.LodePNGInfo, ptr %101, i32 0, i32 11
  %103 = load i64, ptr %102, align 8, !tbaa !16
  %104 = sub i64 %103, 1
  %105 = getelementptr inbounds ptr, ptr %100, i64 %104
  store ptr %97, ptr %105, align 8, !tbaa !5
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %106)
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.LodePNGInfo, ptr %108, i32 0, i32 14
  %110 = load ptr, ptr %109, align 8, !tbaa !18
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.LodePNGInfo, ptr %111, i32 0, i32 11
  %113 = load i64, ptr %112, align 8, !tbaa !16
  %114 = sub i64 %113, 1
  %115 = getelementptr inbounds ptr, ptr %110, i64 %114
  store ptr %107, ptr %115, align 8, !tbaa !5
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %116)
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.LodePNGInfo, ptr %118, i32 0, i32 15
  %120 = load ptr, ptr %119, align 8, !tbaa !19
  %121 = load ptr, ptr %7, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.LodePNGInfo, ptr %121, i32 0, i32 11
  %123 = load i64, ptr %122, align 8, !tbaa !16
  %124 = sub i64 %123, 1
  %125 = getelementptr inbounds ptr, ptr %120, i64 %124
  store ptr %117, ptr %125, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %126

126:                                              ; preds = %69, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %127 = load i32, ptr %6, align 4
  ret i32 %127
}

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, !6, i64 104}
!10 = !{!"_ZTS11LodePNGInfo", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !14, i64 72, !6, i64 80, !6, i64 88, !14, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !11, i64 136, !15, i64 140, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !11, i64 232, !6, i64 240, !6, i64 248, !11, i64 256, !7, i64 264, !7, i64 288}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS16LodePNGColorMode", !13, i64 0, !11, i64 4, !6, i64 8, !14, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!13 = !{!"_ZTS16LodePNGColorType", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS11LodePNGTime", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!16 = !{!10, !14, i64 96}
!17 = !{!10, !6, i64 112}
!18 = !{!10, !6, i64 120}
!19 = !{!10, !6, i64 128}


; 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 hidden void @_ZL12lodepng_freePv(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL12alloc_stringPKc(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 84) i32 @_Z17lodepng_add_itextP11LodePNGInfoPKcS2_S2_S2_(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = shl i64 %9, 3
  %11 = add i64 %10, 8
  %12 = tail call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %7, i64 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = load i64, ptr %8, align 8, !tbaa !15
  %16 = shl i64 %15, 3
  %17 = add i64 %16, 8
  %18 = tail call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %14, i64 noundef %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 120
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = load i64, ptr %8, align 8, !tbaa !15
  %22 = shl i64 %21, 3
  %23 = add i64 %22, 8
  %24 = tail call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %20, i64 noundef %23)
  %25 = getelementptr inbounds i8, ptr %0, i64 128
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load i64, ptr %8, align 8, !tbaa !15
  %28 = shl i64 %27, 3
  %29 = add i64 %28, 8
  %30 = tail call noundef ptr @_ZL15lodepng_reallocPvm(ptr noundef %26, i64 noundef %29)
  %31 = insertelement <4 x ptr> poison, ptr %12, i64 0
  %32 = insertelement <4 x ptr> %31, ptr %18, i64 1
  %33 = insertelement <4 x ptr> %32, ptr %24, i64 2
  %34 = insertelement <4 x ptr> %33, ptr %30, i64 3
  %35 = icmp eq <4 x ptr> %34, zeroinitializer
  %36 = bitcast <4 x i1> %35 to i4
  %37 = icmp eq i4 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %5
  tail call void @_ZL12lodepng_freePv(ptr noundef %12)
  tail call void @_ZL12lodepng_freePv(ptr noundef %18)
  tail call void @_ZL12lodepng_freePv(ptr noundef %24)
  tail call void @_ZL12lodepng_freePv(ptr noundef %30)
  br label %62

39:                                               ; preds = %5
  %40 = load i64, ptr %8, align 8, !tbaa !15
  %41 = add i64 %40, 1
  store i64 %41, ptr %8, align 8, !tbaa !15
  store ptr %12, ptr %6, align 8, !tbaa !5
  store ptr %18, ptr %13, align 8, !tbaa !16
  store ptr %24, ptr %19, align 8, !tbaa !17
  store ptr %30, ptr %25, align 8, !tbaa !18
  %42 = tail call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %1)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i64, ptr %8, align 8, !tbaa !15
  %45 = getelementptr ptr, ptr %43, i64 %44
  %46 = getelementptr i8, ptr %45, i64 -8
  store ptr %42, ptr %46, align 8, !tbaa !19
  %47 = tail call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %2)
  %48 = load ptr, ptr %13, align 8, !tbaa !16
  %49 = load i64, ptr %8, align 8, !tbaa !15
  %50 = getelementptr ptr, ptr %48, i64 %49
  %51 = getelementptr i8, ptr %50, i64 -8
  store ptr %47, ptr %51, align 8, !tbaa !19
  %52 = tail call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %3)
  %53 = load ptr, ptr %19, align 8, !tbaa !17
  %54 = load i64, ptr %8, align 8, !tbaa !15
  %55 = getelementptr ptr, ptr %53, i64 %54
  %56 = getelementptr i8, ptr %55, i64 -8
  store ptr %52, ptr %56, align 8, !tbaa !19
  %57 = tail call noundef ptr @_ZL12alloc_stringPKc(ptr noundef %4)
  %58 = load ptr, ptr %25, align 8, !tbaa !18
  %59 = load i64, ptr %8, align 8, !tbaa !15
  %60 = getelementptr ptr, ptr %58, i64 %59
  %61 = getelementptr i8, ptr %60, i64 -8
  store ptr %57, ptr %61, align 8, !tbaa !19
  br label %62

62:                                               ; preds = %39, %38
  %.0 = phi i32 [ 0, %39 ], [ 83, %38 ]
  ret i32 %.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" }

!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, !12, i64 104}
!6 = !{!"_ZTS11LodePNGInfo", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !13, i64 72, !12, i64 80, !12, i64 88, !13, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !7, i64 136, !14, i64 140, !7, i64 164, !7, i64 168, !7, i64 172, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !7, i64 204, !7, i64 208, !7, i64 212, !7, i64 216, !7, i64 220, !7, i64 224, !7, i64 228, !7, i64 232, !12, i64 240, !12, i64 248, !7, i64 256, !8, i64 264, !8, i64 288}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS16LodePNGColorMode", !11, i64 0, !7, i64 4, !12, i64 8, !13, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!11 = !{!"_ZTS16LodePNGColorType", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTS11LodePNGTime", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!15 = !{!6, !13, i64 96}
!16 = !{!6, !12, i64 112}
!17 = !{!6, !12, i64 120}
!18 = !{!6, !12, i64 128}
!19 = !{!12, !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass