; 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.LodePNGDecompressSettings = type { i32, ptr, ptr, ptr }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z23lodepng_zlib_decompressPPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 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 i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = 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 i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %19 = load i64, ptr %10, align 8, !tbaa !9
  %20 = icmp ult i64 %19, 2
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  store i32 53, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

22:                                               ; preds = %5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 0
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = zext i8 %25 to i32
  %27 = mul nsw i32 %26, 256
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = load i8, ptr %29, align 1, !tbaa !13
  %31 = zext i8 %30 to i32
  %32 = add nsw i32 %27, %31
  %33 = srem i32 %32, 31
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %22
  store i32 24, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

36:                                               ; preds = %22
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 0
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = zext i8 %39 to i32
  %41 = and i32 %40, 15
  store i32 %41, ptr %13, align 4, !tbaa !11
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 0
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = zext i8 %44 to i32
  %46 = ashr i32 %45, 4
  %47 = and i32 %46, 15
  store i32 %47, ptr %14, align 4, !tbaa !11
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 1
  %50 = load i8, ptr %49, align 1, !tbaa !13
  %51 = zext i8 %50 to i32
  %52 = ashr i32 %51, 5
  %53 = and i32 %52, 1
  store i32 %53, ptr %15, align 4, !tbaa !11
  %54 = load i32, ptr %13, align 4, !tbaa !11
  %55 = icmp ne i32 %54, 8
  br i1 %55, label %59, label %56

56:                                               ; preds = %36
  %57 = load i32, ptr %14, align 4, !tbaa !11
  %58 = icmp ugt i32 %57, 7
  br i1 %58, label %59, label %60

59:                                               ; preds = %56, %36
  store i32 25, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

60:                                               ; preds = %56
  %61 = load i32, ptr %15, align 4, !tbaa !11
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  store i32 26, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

64:                                               ; preds = %60
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 2
  %69 = load i64, ptr %10, align 8, !tbaa !9
  %70 = sub i64 %69, 2
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = call noundef i32 @_ZL7inflatePPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef %65, ptr noundef %66, ptr noundef %68, i64 noundef %70, ptr noundef %71)
  store i32 %72, ptr %12, align 4, !tbaa !11
  %73 = load i32, ptr %12, align 4, !tbaa !11
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %64
  %76 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %76, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

77:                                               ; preds = %64
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.LodePNGDecompressSettings, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !14
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %102, label %82

82:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load i64, ptr %10, align 8, !tbaa !9
  %85 = sub i64 %84, 4
  %86 = getelementptr inbounds i8, ptr %83, i64 %85
  %87 = call noundef i32 @_Z20lodepng_read32bitIntPKh(ptr noundef %86)
  store i32 %87, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load i64, ptr %90, align 8, !tbaa !9
  %92 = trunc i64 %91 to i32
  %93 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %89, i32 noundef %92)
  store i32 %93, ptr %18, align 4, !tbaa !11
  %94 = load i32, ptr %18, align 4, !tbaa !11
  %95 = load i32, ptr %17, align 4, !tbaa !11
  %96 = icmp ne i32 %94, %95
  br i1 %96, label %97, label %98

97:                                               ; preds = %82
  store i32 58, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %99

98:                                               ; preds = %82
  store i32 0, ptr %16, align 4
  br label %99

99:                                               ; preds = %98, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  %100 = load i32, ptr %16, align 4
  switch i32 %100, label %103 [
    i32 0, label %101
  ]

101:                                              ; preds = %99
  br label %102

102:                                              ; preds = %101, %77
  store i32 0, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %103

103:                                              ; preds = %102, %99, %75, %63, %59, %35, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %104 = load i32, ptr %6, align 4
  ret i32 %104
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7inflatePPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7adler32PKhj(ptr noundef, i32 noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 0}
!15 = !{!"_ZTS25LodePNGDecompressSettings", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}


; 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 noundef i32 @_Z20lodepng_read32bitIntPKh(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z23lodepng_zlib_decompressPPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = icmp ult i64 %3, 2
  br i1 %6, label %37, label %7

7:                                                ; preds = %5
  %8 = load i8, ptr %2, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = shl nuw nsw i32 %9, 8
  %11 = getelementptr inbounds i8, ptr %2, i64 1
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = or disjoint i32 %10, %13
  %.lhs.trunc = trunc nuw i32 %14 to i16
  %15 = urem i16 %.lhs.trunc, 31
  %.not = icmp eq i16 %15, 0
  br i1 %.not, label %16, label %37

16:                                               ; preds = %7
  %17 = and i32 %9, 15
  %18 = icmp ne i32 %17, 8
  %19 = icmp slt i8 %8, 0
  %or.cond = or i1 %19, %18
  br i1 %or.cond, label %37, label %20

20:                                               ; preds = %16
  %21 = and i32 %13, 32
  %.not27 = icmp eq i32 %21, 0
  br i1 %.not27, label %22, label %37

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %2, i64 2
  %24 = add i64 %3, -2
  %25 = tail call noundef i32 @_ZL7inflatePPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %23, i64 noundef %24, ptr noundef %4)
  %.not28 = icmp eq i32 %25, 0
  br i1 %.not28, label %26, label %37

26:                                               ; preds = %22
  %27 = load i32, ptr %4, align 8, !tbaa !8
  %.not29 = icmp eq i32 %27, 0
  br i1 %.not29, label %28, label %36

28:                                               ; preds = %26
  %29 = getelementptr i8, ptr %2, i64 %3
  %30 = getelementptr i8, ptr %29, i64 -4
  %31 = tail call noundef i32 @_Z20lodepng_read32bitIntPKh(ptr noundef %30)
  %32 = load ptr, ptr %0, align 8, !tbaa !12
  %33 = load i64, ptr %1, align 8, !tbaa !13
  %34 = trunc i64 %33 to i32
  %35 = tail call noundef i32 @_ZL7adler32PKhj(ptr noundef %32, i32 noundef %34)
  %.not30 = icmp eq i32 %35, %31
  br i1 %.not30, label %36, label %37

36:                                               ; preds = %28, %26
  br label %37

37:                                               ; preds = %22, %20, %16, %7, %5, %28, %36
  %.1 = phi i32 [ 0, %36 ], [ 58, %28 ], [ 53, %5 ], [ 24, %7 ], [ 25, %16 ], [ 26, %20 ], [ %25, %22 ]
  ret i32 %.1
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7inflatePPhPmPKhmPK25LodePNGDecompressSettings(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7adler32PKhj(ptr noundef, i32 noundef) local_unnamed_addr #1

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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTS25LodePNGDecompressSettings", !10, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass