; LLVM IR from Try/Tempest :: Engine/thirdparty/libpng (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 }

@.str.41 = 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden void @png_write_complete_chunk(ptr noalias noundef, i32 noundef, ptr noundef, i64 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @png_write_tIME(ptr noalias noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [7 x i8], align 1
  %6 = 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 7, ptr %5) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.png_time_struct, ptr %7, i32 0, i32 1
  %9 = load i8, ptr %8, align 2, !tbaa !9
  %10 = zext i8 %9 to i32
  %11 = icmp sgt i32 %10, 12
  br i1 %11, label %42, label %12

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

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

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

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

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

42:                                               ; preds = %36, %30, %24, %18, %12, %2
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  call void @png_warning(ptr noundef %43, ptr noundef @.str.41)
  store i32 1, ptr %6, align 4
  br label %72

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

72:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 7, ptr %5) #3
  %73 = load i32, ptr %6, align 4
  switch i32 %73, label %75 [
    i32 0, label %74
    i32 1, label %74
  ]

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

75:                                               ; preds = %72
  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 = { "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/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"

@.str.41 = 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden void @png_write_complete_chunk(ptr noalias noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

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

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

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

19:                                               ; preds = %15, %11, %7, %2
  tail call void @png_warning(ptr noundef %0, ptr noundef nonnull @.str.41) #3
  br label %27

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

27:                                               ; preds = %20, %19
  call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %3) #3
  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 = { "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, !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