; 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.LodePNG_InfoPng = type { i32, i32, i32, i32, i32, %struct.LodePNG_InfoColor, i32, i32, i32, i32, %struct.LodePNG_Text, %struct.LodePNG_IText, i8, %struct.LodePNG_Time, i32, i32, i32, i8, %struct.LodePNG_UnknownChunks }
%struct.LodePNG_InfoColor = type { i32, i32, ptr, i64, i32, i32, i32, i32 }
%struct.LodePNG_Text = type { i64, ptr, ptr }
%struct.LodePNG_IText = type { i64, ptr, ptr, ptr, ptr }
%struct.LodePNG_Time = type { i32, i8, i8, i8, i8, i8 }
%struct.LodePNG_UnknownChunks = type { [3 x ptr], [3 x 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 nounwind uwtable
declare dso_local void @_Z22LodePNG_InfoColor_initP17LodePNG_InfoColor(ptr noundef) #1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20LodePNG_InfoPng_copyP15LodePNG_InfoPngPKS_(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z23LodePNG_InfoPng_cleanupP15LodePNG_InfoPng(ptr noundef %8)
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %9, i64 224, i1 false), !tbaa.struct !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %11, i32 0, i32 5
  call void @_Z22LodePNG_InfoColor_initP17LodePNG_InfoColor(ptr noundef %12)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %13, i32 0, i32 5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %15, i32 0, i32 5
  %17 = call noundef i32 @_Z22LodePNG_InfoColor_copyP17LodePNG_InfoColorPKS_(ptr noundef %14, ptr noundef %16)
  store i32 %17, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %2
  %21 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %21, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %56

22:                                               ; preds = %2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %23, i32 0, i32 10
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %25, i32 0, i32 10
  %27 = call noundef i32 @_Z17LodePNG_Text_copyP12LodePNG_TextPKS_(ptr noundef %24, ptr noundef %26)
  store i32 %27, ptr %6, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %22
  %31 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %31, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %56

32:                                               ; preds = %22
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %33, i32 0, i32 11
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %35, i32 0, i32 11
  %37 = call noundef i32 @_Z18LodePNG_IText_copyP13LodePNG_ITextPKS_(ptr noundef %34, ptr noundef %36)
  store i32 %37, ptr %6, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %32
  %41 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %41, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %56

42:                                               ; preds = %32
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %43, i32 0, i32 18
  call void @_Z26LodePNG_UnknownChunks_initP21LodePNG_UnknownChunks(ptr noundef %44)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %45, i32 0, i32 18
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.LodePNG_InfoPng, ptr %47, i32 0, i32 18
  %49 = call noundef i32 @_Z26LodePNG_UnknownChunks_copyP21LodePNG_UnknownChunksPKS_(ptr noundef %46, ptr noundef %48)
  store i32 %49, ptr %6, align 4, !tbaa !9
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %54

52:                                               ; preds = %42
  %53 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %53, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %56

54:                                               ; preds = %42
  %55 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %55, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %56

56:                                               ; preds = %54, %52, %40, %30, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %57 = load i32, ptr %3, align 4
  ret i32 %57
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 8, !5, i64 40, i64 8, !12, i64 48, i64 4, !9, i64 52, i64 4, !9, i64 56, i64 4, !9, i64 60, i64 4, !9, i64 64, i64 4, !9, i64 68, i64 4, !9, i64 72, i64 4, !9, i64 76, i64 4, !9, i64 80, i64 8, !12, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !12, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 8, !5, i64 136, i64 8, !5, i64 144, i64 1, !14, i64 148, i64 4, !9, i64 152, i64 1, !14, i64 153, i64 1, !14, i64 154, i64 1, !14, i64 155, i64 1, !14, i64 156, i64 1, !14, i64 160, i64 4, !9, i64 164, i64 4, !9, i64 168, i64 4, !9, i64 172, i64 1, !14, i64 176, i64 24, !14, i64 200, i64 24, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!7, !7, 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"

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20LodePNG_InfoPng_copyP15LodePNG_InfoPngPKS_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  tail call void @_Z23LodePNG_InfoPng_cleanupP15LodePNG_InfoPng(ptr noundef %0)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull align 8 dereferenceable(224) %1, i64 224, i1 false), !tbaa.struct !5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_Z22LodePNG_InfoColor_initP17LodePNG_InfoColor(ptr noundef nonnull %3)
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = tail call noundef i32 @_Z22LodePNG_InfoColor_copyP17LodePNG_InfoColorPKS_(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %18

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = getelementptr inbounds i8, ptr %1, i64 80
  %9 = tail call noundef i32 @_Z17LodePNG_Text_copyP12LodePNG_TextPKS_(ptr noundef nonnull %7, ptr noundef nonnull %8)
  %.not26 = icmp eq i32 %9, 0
  br i1 %.not26, label %10, label %18

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 104
  %12 = getelementptr inbounds i8, ptr %1, i64 104
  %13 = tail call noundef i32 @_Z18LodePNG_IText_copyP13LodePNG_ITextPKS_(ptr noundef nonnull %11, ptr noundef nonnull %12)
  %.not27 = icmp eq i32 %13, 0
  br i1 %.not27, label %14, label %18

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @_Z26LodePNG_UnknownChunks_initP21LodePNG_UnknownChunks(ptr noundef nonnull %15)
  %16 = getelementptr inbounds i8, ptr %1, i64 176
  %17 = tail call noundef i32 @_Z26LodePNG_UnknownChunks_copyP21LodePNG_UnknownChunksPKS_(ptr noundef nonnull %15, ptr noundef nonnull %16)
  br label %18

18:                                               ; preds = %14, %10, %6, %2
  %.0 = phi i32 [ %5, %2 ], [ %9, %6 ], [ %13, %10 ], [ %17, %14 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z22LodePNG_InfoColor_copyP17LodePNG_InfoColorPKS_(ptr noundef, ptr 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" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6, i64 24, i64 4, !6, i64 28, i64 4, !6, i64 32, i64 8, !10, i64 40, i64 8, !12, i64 48, i64 4, !6, i64 52, i64 4, !6, i64 56, i64 4, !6, i64 60, i64 4, !6, i64 64, i64 4, !6, i64 68, i64 4, !6, i64 72, i64 4, !6, i64 76, i64 4, !6, i64 80, i64 8, !12, i64 88, i64 8, !10, i64 96, i64 8, !10, i64 104, i64 8, !12, i64 112, i64 8, !10, i64 120, i64 8, !10, i64 128, i64 8, !10, i64 136, i64 8, !10, i64 144, i64 1, !14, i64 148, i64 4, !6, i64 152, i64 1, !14, i64 153, i64 1, !14, i64 154, i64 1, !14, i64 155, i64 1, !14, i64 156, i64 1, !14, i64 160, i64 4, !6, i64 164, i64 4, !6, i64 168, i64 4, !6, i64 172, i64 1, !14, i64 176, i64 24, !14, i64 200, i64 24, !14}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!8, !8, i64 0}


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