; LLVM IR from s-matyukevich/raspberry-pi-os :: exercises/lesson01/2/gcrisis/uart-boot/downloader (raspiloader)

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

@stderr = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @do_exit(i32 noundef, i32 noundef) #0

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

declare i32 @open(ptr noundef, i32 noundef, ...) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare void @perror(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @send_kernel(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i64, align 8
  %12 = alloca [4 x i8], align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [65536 x i8], align 16
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #6
  store i8 0, ptr %10, align 1, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = call i32 (ptr, i32, ...) @open(ptr noundef %19, i32 noundef 0)
  store i32 %20, ptr %5, align 4, !tbaa !5
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %25

22:                                               ; preds = %2
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  call void @perror(ptr noundef %23)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %24, i32 noundef 1)
  br label %25

25:                                               ; preds = %22, %2
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = call i64 @lseek(i32 noundef %26, i64 noundef 0, i32 noundef 2) #6
  store i64 %27, ptr %6, align 8, !tbaa !13
  %28 = load i64, ptr %6, align 8, !tbaa !13
  %29 = icmp sgt i64 %28, 2097152
  br i1 %29, label %30, label %34

30:                                               ; preds = %25
  %31 = load ptr, ptr @stderr, align 8, !tbaa !9
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.5) #6
  %33 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %33, i32 noundef 1)
  br label %34

34:                                               ; preds = %30, %25
  %35 = load i64, ptr %6, align 8, !tbaa !13
  %36 = trunc i64 %35 to i32
  %37 = call i32 @__uint32_identity(i32 noundef %36)
  store i32 %37, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = call i64 @lseek(i32 noundef %38, i64 noundef 0, i32 noundef 0) #6
  %40 = load ptr, ptr %4, align 8, !tbaa !9
  %41 = load i64, ptr %6, align 8, !tbaa !13
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %40, i64 noundef %41)
  store ptr %7, ptr %9, align 8, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !13
  br label %43

43:                                               ; preds = %60, %34
  %44 = load i64, ptr %8, align 8, !tbaa !13
  %45 = icmp slt i64 %44, 4
  br i1 %45, label %46, label %64

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !9
  %49 = load i64, ptr %8, align 8, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  %51 = load i64, ptr %8, align 8, !tbaa !13
  %52 = sub nsw i64 4, %51
  %53 = call i64 @write(i32 noundef %47, ptr noundef %50, i64 noundef %52)
  store i64 %53, ptr %11, align 8, !tbaa !13
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = call i32 @tcdrain(i32 noundef %54)
  %56 = load i64, ptr %11, align 8, !tbaa !13
  %57 = icmp eq i64 %56, -1
  br i1 %57, label %58, label %60

58:                                               ; preds = %46
  call void @perror(ptr noundef @.str.7)
  %59 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %59, i32 noundef 1)
  br label %60

60:                                               ; preds = %58, %46
  %61 = load i64, ptr %11, align 8, !tbaa !13
  %62 = load i64, ptr %8, align 8, !tbaa !13
  %63 = add nsw i64 %62, %61
  store i64 %63, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %43, !llvm.loop !15

64:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.memset.p0.i64(ptr align 1 %12, i8 0, i64 4, i1 false)
  store i64 0, ptr %8, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %68, %64
  %66 = load i64, ptr %8, align 8, !tbaa !13
  %67 = icmp slt i64 %66, 4
  br i1 %67, label %68, label %79

68:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %71 = load i64, ptr %8, align 8, !tbaa !13
  %72 = sub nsw i64 4, %71
  %73 = call i64 @read(i32 noundef %69, ptr noundef %70, i64 noundef %72)
  %74 = trunc i64 %73 to i32
  store i32 %74, ptr %13, align 4, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = load i64, ptr %8, align 8, !tbaa !13
  %78 = add nsw i64 %77, %76
  store i64 %78, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %65, !llvm.loop !17

79:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %80 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %81 = load i8, ptr %80, align 1, !tbaa !18
  %82 = zext i8 %81 to i32
  %83 = shl i32 %82, 24
  %84 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  %85 = load i8, ptr %84, align 1, !tbaa !18
  %86 = zext i8 %85 to i32
  %87 = shl i32 %86, 16
  %88 = or i32 %83, %87
  %89 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  %90 = load i8, ptr %89, align 1, !tbaa !18
  %91 = zext i8 %90 to i32
  %92 = shl i32 %91, 8
  %93 = or i32 %88, %92
  %94 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  %95 = load i8, ptr %94, align 1, !tbaa !18
  %96 = zext i8 %95 to i32
  %97 = or i32 %93, %96
  store i32 %97, ptr %14, align 4, !tbaa !5
  %98 = load i32, ptr %14, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = icmp ne i32 %98, %99
  br i1 %100, label %101, label %103

