; 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 }

; 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 uwtable
declare dso_local noundef i32 @_Z17LodeFlate_deflateP8ucvectorPKhmPK25LodeZlib_CompressSettings(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef, i8 noundef zeroext) #2

; 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) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z17LodeZlib_compressPPhPmPKhmPK25LodeZlib_CompressSettings(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.ucvector, align 8
  %12 = alloca %struct.ucvector, align 8
  %13 = alloca i64, align 8
  %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
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, 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 4, ptr %16) #3
  store i32 120, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %21 = load i32, ptr %16, align 4, !tbaa !11
  %22 = mul i32 256, %21
  %23 = load i32, ptr %18, align 4, !tbaa !11
  %24 = mul i32 %23, 32
  %25 = add i32 %22, %24
  %26 = load i32, ptr %17, align 4, !tbaa !11
  %27 = mul i32 %26, 64
  %28 = add i32 %25, %27
  store i32 %28, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %29 = load i32, ptr %19, align 4, !tbaa !11
  %30 = urem i32 %29, 31
  %31 = sub i32 31, %30
  store i32 %31, ptr %20, align 4, !tbaa !11
  %32 = load i32, ptr %20, align 4, !tbaa !11
  %33 = load i32, ptr %19, align 4, !tbaa !11
  %34 = add i32 %33, %32
  store i32 %34, ptr %19, align 4, !tbaa !11
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load i64, ptr %37, align 8, !tbaa !9
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef %12, ptr noundef %36, i64 noundef %38)
  %39 = load i32, ptr %19, align 4, !tbaa !11
  %40 = udiv i32 %39, 256
  %41 = trunc i32 %40 to i8
  %42 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %12, i8 noundef zeroext %41)
  %43 = load i32, ptr %19, align 4, !tbaa !11
  %44 = urem i32 %43, 256
  %45 = trunc i32 %44 to i8
  %46 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %12, i8 noundef zeroext %45)
  call void @_ZL13ucvector_initP8ucvector(ptr noundef %11)
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = call noundef i32 @_Z17LodeFlate_deflateP8ucvectorPKhmPK25LodeZlib_CompressSettings(ptr noundef %11, ptr noundef %47, i64 noundef %48, ptr noundef %49)
  store i32 %50, ptr %14, align 4, !tbaa !11
  %51 = load i32, ptr %14, align 4, !tbaa !11
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %75, label %53

53:                                               ; preds = %5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i64, ptr %9, align 8, !tbaa !9
  %56 = trunc i64 %55 to i32
  %57 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %54, i32 noundef %56)
  store i32 %57, ptr %15, align 4, !tbaa !11
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %70, %53
  %59 = load i64, ptr %13, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.ucvector, ptr %11, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !13
  %62 = icmp ult i64 %59, %61
  br i1 %62, label %63, label %73

63:                                               ; preds = %58
  %64 = getelementptr inbounds %struct.ucvector, ptr %11, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = load i64, ptr %13, align 8, !tbaa !9
  %67 = getelementptr inbounds i8, ptr %65, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !16
  %69 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %12, i8 noundef zeroext %68)
  br label %70

70:                                               ; preds = %63
  %71 = load i64, ptr %13, align 8, !tbaa !9
  %72 = add i64 %71, 1
  store i64 %72, ptr %13, align 8, !tbaa !9
  br label %58, !llvm.loop !17

73:                                               ; preds = %58
  call void @_ZL16ucvector_cleanupPv(ptr noundef %11)
  %74 = load i32, ptr %15, align 4, !tbaa !11
  call void @_Z20LodeZlib_add32bitIntP8ucvectorj(ptr noundef %12, i32 noundef %74)
  br label %75

75:                                               ; preds = %73, %5
  %76 = getelementptr inbounds %struct.ucvector, ptr %12, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %77, ptr %78, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ucvector, ptr %12, i32 0, i32 1
  %80 = load i64, ptr %79, align 8, !tbaa !13
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %80, ptr %81, align 8, !tbaa !9
  %82 = load i32, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #3
  ret i32 %82
}

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; 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 #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z17LodeZlib_compressPPhPmPKhmPK25LodeZlib_CompressSettings(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca %struct.ucvector, align 8
  %7 = alloca %struct.ucvector, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = load i64, ptr %1, align 8, !tbaa !9
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef nonnull %7, ptr noundef %8, i64 noundef %9)
  %10 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %7, i8 noundef zeroext 120)
  %11 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %7, i8 noundef zeroext 1)
  call void @_ZL13ucvector_initP8ucvector(ptr noundef nonnull %6)
  %12 = call noundef i32 @_Z17LodeFlate_deflateP8ucvectorPKhmPK25LodeZlib_CompressSettings(ptr noundef nonnull %6, ptr noundef %2, i64 noundef %3, ptr noundef %4)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %25

13:                                               ; preds = %5
  %14 = trunc i64 %3 to i32
  %15 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %2, i32 noundef %14)
  %16 = getelementptr inbounds i8, ptr %6, i64 8
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %.not23 = icmp eq i64 %17, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.022 = phi i64 [ %22, %.lr.ph ], [ 0, %13 ]
  %18 = load ptr, ptr %6, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %18, i64 %.022
  %20 = load i8, ptr %19, align 1, !tbaa !14
  %21 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %7, i8 noundef zeroext %20)
  %22 = add nuw i64 %.022, 1
  %23 = load i64, ptr %16, align 8, !tbaa !11
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %13
  call void @_ZL16ucvector_cleanupPv(ptr noundef nonnull %6)
  call void @_Z20LodeZlib_add32bitIntP8ucvectorj(ptr noundef nonnull %7, i32 noundef %15)
  br label %25

25:                                               ; preds = %._crit_edge, %5
  %26 = load ptr, ptr %7, align 8, !tbaa !13
  store ptr %26, ptr %0, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %7, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !11
  store i64 %28, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  ret i32 %12
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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, !10, i64 8}
!12 = !{!"_ZTS8ucvector", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !6, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass