; LLVM IR from simbody/simbody :: Simbody/Visualizer/simbody-visualizer (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.ucvector = type { ptr, i64, i64 }
%struct.LodeZlib_DecompressSettings = type { i32 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z17LodeFlate_inflateP8ucvectorPKhmm(ptr noundef, ptr noundef, i64 noundef, i64 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 nounwind uwtable
declare dso_local noundef i32 @_Z21LodeZlib_read32bitIntPKh(ptr noundef) #2

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

22:                                               ; preds = %5
  store i32 53, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

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

36:                                               ; preds = %23
  store i32 24, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

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

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

60:                                               ; preds = %57, %37
  store i32 25, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

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

64:                                               ; preds = %61
  store i32 26, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

65:                                               ; preds = %61
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load i64, ptr %68, align 8, !tbaa !9
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef %16, ptr noundef %67, i64 noundef %69)
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load i64, ptr %10, align 8, !tbaa !9
  %72 = call noundef i32 @_Z17LodeFlate_inflateP8ucvectorPKhmm(ptr noundef %16, ptr noundef %70, i64 noundef %71, i64 noundef 2)
  store i32 %72, ptr %12, align 4, !tbaa !11
  %73 = getelementptr inbounds %struct.ucvector, ptr %16, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %74, ptr %75, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ucvector, ptr %16, i32 0, i32 1
  %77 = load i64, ptr %76, align 8, !tbaa !16
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %77, ptr %78, align 8, !tbaa !9
  %79 = load i32, ptr %12, align 4, !tbaa !11
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %65
  %82 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %82, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

83:                                               ; preds = %65
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.LodeZlib_DecompressSettings, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !17
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %108, label %88

88:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i64, ptr %10, align 8, !tbaa !9
  %91 = sub i64 %90, 4
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = call noundef i32 @_Z21LodeZlib_read32bitIntPKh(ptr noundef %92)
  store i32 %93, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %94 = getelementptr inbounds %struct.ucvector, ptr %16, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !14
  %96 = getelementptr inbounds %struct.ucvector, ptr %16, i32 0, i32 1
  %97 = load i64, ptr %96, align 8, !tbaa !16
  %98 = trunc i64 %97 to i32
  %99 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %95, i32 noundef %98)
  store i32 %99, ptr %19, align 4, !tbaa !11
  %100 = load i32, ptr %19, align 4, !tbaa !11
  %101 = load i32, ptr %18, align 4, !tbaa !11
  %102 = icmp ne i32 %100, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %88
  store i32 58, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %105

104:                                              ; preds = %88
  store i32 0, ptr %17, align 4
  br label %105

105:                                              ; preds = %104, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %106 = load i32, ptr %17, align 4
  switch i32 %106, label %109 [
    i32 0, label %107
  ]

107:                                              ; preds = %105
  br label %108

108:                                              ; preds = %107, %83
  store i32 0, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

109:                                              ; preds = %108, %105, %81, %64, %60, %36, %22
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  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
  %110 = load i32, ptr %6, align 4
  ret i32 %110
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef, ptr noundef, i64 noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !6, i64 0}
!15 = !{!"_ZTS8ucvector", !6, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!15, !10, i64 8}
!17 = !{!18, !12, i64 0}
!18 = !{!"_ZTS27LodeZlib_DecompressSettings", !12, 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"

%struct.ucvector = type { ptr, i64, i64 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z17LodeFlate_inflateP8ucvectorPKhmm(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z19LodeZlib_decompressPPhPmPKhmPK27LodeZlib_DecompressSettings(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2, i64 noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = alloca %struct.ucvector, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  %7 = icmp ult i64 %3, 2
  br i1 %7, label %41, label %8

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

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

21:                                               ; preds = %17
  %22 = and i32 %14, 32
  %.not26 = icmp eq i32 %22, 0
  br i1 %.not26, label %23, label %41

23:                                               ; preds = %21
  %24 = load ptr, ptr %0, align 8, !tbaa !8
  %25 = load i64, ptr %1, align 8, !tbaa !10
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef nonnull %6, ptr noundef %24, i64 noundef %25)
  %26 = call noundef i32 @_Z17LodeFlate_inflateP8ucvectorPKhmm(ptr noundef nonnull %6, ptr noundef nonnull %2, i64 noundef %3, i64 noundef 2)
  %27 = load ptr, ptr %6, align 8, !tbaa !12
  store ptr %27, ptr %0, align 8, !tbaa !8
  %28 = getelementptr inbounds i8, ptr %6, i64 8
  %29 = load i64, ptr %28, align 8, !tbaa !14
  store i64 %29, ptr %1, align 8, !tbaa !10
  %.not27 = icmp eq i32 %26, 0
  br i1 %.not27, label %30, label %41

30:                                               ; preds = %23
  %31 = load i32, ptr %4, align 4, !tbaa !15
  %.not28 = icmp eq i32 %31, 0
  br i1 %.not28, label %32, label %40

32:                                               ; preds = %30
  %33 = getelementptr i8, ptr %2, i64 %3
  %34 = getelementptr i8, ptr %33, i64 -4
  %35 = call noundef i32 @_Z21LodeZlib_read32bitIntPKh(ptr noundef %34)
  %36 = load ptr, ptr %6, align 8, !tbaa !12
  %37 = load i64, ptr %28, align 8, !tbaa !14
  %38 = trunc i64 %37 to i32
  %39 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %36, i32 noundef %38)
  %.not29 = icmp eq i32 %39, %35
  br i1 %.not29, label %40, label %41

40:                                               ; preds = %32, %30
  br label %41

41:                                               ; preds = %23, %21, %17, %8, %5, %32, %40
  %.1 = phi i32 [ 0, %40 ], [ 58, %32 ], [ 53, %5 ], [ 24, %8 ], [ 25, %17 ], [ 26, %21 ], [ %26, %23 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  ret i32 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !6, i64 0}
!12 = !{!13, !9, i64 0}
!13 = !{!"_ZTS8ucvector", !9, i64 0, !11, i64 8, !11, i64 16}
!14 = !{!13, !11, i64 8}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTS27LodeZlib_DecompressSettings", !17, i64 0}
!17 = !{!"int", !6, i64 0}


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