101:                                              ; preds = %79
  call void @perror(ptr noundef @.str.8)
  %102 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %102, i32 noundef 1)
  br label %103

103:                                              ; preds = %101, %79
  br label %104

104:                                              ; preds = %139, %103
  %105 = load i8, ptr %10, align 1, !tbaa !11, !range !19, !noundef !20
  %106 = trunc i8 %105 to i1
  %107 = xor i1 %106, true
  br i1 %107, label %108, label %140

108:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 65536, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 0, ptr %16, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = getelementptr inbounds [65536 x i8], ptr %15, i64 0, i64 0
  %111 = call i64 @read(i32 noundef %109, ptr noundef %110, i64 noundef 65536)
  store i64 %111, ptr %17, align 8, !tbaa !13
  %112 = load i64, ptr %17, align 8, !tbaa !13
  switch i64 %112, label %116 [
    i64 -1, label %113
    i64 0, label %115
  ]

113:                                              ; preds = %108
  call void @perror(ptr noundef @.str.9)
  %114 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %114, i32 noundef 1)
  br label %115

115:                                              ; preds = %113, %108
  store i8 1, ptr %10, align 1, !tbaa !11
  br label %116

116:                                              ; preds = %115, %108
  br label %117

117:                                              ; preds = %132, %116
  %118 = load i64, ptr %17, align 8, !tbaa !13
  %119 = icmp sgt i64 %118, 0
  br i1 %119, label %120, label %139

120:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = load i64, ptr %16, align 8, !tbaa !13
  %123 = getelementptr inbounds [65536 x i8], ptr %15, i64 0, i64 %122
  %124 = load i64, ptr %17, align 8, !tbaa !13
  %125 = call i64 @write(i32 noundef %121, ptr noundef %123, i64 noundef %124)
  store i64 %125, ptr %18, align 8, !tbaa !13
  %126 = load i32, ptr %3, align 4, !tbaa !5
  %127 = call i32 @tcdrain(i32 noundef %126)
  %128 = load i64, ptr %18, align 8, !tbaa !13
  %129 = icmp eq i64 %128, -1
  br i1 %129, label %130, label %132

130:                                              ; preds = %120
  call void @perror(ptr noundef @.str.7)
  %131 = load i32, ptr %3, align 4, !tbaa !5
  call void @do_exit(i32 noundef %131, i32 noundef 1)
  br label %132

132:                                              ; preds = %130, %120
  %133 = load i64, ptr %18, align 8, !tbaa !13
  %134 = load i64, ptr %17, align 8, !tbaa !13
  %135 = sub nsw i64 %134, %133
  store i64 %135, ptr %17, align 8, !tbaa !13
  %136 = load i64, ptr %18, align 8, !tbaa !13
  %137 = load i64, ptr %16, align 8, !tbaa !13
  %138 = add nsw i64 %137, %136
  store i64 %138, ptr %16, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %117, !llvm.loop !21

139:                                              ; preds = %117
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 65536, ptr %15) #6
  br label %104, !llvm.loop !22

140:                                              ; preds = %104
  %141 = load ptr, ptr @stderr, align 8, !tbaa !9
  %142 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %141, ptr noundef @.str.10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret void
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__uint32_identity(i32 noundef) #4

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #2

