; LLVM IR from NOAA-PMEL/Ferret :: fer/ccr (binaryRead)

; 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.anon = type { i32, [256 x i8] }

@Types = external hidden global %struct.anon, align 4
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 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
declare hidden void @setError(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @br_set_type_(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca [1024 x i8], align 16
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  store i32 0, ptr @Types, align 4, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds [1024 x i8], ptr %4, i64 0, i64 0
  store ptr %12, ptr %7, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %33, %1
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i8, ptr %14, align 1, !tbaa !13
  %16 = sext i8 %15 to i32
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %36

18:                                               ; preds = %13
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i8, ptr %19, align 1, !tbaa !13
  %21 = sext i8 %20 to i32
  %22 = icmp ne i32 %21, 32
  br i1 %22, label %23, label %33

23:                                               ; preds = %18
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = sext i8 %25 to i32
  %27 = icmp ne i32 %26, 9
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i8, ptr %29, align 1, !tbaa !13
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i32 1
  store ptr %32, ptr %7, align 8, !tbaa !5
  store i8 %30, ptr %31, align 1, !tbaa !13
  br label %33

33:                                               ; preds = %28, %23, %18
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i32 1
  store ptr %35, ptr %6, align 8, !tbaa !5
  br label %13, !llvm.loop !14

36:                                               ; preds = %13
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %37, align 1, !tbaa !13
  %38 = getelementptr inbounds [1024 x i8], ptr %4, i64 0, i64 0
  %39 = call ptr @strtok(ptr noundef %38, ptr noundef @.str.6) #3
  store ptr %39, ptr %5, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %56, %36
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %48

43:                                               ; preds = %40
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i8, ptr %44, align 1, !tbaa !13
  %46 = sext i8 %45 to i32
  %47 = icmp ne i32 %46, 0
  br label %48

48:                                               ; preds = %43, %40
  %49 = phi i1 [ false, %40 ], [ %47, %43 ]
  br i1 %49, label %50, label %65

50:                                               ; preds = %48
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 @get_type(ptr noundef %51, ptr noundef %8)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %56, label %54

54:                                               ; preds = %50
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  call void @setError(ptr noundef @.str.7, ptr noundef %55)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %66

56:                                               ; preds = %50
  %57 = load i32, ptr @Types, align 4, !tbaa !11
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @Types, align 4, !tbaa !11
  %59 = load i8, ptr %8, align 1, !tbaa !13
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %9, align 4, !tbaa !9
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds [256 x i8], ptr getelementptr inbounds (%struct.anon, ptr @Types, i32 0, i32 1), i64 0, i64 %62
  store i8 %59, ptr %63, align 1, !tbaa !13
  %64 = call ptr @strtok(ptr noundef null, ptr noundef @.str.6) #3
  store ptr %64, ptr %5, align 8, !tbaa !5
  br label %40, !llvm.loop !16

65:                                               ; preds = %48
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %66

66:                                               ; preds = %65, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1024, ptr %4) #3
  %67 = load i32, ptr %2, align 4
  ret i32 %67
}

; Function Attrs: nounwind
declare ptr @strtok(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @get_type(ptr noundef, ptr noundef) #1

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 = { nounwind "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !7, i64 4}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.anon = type { i32, [256 x i8] }

@Types = external hidden local_unnamed_addr global %struct.anon, align 4
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1

; 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: nounwind uwtable
declare hidden void @setError(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @br_set_type_(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca [1024 x i8], align 16
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  store i32 0, ptr @Types, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %8, %1
  %.014 = phi ptr [ %0, %1 ], [ %9, %8 ]
  %.013 = phi ptr [ %2, %1 ], [ %.1, %8 ]
  %5 = load i8, ptr %.014, align 1, !tbaa !10
  switch i8 %5, label %6 [
    i8 0, label %10
    i8 32, label %8
    i8 9, label %8
  ]

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %.013, i64 1
  store i8 %5, ptr %.013, align 1, !tbaa !10
  br label %8

8:                                                ; preds = %4, %4, %6
  %.1 = phi ptr [ %7, %6 ], [ %.013, %4 ], [ %.013, %4 ]
  %9 = getelementptr inbounds i8, ptr %.014, i64 1
  br label %4, !llvm.loop !11

10:                                               ; preds = %4
  store i8 0, ptr %.013, align 1, !tbaa !10
  %11 = call ptr @strtok(ptr noundef nonnull %2, ptr noundef nonnull @.str.6) #3
  %.not1824 = icmp eq ptr %11, null
  br i1 %.not1824, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %10, %16
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 0, %10 ]
  %.01525 = phi ptr [ %21, %16 ], [ %11, %10 ]
  %12 = load i8, ptr %.01525, align 1, !tbaa !10
  %.not19 = icmp eq i8 %12, 0
  br i1 %.not19, label %.critedge, label %13

13:                                               ; preds = %.lr.ph
  %14 = call i32 @get_type(ptr noundef nonnull %.01525, ptr noundef nonnull %3)
  %.not20 = icmp eq i32 %14, 0
  br i1 %.not20, label %15, label %16

15:                                               ; preds = %13
  call void @setError(ptr noundef nonnull @.str.7, ptr noundef nonnull %.01525)
  br label %.critedge

16:                                               ; preds = %13
  %17 = load i32, ptr @Types, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @Types, align 4, !tbaa !5
  %19 = load i8, ptr %3, align 1, !tbaa !10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = getelementptr inbounds [256 x i8], ptr getelementptr inbounds (i8, ptr @Types, i64 4), i64 0, i64 %indvars.iv
  store i8 %19, ptr %20, align 1, !tbaa !10
  %21 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str.6) #3
  %.not18 = icmp eq ptr %21, null
  br i1 %.not18, label %.critedge, label %.lr.ph, !llvm.loop !13

.critedge:                                        ; preds = %16, %.lr.ph, %10, %15
  %.016 = phi i32 [ 0, %15 ], [ 1, %10 ], [ 1, %.lr.ph ], [ 1, %16 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %2) #3
  ret i32 %.016
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @get_type(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { mustprogress nofree nounwind willreturn "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, !7, i64 0}
!6 = !{!"", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass