; LLVM IR from musetronstar/tagd :: tagl/src (lemon)

; 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.88 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [5 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #2

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

12:                                               ; preds = %101, %4
  %13 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 0
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call ptr @fgets(ptr noundef %13, i32 noundef 1000, ptr noundef %14)
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %29

17:                                               ; preds = %12
  %18 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 0
  %19 = load i8, ptr %18, align 16, !tbaa !9
  %20 = sext i8 %19 to i32
  %21 = icmp ne i32 %20, 37
  br i1 %21, label %27, label %22

22:                                               ; preds = %17
  %23 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = icmp ne i32 %25, 37
  br label %27

27:                                               ; preds = %22, %17
  %28 = phi i1 [ true, %17 ], [ %26, %22 ]
  br label %29

29:                                               ; preds = %27, %12
  %30 = phi i1 [ false, %12 ], [ %28, %27 ]
  br i1 %30, label %31, label %107

31:                                               ; preds = %29
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 4, !tbaa !10
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !10
  store i32 0, ptr %10, align 4, !tbaa !10
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %101

37:                                               ; preds = %31
  store i32 0, ptr %9, align 4, !tbaa !10
  br label %38

38:                                               ; preds = %97, %37
  %39 = load i32, ptr %9, align 4, !tbaa !10
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %100

44:                                               ; preds = %38
  %45 = load i32, ptr %9, align 4, !tbaa !10
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !9
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 80
  br i1 %50, label %51, label %96

51:                                               ; preds = %44
  %52 = load i32, ptr %9, align 4, !tbaa !10
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %53
  %55 = call i32 @strncmp(ptr noundef %54, ptr noundef @.str.132, i64 noundef 5) #7
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %96

57:                                               ; preds = %51
  %58 = load i32, ptr %9, align 4, !tbaa !10
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %75, label %60

60:                                               ; preds = %57
  %61 = call ptr @__ctype_b_loc() #8
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !10
  %64 = sub nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !9
  %68 = zext i8 %67 to i32
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i16, ptr %62, i64 %69
  %71 = load i16, ptr %70, align 2, !tbaa !12
  %72 = zext i16 %71 to i32
  %73 = and i32 %72, 1024
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %96, label %75

75:                                               ; preds = %60, %57
  %76 = load i32, ptr %9, align 4, !tbaa !10
  %77 = load i32, ptr %10, align 4, !tbaa !10
  %78 = icmp sgt i32 %76, %77
  br i1 %78, label %79, label %88

79:                                               ; preds = %75
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load i32, ptr %9, align 4, !tbaa !10
  %82 = load i32, ptr %10, align 4, !tbaa !10
  %83 = sub nsw i32 %81, %82
  %84 = load i32, ptr %10, align 4, !tbaa !10
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %85
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.133, i32 noundef %83, ptr noundef %86) #6
  br label %88

88:                                               ; preds = %79, %75
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.88, ptr noundef %90) #6
  %92 = load i32, ptr %9, align 4, !tbaa !10
  %93 = add nsw i32 %92, 4
  store i32 %93, ptr %9, align 4, !tbaa !10
  %94 = load i32, ptr %9, align 4, !tbaa !10
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %10, align 4, !tbaa !10
  br label %96

96:                                               ; preds = %88, %60, %51, %44
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %9, align 4, !tbaa !10
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %9, align 4, !tbaa !10
  br label %38, !llvm.loop !14

100:                                              ; preds = %38
  br label %101

101:                                              ; preds = %100, %31
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = load i32, ptr %10, align 4, !tbaa !10
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 %104
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef @.str.88, ptr noundef %105) #6
  br label %12, !llvm.loop !16

107:                                              ; preds = %29
  call void @llvm.lifetime.end.p0(i64 1000, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret void
}

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #5

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

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

@.str.88 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [5 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #2

; Function Attrs: nofree nounwind uwtable
define dso_local void @tplt_xfer(ptr noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3) local_unnamed_addr #3 {
  %5 = alloca [1000 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1000, ptr nonnull %5) #5
  %6 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 1000, ptr noundef %1)
  %.not27 = icmp eq ptr %6, null
  br i1 %.not27, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = getelementptr inbounds i8, ptr %5, i64 1
  %.not24 = icmp eq ptr %0, null
  br i1 %.not24, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %13
  %8 = load i8, ptr %5, align 16, !tbaa !5
  %9 = icmp ne i8 %8, 37
  %10 = load i8, ptr %7, align 1
  %11 = icmp ne i8 %10, 37
  %12 = select i1 %9, i1 true, i1 %11
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %.lr.ph.split.us
  %14 = load i32, ptr %3, align 4, !tbaa !8
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %3, align 4, !tbaa !8
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.88, ptr noundef nonnull %5) #5
  %17 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 1000, ptr noundef %1)
  %.not.us = icmp eq ptr %17, null
  br i1 %.not.us, label %.critedge, label %.lr.ph.split.us, !llvm.loop !10