declare i32 @tcdrain(i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 = { inlinehint 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!7, !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @do_exit(i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #2

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

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @send_kernel(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca [4 x i8], align 4
  %5 = alloca [65536 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %6 = tail call i32 (ptr, i32, ...) @open(ptr noundef %1, i32 noundef 0) #7
  %7 = icmp eq i32 %6, -1
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  tail call void @perror(ptr noundef %1) #8
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %9

9:                                                ; preds = %8, %2
  %10 = tail call i64 @lseek(i32 noundef %6, i64 noundef 0, i32 noundef 2) #7
  %11 = icmp sgt i64 %10, 2097152
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.5) #9
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %15

15:                                               ; preds = %12, %9
  %16 = trunc i64 %10 to i32
  %17 = tail call i32 @__uint32_identity(i32 noundef %16)
  store i32 %17, ptr %3, align 4, !tbaa !9
  %18 = tail call i64 @lseek(i32 noundef %6, i64 noundef 0, i32 noundef 0) #7
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %1, i64 noundef %10)
  br label %20

20:                                               ; preds = %15, %27
  %.045 = phi i64 [ 0, %15 ], [ %28, %27 ]
  %21 = getelementptr inbounds i8, ptr %3, i64 %.045
  %22 = sub nsw i64 4, %.045
  %23 = call i64 @write(i32 noundef %0, ptr noundef nonnull %21, i64 noundef %22) #7
  %24 = tail call i32 @tcdrain(i32 noundef %0) #7
  %25 = icmp eq i64 %23, -1
  br i1 %25, label %26, label %27

26:                                               ; preds = %20
  tail call void @perror(ptr noundef nonnull @.str.7) #8
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %27

27:                                               ; preds = %26, %20
  %28 = add nsw i64 %23, %.045
  %29 = icmp slt i64 %28, 4
  br i1 %29, label %20, label %30, !llvm.loop !11

30:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  store i32 0, ptr %4, align 4
  br label %31

31:                                               ; preds = %30, %31
  %.146 = phi i64 [ 0, %30 ], [ %35, %31 ]
  %32 = sub nsw i64 4, %.146
  %33 = call i64 @read(i32 noundef %0, ptr noundef nonnull %4, i64 noundef %32) #7
  %sext = shl i64 %33, 32
  %34 = ashr exact i64 %sext, 32
  %35 = add nsw i64 %34, %.146
  %36 = icmp slt i64 %35, 4
  br i1 %36, label %31, label %37, !llvm.loop !13

37:                                               ; preds = %31
  %38 = load i8, ptr %4, align 4, !tbaa !14
  %39 = zext i8 %38 to i32
  %40 = shl nuw i32 %39, 24
  %41 = getelementptr inbounds i8, ptr %4, i64 1
  %42 = load i8, ptr %41, align 1, !tbaa !14
  %43 = zext i8 %42 to i32
  %44 = shl nuw nsw i32 %43, 16
  %45 = or disjoint i32 %44, %40
  %46 = getelementptr inbounds i8, ptr %4, i64 2
  %47 = load i8, ptr %46, align 2, !tbaa !14
  %48 = zext i8 %47 to i32
  %49 = shl nuw nsw i32 %48, 8
  %50 = or disjoint i32 %45, %49
  %51 = getelementptr inbounds i8, ptr %4, i64 3
  %52 = load i8, ptr %51, align 1, !tbaa !14
  %53 = zext i8 %52 to i32
  %54 = or disjoint i32 %50, %53
  %.not = icmp eq i32 %54, %17
  br i1 %.not, label %.preheader, label %55

55:                                               ; preds = %37
  tail call void @perror(ptr noundef nonnull @.str.8) #8
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %.preheader

.preheader:                                       ; preds = %55, %37
  br label %56

56:                                               ; preds = %.preheader, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 65536, ptr nonnull %5) #7
  %57 = call i64 @read(i32 noundef %6, ptr noundef nonnull %5, i64 noundef 65536) #7
  switch i64 %57, label %61 [
    i64 -1, label %58
    i64 0, label %._crit_edge.thread
  ]

58:                                               ; preds = %56
  tail call void @perror(ptr noundef nonnull @.str.9) #8
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %56, %58
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %5) #7
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret void

61:                                               ; preds = %56
  %62 = icmp sgt i64 %57, 0
  br i1 %62, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %61, %68
  %.04148 = phi i64 [ %69, %68 ], [ %57, %61 ]
  %.04247 = phi i64 [ %70, %68 ], [ 0, %61 ]
  %63 = getelementptr inbounds [65536 x i8], ptr %5, i64 0, i64 %.04247
  %64 = call i64 @write(i32 noundef %0, ptr noundef nonnull %63, i64 noundef %.04148) #7
  %65 = tail call i32 @tcdrain(i32 noundef %0) #7
  %66 = icmp eq i64 %64, -1
  br i1 %66, label %67, label %68

67:                                               ; preds = %.lr.ph
  tail call void @perror(ptr noundef nonnull @.str.7) #8
  tail call void @do_exit(i32 noundef %0, i32 noundef 1)
  br label %68

68:                                               ; preds = %67, %.lr.ph
  %69 = sub nsw i64 %.04148, %64
  %70 = add nsw i64 %64, %.04247
  %71 = icmp sgt i64 %69, 0
  br i1 %71, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %68, %61
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %5) #7
  br label %56, !llvm.loop !16
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__uint32_identity(i32 noundef) local_unnamed_addr #5

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #2

declare i32 @tcdrain(i32 noundef) local_unnamed_addr #6

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree "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 "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 "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 = { inlinehint 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 #6 = { "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 #7 = { nounwind }
attributes #8 = { cold }
attributes #9 = { cold 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass