; LLVM IR from holzschu/ios_system :: shell_cmds/seq (seq)

; 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.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 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: nounwind uwtable
define dso_local i32 @valid_format(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %93, %1
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !11
  %9 = sext i8 %8 to i32
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %94

11:                                               ; preds = %6
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %38

16:                                               ; preds = %11
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = sext i8 %18 to i32
  %20 = icmp ne i32 %19, 37
  br i1 %20, label %21, label %38

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %35, %21
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i32 1
  store ptr %24, ptr %3, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %25
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i8, ptr %31, align 1, !tbaa !11
  %33 = sext i8 %32 to i32
  %34 = icmp ne i32 %33, 37
  br label %35

35:                                               ; preds = %30, %25
  %36 = phi i1 [ false, %25 ], [ %34, %30 ]
  br i1 %36, label %22, label %37, !llvm.loop !12

37:                                               ; preds = %35
  br label %38

38:                                               ; preds = %37, %16, %11
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %93

43:                                               ; preds = %38
  br label %44

44:                                               ; preds = %87, %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i32 1
  store ptr %46, ptr %3, align 8, !tbaa !5
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 37
  br i1 %50, label %51, label %54

51:                                               ; preds = %44
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i32 1
  store ptr %53, ptr %3, align 8, !tbaa !5
  br label %92

54:                                               ; preds = %44
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i8, ptr %55, align 1, !tbaa !11
  %57 = sext i8 %56 to i32
  %58 = call ptr @strchr(ptr noundef @.str.11, i32 noundef %57) #5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %67

60:                                               ; preds = %54
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !9
  %63 = icmp slt i32 %61, 1
  br i1 %63, label %64, label %67

64:                                               ; preds = %60
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i32 1
  store ptr %66, ptr %3, align 8, !tbaa !5
  br label %92

67:                                               ; preds = %60, %54
  %68 = call ptr @__ctype_b_loc() #6
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i32
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i16, ptr %69, i64 %73
  %75 = load i16, ptr %74, align 2, !tbaa !14
  %76 = zext i16 %75 to i32
  %77 = and i32 %76, 2048
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %85, label %79

79:                                               ; preds = %67
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load i8, ptr %80, align 1, !tbaa !11
  %82 = sext i8 %81 to i32
  %83 = call ptr @strchr(ptr noundef @.str.12, i32 noundef %82) #5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %86

85:                                               ; preds = %79, %67
  br label %87

86:                                               ; preds = %79
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %98

87:                                               ; preds = %85
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load i8, ptr %88, align 1, !tbaa !11
  %90 = sext i8 %89 to i32
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %44, label %92, !llvm.loop !16

92:                                               ; preds = %87, %64, %51
  br label %93

93:                                               ; preds = %92, %38
  br label %6, !llvm.loop !17

94:                                               ; preds = %6
  %95 = load i32, ptr %4, align 4, !tbaa !9
  %96 = icmp sle i32 %95, 1
  %97 = zext i1 %96 to i32
  store i32 %97, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %98

98:                                               ; preds = %94, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %99 = load i32, ptr %2, align 4
  ret i32 %99
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

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 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 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}


; 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.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nofree nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @valid_format(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  br label %2

2:                                                ; preds = %.loopexit33, %1
  %.017 = phi ptr [ %0, %1 ], [ %.4, %.loopexit33 ]
  %.0 = phi i32 [ 0, %1 ], [ %.3, %.loopexit33 ]
  %3 = load i8, ptr %.017, align 1, !tbaa !5
  switch i8 %3, label %.preheader34 [
    i8 0, label %29
    i8 37, label %.preheader.preheader
  ]

.preheader34:                                     ; preds = %2, %.preheader34
  %.118 = phi ptr [ %4, %.preheader34 ], [ %.017, %2 ]
  %4 = getelementptr inbounds i8, ptr %.118, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  switch i8 %5, label %.preheader34 [
    i8 0, label %.loopexit33
    i8 37, label %.preheader.preheader
  ]

.preheader.preheader:                             ; preds = %.preheader34, %2
  %.320.ph = phi ptr [ %.017, %2 ], [ %4, %.preheader34 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %28
  %.320 = phi ptr [ %6, %28 ], [ %.320.ph, %.preheader.preheader ]
  %.1 = phi i32 [ %.2, %28 ], [ %.0, %.preheader.preheader ]
  %6 = getelementptr inbounds i8, ptr %.320, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = icmp eq i8 %7, 37
  br i1 %8, label %9, label %11

9:                                                ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %.320, i64 2
  br label %.loopexit33

11:                                               ; preds = %.preheader
  %12 = sext i8 %7 to i32
  %13 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %12) #3
  %.not29 = icmp eq ptr %13, null
  br i1 %.not29, label %19, label %14

14:                                               ; preds = %11
  %15 = add nsw i32 %.1, 1
  %16 = icmp slt i32 %.1, 1
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %.320, i64 2
  br label %.loopexit33

19:                                               ; preds = %14, %11
  %.2 = phi i32 [ %15, %14 ], [ %.1, %11 ]
  %20 = tail call ptr @__ctype_b_loc() #4
  %21 = load ptr, ptr %20, align 8, !tbaa !8
  %22 = zext i8 %7 to i64
  %23 = getelementptr inbounds i16, ptr %21, i64 %22
  %24 = load i16, ptr %23, align 2, !tbaa !10
  %25 = and i16 %24, 2048
  %.not30 = icmp eq i16 %25, 0
  br i1 %.not30, label %26, label %28

26:                                               ; preds = %19
  %27 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %12) #3
  %.not31 = icmp eq ptr %27, null
  br i1 %.not31, label %.loopexit, label %28

28:                                               ; preds = %19, %26
  %.not32 = icmp eq i8 %7, 0
  br i1 %.not32, label %.loopexit33, label %.preheader, !llvm.loop !12

.loopexit33:                                      ; preds = %.preheader34, %28, %9, %17
  %.4 = phi ptr [ %10, %9 ], [ %18, %17 ], [ %6, %28 ], [ %4, %.preheader34 ]
  %.3 = phi i32 [ %.1, %9 ], [ %15, %17 ], [ %.2, %28 ], [ %.0, %.preheader34 ]
  br label %2, !llvm.loop !14

29:                                               ; preds = %2
  %30 = icmp slt i32 %.0, 2
  %31 = zext i1 %30 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %26, %29
  %.021 = phi i32 [ %31, %29 ], [ 0, %26 ]
  ret i32 %.021
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(read, inaccessiblemem: none) 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 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 #2 = { 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 #3 = { nounwind willreturn memory(read) }
attributes #4 = { 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 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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