; LLVM IR from Try/Tempest :: Engine/thirdparty/libpng (pngrutil)

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

@.str.49 = external hidden unnamed_addr constant [19 x i8], align 1

; 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: nounwind uwtable
define dso_local void @png_check_chunk_name(ptr noalias noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %8 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %8, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %31, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp sle i32 %10, 4
  br i1 %11, label %12, label %34

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = and i32 %13, 255
  store i32 %14, ptr %7, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 65
  br i1 %16, label %26, label %17

17:                                               ; preds = %12
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = icmp sgt i32 %18, 122
  br i1 %19, label %26, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, 90
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 97
  br i1 %25, label %26, label %28

26:                                               ; preds = %23, %17, %12
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  call void @png_chunk_error(ptr noundef %27, ptr noundef @.str.49) #4
  unreachable

28:                                               ; preds = %23, %20
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = lshr i32 %29, 8
  store i32 %30, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !11

34:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: noreturn
declare void @png_chunk_error(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { noreturn "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 }
attributes #4 = { noreturn }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str.49 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @png_check_chunk_name(ptr noalias noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = and i32 %1, 255
  %4 = add nsw i32 %3, -123
  %or.cond = icmp ult i32 %4, -58
  %5 = add nsw i32 %3, -91
  %or.cond3 = icmp ult i32 %5, 6
  %or.cond14 = select i1 %or.cond, i1 true, i1 %or.cond3
  br i1 %or.cond14, label %6, label %7

6:                                                ; preds = %17, %12, %7, %2
  tail call void @png_chunk_error(ptr noundef %0, ptr noundef nonnull @.str.49) #2
  unreachable

7:                                                ; preds = %2
  %8 = lshr i32 %1, 8
  %9 = and i32 %8, 255
  %10 = add nsw i32 %9, -123
  %or.cond.1 = icmp ult i32 %10, -58
  %11 = add nsw i32 %9, -91
  %or.cond3.1 = icmp ult i32 %11, 6
  %or.cond14.1 = select i1 %or.cond.1, i1 true, i1 %or.cond3.1
  br i1 %or.cond14.1, label %6, label %12

12:                                               ; preds = %7
  %13 = lshr i32 %1, 16
  %14 = and i32 %13, 255
  %15 = add nsw i32 %14, -123
  %or.cond.2 = icmp ult i32 %15, -58
  %16 = add nsw i32 %14, -91
  %or.cond3.2 = icmp ult i32 %16, 6
  %or.cond14.2 = select i1 %or.cond.2, i1 true, i1 %or.cond3.2
  br i1 %or.cond14.2, label %6, label %17

17:                                               ; preds = %12
  %18 = lshr i32 %1, 24
  %19 = add nsw i32 %18, -123
  %or.cond.3 = icmp ult i32 %19, -58
  %20 = add nsw i32 %18, -91
  %or.cond3.3 = icmp ult i32 %20, 6
  %or.cond14.3 = select i1 %or.cond.3, i1 true, i1 %or.cond3.3
  br i1 %or.cond14.3, label %6, label %21

21:                                               ; preds = %17
  ret void
}

; Function Attrs: noreturn
declare void @png_chunk_error(ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { noreturn "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 = { noreturn 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)"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass