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

@decimal_point = external dso_local global ptr, align 8
@default_format = external dso_local global [3 x i8], align 1
@generate_format.buf = external hidden global [256 x i8], align 16
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [9 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 ptr @generate_format(double noundef %0, double noundef %1, double noundef %2, i32 noundef %3, i8 noundef signext %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store double %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i8 %4, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #5
  store i8 0, ptr %12, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %5
  store ptr @default_format, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %155

21:                                               ; preds = %5
  %22 = load double, ptr %7, align 8, !tbaa !5
  %23 = load double, ptr %9, align 8, !tbaa !5
  %24 = fcmp ogt double %22, %23
  br i1 %24, label %25, label %36

25:                                               ; preds = %21
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = load double, ptr %8, align 8, !tbaa !5
  %28 = load double, ptr %7, align 8, !tbaa !5
  %29 = load double, ptr %9, align 8, !tbaa !5
  %30 = fsub double %28, %29
  %31 = load double, ptr %8, align 8, !tbaa !5
  %32 = fdiv double %30, %31
  %33 = call double @llvm.floor.f64(double %32)
  %34 = fneg double %27
  %35 = call double @llvm.fmuladd.f64(double %34, double %33, double %26)
  store double %35, ptr %9, align 8, !tbaa !5
  br label %46

36:                                               ; preds = %21
  %37 = load double, ptr %7, align 8, !tbaa !5
  %38 = load double, ptr %8, align 8, !tbaa !5
  %39 = load double, ptr %9, align 8, !tbaa !5
  %40 = load double, ptr %7, align 8, !tbaa !5
  %41 = fsub double %39, %40
  %42 = load double, ptr %8, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  %44 = call double @llvm.floor.f64(double %43)
  %45 = call double @llvm.fmuladd.f64(double %38, double %44, double %37)
  store double %45, ptr %9, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %36, %25
  %47 = load double, ptr %8, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @generate_format.buf, ptr noundef @.str.15, double noundef %47) #5
  %49 = call ptr @strchr(ptr noundef @generate_format.buf, i32 noundef 101) #6
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %52

51:                                               ; preds = %46
  store i8 101, ptr %12, align 1, !tbaa !11
  br label %52

52:                                               ; preds = %51, %46
  %53 = call i32 @decimal_places(ptr noundef @generate_format.buf)
  store i32 %53, ptr %13, align 4, !tbaa !9
  %54 = load double, ptr %7, align 8, !tbaa !5
  %55 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @generate_format.buf, ptr noundef @.str.15, double noundef %54) #5
  store i32 %55, ptr %14, align 4, !tbaa !9
  %56 = call ptr @strchr(ptr noundef @generate_format.buf, i32 noundef 101) #6
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  store i8 101, ptr %12, align 1, !tbaa !11
  br label %59

59:                                               ; preds = %58, %52
  %60 = call i32 @decimal_places(ptr noundef @generate_format.buf)
  store i32 %60, ptr %16, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %72

62:                                               ; preds = %59
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = load ptr, ptr @decimal_point, align 8, !tbaa !12
  %66 = call i64 @strlen(ptr noundef %65) #6
  %67 = add i64 %64, %66
  %68 = load i32, ptr %14, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = sub i64 %69, %67
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr %14, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %62, %59
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %76, label %78

76:                                               ; preds = %72
  %77 = load i32, ptr %13, align 4, !tbaa !9
  br label %80

78:                                               ; preds = %72
  %79 = load i32, ptr %16, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %78, %76
  %81 = phi i32 [ %77, %76 ], [ %79, %78 ]
  store i32 %81, ptr %13, align 4, !tbaa !9
  %82 = load double, ptr %9, align 8, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @generate_format.buf, ptr noundef @.str.15, double noundef %82) #5
  store i32 %83, ptr %15, align 4, !tbaa !9
  %84 = call ptr @strchr(ptr noundef @generate_format.buf, i32 noundef 101) #6
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %87

86:                                               ; preds = %80
  store i8 101, ptr %12, align 1, !tbaa !11
  br label %87

87:                                               ; preds = %86, %80
  %88 = call i32 @decimal_places(ptr noundef @generate_format.buf)
  store i32 %88, ptr %16, align 4, !tbaa !9
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %100

