; LLVM IR from niessner/Matterport :: code/gaps/pkgs/png (pngwutil)

; 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.png_time_struct = type { i16, i8, i8, i8, i8, i8 }

@__const.png_write_tIME.png_tIME = external hidden unnamed_addr constant [5 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @png_save_uint_16(ptr noundef, i32 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 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @png_write_chunk(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #0

declare void @png_warning(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @png_write_tIME(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [5 x i8], align 1
  %6 = alloca [7 x i8], align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %5, ptr align 1 @__const.png_write_tIME.png_tIME, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 7, ptr %6) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.png_time_struct, ptr %8, i32 0, i32 1
  %10 = load i8, ptr %9, align 2, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = icmp sgt i32 %11, 12
  br i1 %12, label %43, label %13

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.png_time_struct, ptr %14, i32 0, i32 1
  %16 = load i8, ptr %15, align 2, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = icmp slt i32 %17, 1
  br i1 %18, label %43, label %19

19:                                               ; preds = %13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.png_time_struct, ptr %20, i32 0, i32 2
  %22 = load i8, ptr %21, align 1, !tbaa !12
  %23 = zext i8 %22 to i32
  %24 = icmp sgt i32 %23, 31
  br i1 %24, label %43, label %25

25:                                               ; preds = %19
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.png_time_struct, ptr %26, i32 0, i32 2
  %28 = load i8, ptr %27, align 1, !tbaa !12
  %29 = zext i8 %28 to i32
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %43, label %31

31:                                               ; preds = %25
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.png_time_struct, ptr %32, i32 0, i32 3
  %34 = load i8, ptr %33, align 2, !tbaa !13
  %35 = zext i8 %34 to i32
  %36 = icmp sgt i32 %35, 23
  br i1 %36, label %43, label %37

37:                                               ; preds = %31
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.png_time_struct, ptr %38, i32 0, i32 5
  %40 = load i8, ptr %39, align 2, !tbaa !14
  %41 = zext i8 %40 to i32
  %42 = icmp sgt i32 %41, 60
  br i1 %42, label %43, label %45

43:                                               ; preds = %37, %31, %25, %19, %13, %2
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  call void @png_warning(ptr noundef %44, ptr noundef @.str.44)
  store i32 1, ptr %7, align 4
  br label %74

45:                                               ; preds = %37
  %46 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 0
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.png_time_struct, ptr %47, i32 0, i32 0
  %49 = load i16, ptr %48, align 2, !tbaa !15
  %50 = zext i16 %49 to i32
  call void @png_save_uint_16(ptr noundef %46, i32 noundef %50)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.png_time_struct, ptr %51, i32 0, i32 1
  %53 = load i8, ptr %52, align 2, !tbaa !9
  %54 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 2
  store i8 %53, ptr %54, align 1, !tbaa !16
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.png_time_struct, ptr %55, i32 0, i32 2
  %57 = load i8, ptr %56, align 1, !tbaa !12
  %58 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 3
  store i8 %57, ptr %58, align 1, !tbaa !16
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.png_time_struct, ptr %59, i32 0, i32 3
  %61 = load i8, ptr %60, align 2, !tbaa !13
  %62 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 4
  store i8 %61, ptr %62, align 1, !tbaa !16
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.png_time_struct, ptr %63, i32 0, i32 4
  %65 = load i8, ptr %64, align 1, !tbaa !17
  %66 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 5
  store i8 %65, ptr %66, align 1, !tbaa !16
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.png_time_struct, ptr %67, i32 0, i32 5
  %69 = load i8, ptr %68, align 2, !tbaa !14
  %70 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 6
  store i8 %69, ptr %70, align 1, !tbaa !16
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds [5 x i8], ptr %5, i64 0, i64 0
  %73 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 0
  call void @png_write_chunk(ptr noundef %71, ptr noundef %72, ptr noundef %73, i64 noundef 7)
  store i32 0, ptr %7, align 4
  br label %74

74:                                               ; preds = %45, %43
  call void @llvm.lifetime.end.p0(i64 7, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr %5) #4
  %75 = load i32, ptr %7, align 4
  switch i32 %75, label %77 [
    i32 0, label %76
    i32 1, label %76
  ]

76:                                               ; preds = %74, %74
  ret void

77:                                               ; preds = %74
  unreachable
}

attributes #0 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #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/C++ TBAA"}
!9 = !{!10, !7, i64 2}
!10 = !{!"png_time_struct", !11, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !7, i64 3}
!13 = !{!10, !7, i64 4}
!14 = !{!10, !7, i64 6}
!15 = !{!10, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !7, i64 5}


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

@__const.png_write_tIME.png_tIME = external hidden unnamed_addr constant [5 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @png_save_uint_16(ptr noundef, i32 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @png_write_chunk(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare void @png_warning(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @png_write_tIME(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [5 x i8], align 1
  %4 = alloca [7 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %3, ptr noundef nonnull align 1 dereferenceable(5) @__const.png_write_tIME.png_tIME, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %4) #4
  %5 = getelementptr inbounds i8, ptr %1, i64 2
  %6 = load i8, ptr %5, align 2, !tbaa !5
  %7 = add i8 %6, -13
  %or.cond = icmp ult i8 %7, -12
  br i1 %or.cond, label %20, label %8

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 3
  %10 = load i8, ptr %9, align 1, !tbaa !10
  %11 = add i8 %10, -32
  %or.cond15 = icmp ult i8 %11, -31
  br i1 %or.cond15, label %20, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i8, ptr %13, align 2, !tbaa !11
  %15 = icmp ugt i8 %14, 23
  br i1 %15, label %20, label %16

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %1, i64 6
  %18 = load i8, ptr %17, align 2, !tbaa !12
  %19 = icmp ugt i8 %18, 60
  br i1 %19, label %20, label %21

20:                                               ; preds = %16, %12, %8, %2
  tail call void @png_warning(ptr noundef %0, ptr noundef nonnull @.str.44) #4
  br label %28

21:                                               ; preds = %16
  %22 = load i16, ptr %1, align 2, !tbaa !13
  %23 = zext i16 %22 to i32
  call void @png_save_uint_16(ptr noundef nonnull %4, i32 noundef %23)
  %24 = getelementptr inbounds i8, ptr %4, i64 2
  %25 = load <4 x i8>, ptr %5, align 2, !tbaa !14
  store <4 x i8> %25, ptr %24, align 1, !tbaa !14
  %26 = load i8, ptr %17, align 2, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %4, i64 6
  store i8 %26, ptr %27, align 1, !tbaa !14
  call void @png_write_chunk(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 7)
  br label %28

28:                                               ; preds = %21, %20
  call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %3) #4
  ret void
}

attributes #0 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #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, !8, i64 2}
!6 = !{!"png_time_struct", !7, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !8, i64 3}
!11 = !{!6, !8, i64 4}
!12 = !{!6, !8, i64 6}
!13 = !{!6, !7, i64 0}
!14 = !{!8, !8, i64 0}


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