.lr.ph.split:                                     ; preds = %.lr.ph, %.loopexit
  %18 = load i8, ptr %5, align 16, !tbaa !5
  %19 = icmp ne i8 %18, 37
  %20 = load i8, ptr %7, align 1
  %21 = icmp ne i8 %20, 37
  %22 = select i1 %19, i1 true, i1 %21
  br i1 %22, label %.preheader, label %.critedge

.preheader:                                       ; preds = %.lr.ph.split
  %23 = load i32, ptr %3, align 4, !tbaa !8
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !8
  br label %25

25:                                               ; preds = %.preheader, %56
  %26 = phi i8 [ %.pre, %56 ], [ %18, %.preheader ]
  %.020 = phi i32 [ %57, %56 ], [ 0, %.preheader ]
  %.0 = phi i32 [ %.1, %56 ], [ 0, %.preheader ]
  switch i8 %26, label %56 [
    i8 0, label %.loopexit
    i8 80, label %27
  ]

27:                                               ; preds = %25
  %28 = sext i32 %.020 to i64
  %29 = getelementptr inbounds [1000 x i8], ptr %5, i64 0, i64 %28
  %30 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) @.str.132, i64 noundef 5) #6
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %56

32:                                               ; preds = %27
  %33 = icmp eq i32 %.020, 0
  br i1 %33, label %45, label %34

34:                                               ; preds = %32
  %35 = tail call ptr @__ctype_b_loc() #7
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = add nsw i32 %.020, -1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1000 x i8], ptr %5, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = zext i8 %40 to i64
  %42 = getelementptr inbounds i16, ptr %36, i64 %41
  %43 = load i16, ptr %42, align 2, !tbaa !14
  %44 = and i16 %43, 1024
  %.not26 = icmp eq i16 %44, 0
  br i1 %.not26, label %45, label %56

45:                                               ; preds = %34, %32
  %46 = icmp sgt i32 %.020, %.0
  br i1 %46, label %47, label %52

47:                                               ; preds = %45
  %48 = sub nsw i32 %.020, %.0
  %49 = sext i32 %.0 to i64
  %50 = getelementptr inbounds [1000 x i8], ptr %5, i64 0, i64 %49
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.133, i32 noundef %48, ptr noundef nonnull %50) #5
  br label %52

52:                                               ; preds = %47, %45
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.88, ptr noundef nonnull %0) #5
  %54 = add nsw i32 %.020, 4
  %55 = add nsw i32 %.020, 5
  br label %56

56:                                               ; preds = %25, %27, %34, %52
  %.121 = phi i32 [ %54, %52 ], [ %.020, %34 ], [ %.020, %27 ], [ %.020, %25 ]
  %.1 = phi i32 [ %55, %52 ], [ %.0, %34 ], [ %.0, %27 ], [ %.0, %25 ]
  %57 = add nsw i32 %.121, 1
  %.phi.trans.insert = sext i32 %57 to i64
  %.phi.trans.insert30 = getelementptr inbounds [1000 x i8], ptr %5, i64 0, i64 %.phi.trans.insert
  %.pre = load i8, ptr %.phi.trans.insert30, align 1, !tbaa !5
  br label %25, !llvm.loop !16

.loopexit:                                        ; preds = %25
  %58 = sext i32 %.0 to i64
  %59 = getelementptr inbounds [1000 x i8], ptr %5, i64 0, i64 %58
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str.88, ptr noundef nonnull %59) #5
  %61 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 1000, ptr noundef %1)
  %.not = icmp eq ptr %61, null
  br i1 %.not, label %.critedge, label %.lr.ph.split, !llvm.loop !10

.critedge:                                        ; preds = %.lr.ph.split, %.loopexit, %.lr.ph.split.us, %13, %4
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %5) #5
  ret void
}

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #4

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !6, i64 0}
!16 = distinct !{!16, !11}


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