90:                                               ; preds = %87
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = load ptr, ptr @decimal_point, align 8, !tbaa !12
  %94 = call i64 @strlen(ptr noundef %93) #6
  %95 = add i64 %92, %94
  %96 = load i32, ptr %15, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = sub i64 %97, %95
  %99 = trunc i64 %98 to i32
  store i32 %99, ptr %15, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %90, %87
  %101 = load i32, ptr %13, align 4, !tbaa !9
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %132

103:                                              ; preds = %100
  %104 = load i8, ptr %11, align 1, !tbaa !11
  %105 = sext i8 %104 to i32
  %106 = load i32, ptr %14, align 4, !tbaa !9
  %107 = load i32, ptr %15, align 4, !tbaa !9
  %108 = icmp slt i32 %106, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %103
  %110 = load i32, ptr %15, align 4, !tbaa !9
  br label %113

111:                                              ; preds = %103
  %112 = load i32, ptr %14, align 4, !tbaa !9
  br label %113

113:                                              ; preds = %111, %109
  %114 = phi i32 [ %110, %109 ], [ %112, %111 ]
  %115 = load ptr, ptr @decimal_point, align 8, !tbaa !12
  %116 = call i64 @strlen(ptr noundef %115) #6
  %117 = trunc i64 %116 to i32
  %118 = add nsw i32 %114, %117
  %119 = load i32, ptr %13, align 4, !tbaa !9
  %120 = add nsw i32 %118, %119
  %121 = load i32, ptr %13, align 4, !tbaa !9
  %122 = load i8, ptr %12, align 1, !tbaa !11
  %123 = sext i8 %122 to i32
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %128

125:                                              ; preds = %113
  %126 = load i8, ptr %12, align 1, !tbaa !11
  %127 = sext i8 %126 to i32
  br label %129

128:                                              ; preds = %113
  br label %129

129:                                              ; preds = %128, %125
  %130 = phi i32 [ %127, %125 ], [ 102, %128 ]
  %131 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @generate_format.buf, ptr noundef @.str.16, i32 noundef %105, i32 noundef %120, i32 noundef %121, i32 noundef %130) #5
  br label %154

132:                                              ; preds = %100
  %133 = load i8, ptr %11, align 1, !tbaa !11
  %134 = sext i8 %133 to i32
  %135 = load i32, ptr %14, align 4, !tbaa !9
  %136 = load i32, ptr %15, align 4, !tbaa !9
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %138, label %140

138:                                              ; preds = %132
  %139 = load i32, ptr %15, align 4, !tbaa !9
  br label %142

140:                                              ; preds = %132
  %141 = load i32, ptr %14, align 4, !tbaa !9
  br label %142

142:                                              ; preds = %140, %138
  %143 = phi i32 [ %139, %138 ], [ %141, %140 ]
  %144 = load i8, ptr %12, align 1, !tbaa !11
  %145 = sext i8 %144 to i32
  %146 = icmp ne i32 %145, 0
  br i1 %146, label %147, label %150

147:                                              ; preds = %142
  %148 = load i8, ptr %12, align 1, !tbaa !11
  %149 = sext i8 %148 to i32
  br label %151

150:                                              ; preds = %142
  br label %151

151:                                              ; preds = %150, %147
  %152 = phi i32 [ %149, %147 ], [ 103, %150 ]
  %153 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @generate_format.buf, ptr noundef @.str.17, i32 noundef %134, i32 noundef %143, i32 noundef %152) #5
  br label %154

154:                                              ; preds = %151, %129
  store ptr @generate_format.buf, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %155

155:                                              ; preds = %154, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #5
  %156 = load ptr, ptr %6, align 8
  ret ptr %156
}

; 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(read)
declare i64 @strlen(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @decimal_places(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

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(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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"double", !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 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}


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

@decimal_point = external dso_local local_unnamed_addr global ptr, align 8
@default_format = external dso_local global [3 x i8], align 1
@generate_format.buf = external hidden global [256 x i8], align 16
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @generate_format(double noundef %0, double noundef %1, double noundef %2, i32 noundef %3, i8 noundef signext %4) local_unnamed_addr #0 {
  %6 = icmp eq i32 %3, 0
  br i1 %6, label %60, label %7

7:                                                ; preds = %5
  %8 = fcmp ogt double %0, %2
  br i1 %8, label %9, label %15

9:                                                ; preds = %7
  %10 = fsub double %0, %2
  %11 = fdiv double %10, %1
  %12 = tail call double @llvm.floor.f64(double %11)
  %13 = fneg double %1
  %14 = tail call double @llvm.fmuladd.f64(double %13, double %12, double %0)
  br label %20

15:                                               ; preds = %7
  %16 = fsub double %2, %0
  %17 = fdiv double %16, %1
  %18 = tail call double @llvm.floor.f64(double %17)
  %19 = tail call double @llvm.fmuladd.f64(double %1, double %18, double %0)
  br label %20

20:                                               ; preds = %15, %9
  %.044 = phi double [ %14, %9 ], [ %19, %15 ]
  %21 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @generate_format.buf, ptr noundef nonnull dereferenceable(1) @.str.15, double noundef %1) #5
  %22 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @generate_format.buf, i32 noundef 101) #6
  %.not = icmp eq ptr %22, null
  %23 = tail call i32 @decimal_places(ptr noundef nonnull @generate_format.buf)
  %24 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @generate_format.buf, ptr noundef nonnull dereferenceable(1) @.str.15, double noundef %0) #5
  %25 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @generate_format.buf, i32 noundef 101) #6
  %.not52 = icmp eq ptr %25, null
  %26 = tail call i32 @decimal_places(ptr noundef nonnull @generate_format.buf)
  %.not53 = icmp eq i32 %26, 0
  br i1 %.not53, label %33, label %27

27:                                               ; preds = %20
  %28 = load ptr, ptr @decimal_point, align 8, !tbaa !5
  %29 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %28) #6
  %30 = trunc i64 %29 to i32
  %31 = add i32 %26, %30
  %32 = sub i32 %24, %31
  br label %33

33:                                               ; preds = %27, %20
  %.041 = phi i32 [ %32, %27 ], [ %24, %20 ]
  %34 = tail call i32 @llvm.smax.i32(i32 %26, i32 %23)
  %35 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @generate_format.buf, ptr noundef nonnull dereferenceable(1) @.str.15, double noundef %.044) #5
  %36 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) @generate_format.buf, i32 noundef 101) #6
  %.not54 = icmp eq ptr %36, null
  %37 = select i1 %.not54, i1 %.not52, i1 false
  %38 = select i1 %37, i1 %.not, i1 false
  %39 = tail call i32 @decimal_places(ptr noundef nonnull @generate_format.buf)
  %.not55 = icmp eq i32 %39, 0
  br i1 %.not55, label %46, label %40

40:                                               ; preds = %33
  %41 = load ptr, ptr @decimal_point, align 8, !tbaa !5
  %42 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %41) #6
  %43 = trunc i64 %42 to i32
  %44 = add i32 %39, %43
  %45 = sub i32 %35, %44
  br label %46

46:                                               ; preds = %40, %33
  %.0 = phi i32 [ %45, %40 ], [ %35, %33 ]
  %.not56 = icmp eq i32 %34, 0
  %47 = sext i8 %4 to i32
  %48 = tail call i32 @llvm.smax.i32(i32 %.041, i32 %.0)
  br i1 %.not56, label %57, label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr @decimal_point, align 8, !tbaa !5
  %51 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %50) #6
  %52 = trunc i64 %51 to i32
  %53 = add i32 %48, %34
  %54 = add i32 %53, %52
  %55 = select i1 %38, i32 102, i32 101
  %56 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @generate_format.buf, ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef %47, i32 noundef %54, i32 noundef %34, i32 noundef %55) #5
  br label %60

57:                                               ; preds = %46
  %58 = select i1 %38, i32 103, i32 101
  %59 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @generate_format.buf, ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %47, i32 noundef %48, i32 noundef %58) #5
  br label %60

60:                                               ; preds = %49, %57, %5
  %.043 = phi ptr [ @default_format, %5 ], [ @generate_format.buf, %57 ], [ @generate_format.buf, %49 ]
  ret ptr %.043
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @decimal_places(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass