; LLVM IR from nelhage/reptyr :: platform/linux (linux)

; 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.proc_stat = type { i32, [17 x i8], i8, i32, i32, i32, i64 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%struct.fd_array = type { ptr, i32, i32 }
%struct.ptrace_child = type { i32, i32, i32, i32, i32, i64, i64, %struct.user_regs_struct }
%struct.user_regs_struct = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.dirent = type { i64, i64, i16, i8, [256 x i8] }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [40 x i8], align 1

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

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

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

; Function Attrs: noreturn
declare void @die(ptr noundef, ...) #3

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

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

declare void @error(ptr noundef, ...) #5

declare void @debug(ptr noundef, ...) #5

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #6

declare ptr @opendir(ptr noundef) #5

declare ptr @readdir(ptr noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #7

declare i32 @closedir(ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @get_child_tty_fds(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %struct.proc_stat, align 8
  %9 = alloca %struct.stat, align 8
  %10 = alloca %struct.stat, align 8
  %11 = alloca %struct.stat, align 8
  %12 = alloca [4096 x i8], align 16
  %13 = alloca %struct.fd_array, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %struct.stat, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 144, ptr %9) #9
  call void @llvm.lifetime.start.p0(i64 144, ptr %10) #9
  call void @llvm.lifetime.start.p0(i64 144, ptr %11) #9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %12) #9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #9
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  call void (ptr, ...) @debug(ptr noundef @.str.21)
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = call i32 @parse_proc_stat(i32 noundef %22, ptr noundef %8)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ptrace_child, ptr %24, i32 0, i32 4
  store i32 %23, ptr %25, align 8, !tbaa !11
  %26 = icmp ne i32 %23, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %150

28:                                               ; preds = %3
  %29 = getelementptr inbounds %struct.proc_stat, ptr %8, i32 0, i32 6
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = trunc i64 %30 to i32
  call void (ptr, ...) @debug(ptr noundef @.str.22, i32 noundef %31)
  %32 = call i32 @stat(ptr noundef @.str.23, ptr noundef %9) #9
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %45

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  %35 = call ptr @__errno_location() #10
  %36 = load i32, ptr %35, align 4, !tbaa !9
  store i32 %36, ptr %17, align 4, !tbaa !9
  %37 = load i32, ptr %17, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  call void (ptr, ...) @die(ptr noundef @.str, ptr noundef @.str.1) #11
  unreachable

40:                                               ; preds = %34
  %41 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %41, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  %42 = load i32, ptr %18, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ptrace_child, ptr %43, i32 0, i32 4
  store i32 %42, ptr %44, align 8, !tbaa !11
  call void (ptr, ...) @error(ptr noundef @.str.24)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %150

45:                                               ; preds = %28
  %46 = call i32 @stat(ptr noundef @.str.25, ptr noundef %10) #9
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %64

48:                                               ; preds = %45
  call void (ptr, ...) @error(ptr noundef @.str.26)
  call void @llvm.memset.p0.i64(ptr align 8 %19, i8 0, i64 144, i1 false)
  %49 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 0
  %50 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 1
  %51 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 2
  %52 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 3
  %53 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 4
  %54 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 5
  %55 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 6
  %56 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 7
  store i64 -1, ptr %56, align 8, !tbaa !18
  %57 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 8
  %58 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 9
  %59 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 10
  %60 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 11
  %61 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 12
  %62 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 13
  %63 = getelementptr inbounds %struct.stat, ptr %19, i32 0, i32 14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %19, i64 144, i1 false), !tbaa.struct !21
  br label %64

64:                                               ; preds = %48, %45
  %65 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.ptrace_child, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !24
  %69 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %65, i64 noundef 4096, ptr noundef @.str.27, i32 noundef %68) #9
  %70 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %71 = call ptr @opendir(ptr noundef %70)
  store ptr %71, ptr %14, align 8, !tbaa !5
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %64
  store ptr null, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %150

74:                                               ; preds = %64
  br label %75

75:                                               ; preds = %140, %99, %86, %74
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = call ptr @readdir(ptr noundef %76)
  store ptr %77, ptr %15, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %141

79:                                               ; preds = %75
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.dirent, ptr %80, i32 0, i32 4
  %82 = getelementptr inbounds [256 x i8], ptr %81, i64 0, i64 0
  %83 = load i8, ptr %82, align 1, !tbaa !23
  %84 = sext i8 %83 to i32
  %85 = icmp eq i32 %84, 46
  br i1 %85, label %86, label %87

86:                                               ; preds = %79
  br label %75, !llvm.loop !25

87:                                               ; preds = %79
  %88 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ptrace_child, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !24
  %92 = load ptr, ptr %15, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.dirent, ptr %92, i32 0, i32 4
  %94 = getelementptr inbounds [256 x i8], ptr %93, i64 0, i64 0
  %95 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %88, i64 noundef 4096, ptr noundef @.str.28, i32 noundef %91, ptr noundef %94) #9
  %96 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %97 = call i32 @stat(ptr noundef %96, ptr noundef %11) #9
  %98 = icmp slt i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %87
  br label %75, !llvm.loop !25

100:                                              ; preds = %87
  %101 = getelementptr inbounds %struct.stat, ptr %11, i32 0, i32 7
  %102 = load i64, ptr %101, align 8, !tbaa !18
  %103 = getelementptr inbounds %struct.proc_stat, ptr %8, i32 0, i32 6
  %104 = load i64, ptr %103, align 8, !tbaa !16
  %105 = icmp eq i64 %102, %104
  br i1 %105, label %118, label %106

106:                                              ; preds = %100
  %107 = getelementptr inbounds %struct.stat, ptr %11, i32 0, i32 7
  %108 = load i64, ptr %107, align 8, !tbaa !18
  %109 = getelementptr inbounds %struct.stat, ptr %9, i32 0, i32 7
  %110 = load i64, ptr %109, align 8, !tbaa !18
  %111 = icmp eq i64 %108, %110
  br i1 %111, label %118, label %112

112:                                              ; preds = %106
  %113 = getelementptr inbounds %struct.stat, ptr %11, i32 0, i32 7
  %114 = load i64, ptr %113, align 8, !tbaa !18
  %115 = getelementptr inbounds %struct.stat, ptr %10, i32 0, i32 7
  %116 = load i64, ptr %115, align 8, !tbaa !18
  %117 = icmp eq i64 %114, %116
  br i1 %117, label %118, label %140

118:                                              ; preds = %112, %106, %100
  %119 = load ptr, ptr %15, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.dirent, ptr %119, i32 0, i32 4
  %121 = getelementptr inbounds [256 x i8], ptr %120, i64 0, i64 0
  call void (ptr, ...) @debug(ptr noundef @.str.29, ptr noundef %121)
  %122 = load ptr, ptr %15, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.dirent, ptr %122, i32 0, i32 4
  %124 = getelementptr inbounds [256 x i8], ptr %123, i64 0, i64 0
  %125 = call i32 @atoi(ptr noundef %124) #12
  %126 = call i32 @fd_array_push(ptr noundef %13, i32 noundef %125)
  %127 = icmp ne i32 %126, 0
  br i1 %127, label %128, label %139

128:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #9
  %129 = call ptr @__errno_location() #10
  %130 = load i32, ptr %129, align 4, !tbaa !9
  store i32 %130, ptr %20, align 4, !tbaa !9
  %131 = load i32, ptr %20, align 4, !tbaa !9
  %132 = icmp eq i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %128
  call void (ptr, ...) @die(ptr noundef @.str, ptr noundef @.str.1) #11
  unreachable

134:                                              ; preds = %128
  %135 = load i32, ptr %20, align 4, !tbaa !9
  store i32 %135, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #9
  %136 = load i32, ptr %21, align 4, !tbaa !9
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.ptrace_child, ptr %137, i32 0, i32 4
  store i32 %136, ptr %138, align 8, !tbaa !11
  call void (ptr, ...) @error(ptr noundef @.str.30)
  br label %142

139:                                              ; preds = %118
  br label %140

140:                                              ; preds = %139, %112
  br label %75, !llvm.loop !25

141:                                              ; preds = %75
  br label %142

142:                                              ; preds = %141, %134
  %143 = getelementptr inbounds %struct.fd_array, ptr %13, i32 0, i32 1
  %144 = load i32, ptr %143, align 8, !tbaa !27
  %145 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %144, ptr %145, align 4, !tbaa !9
  %146 = load ptr, ptr %14, align 8, !tbaa !5
  %147 = call i32 @closedir(ptr noundef %146)
  %148 = getelementptr inbounds %struct.fd_array, ptr %13, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8, !tbaa !29
  store ptr %149, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %150

150:                                              ; preds = %142, %73, %40, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4096, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 144, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 144, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 144, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #9
  %151 = load ptr, ptr %4, align 8
  ret ptr %151
}

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

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

declare i32 @fd_array_push(ptr noundef, i32 noundef) #5

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 = { 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 = { noreturn "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 = { "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 = { inlinehint nounwind willreturn memory(read) 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(none) }
attributes #11 = { noreturn }
attributes #12 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"ptrace_child", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 24, !13, i64 32, !14, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!"user_regs_struct", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208}
!15 = !{!"long long", !7, i64 0}
!16 = !{!17, !13, i64 40}
!17 = !{!"proc_stat", !10, i64 0, !7, i64 4, !7, i64 21, !10, i64 24, !10, i64 28, !10, i64 32, !13, i64 40}
!18 = !{!19, !13, i64 40}
!19 = !{!"stat", !13, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !20, i64 72, !20, i64 88, !20, i64 104, !7, i64 120}
!20 = !{!"timespec", !13, i64 0, !13, i64 8}
!21 = !{i64 0, i64 8, !22, i64 8, i64 8, !22, i64 16, i64 8, !22, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !9, i64 36, i64 4, !9, i64 40, i64 8, !22, i64 48, i64 8, !22, i64 56, i64 8, !22, i64 64, i64 8, !22, i64 72, i64 8, !22, i64 80, i64 8, !22, i64 88, i64 8, !22, i64 96, i64 8, !22, i64 104, i64 8, !22, i64 112, i64 8, !22, i64 120, i64 24, !23}
!22 = !{!13, !13, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!12, !10, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !10, i64 8}
!28 = !{!"fd_array", !6, i64 0, !10, i64 8, !10, i64 12}
!29 = !{!28, !6, 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"

%struct.proc_stat = type { i32, [17 x i8], i8, i32, i32, i32, i64 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%struct.fd_array = type { ptr, i32, i32 }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @parse_proc_stat(i32 noundef, ptr 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: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

; Function Attrs: noreturn
declare void @die(ptr noundef, ...) 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: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

declare void @error(ptr noundef, ...) local_unnamed_addr #5

declare void @debug(ptr noundef, ...) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noalias noundef ptr @opendir(ptr nocapture noundef readonly) local_unnamed_addr #4

declare ptr @readdir(ptr noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @closedir(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local ptr @get_child_tty_fds(ptr nocapture noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = alloca %struct.proc_stat, align 8
  %5 = alloca %struct.stat, align 8
  %6 = alloca %struct.stat, align 8
  %7 = alloca %struct.stat, align 8
  %8 = alloca [4096 x i8], align 16
  %9 = alloca %struct.fd_array, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %8) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  tail call void (ptr, ...) @debug(ptr noundef nonnull @.str.21) #8
  %10 = call i32 @parse_proc_stat(i32 noundef %1, ptr noundef nonnull %4)
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %10, ptr %11, align 8, !tbaa !5
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %12, label %69

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %4, i64 40
  %14 = load i64, ptr %13, align 8, !tbaa !13
  %15 = trunc i64 %14 to i32
  call void (ptr, ...) @debug(ptr noundef nonnull @.str.22, i32 noundef %15) #8
  %16 = call i32 @stat(ptr noundef nonnull @.str.23, ptr noundef nonnull %5) #8
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %18, label %24

18:                                               ; preds = %12
  %19 = tail call ptr @__errno_location() #9
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  call void (ptr, ...) @die(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #10
  unreachable

23:                                               ; preds = %18
  store i32 %20, ptr %11, align 8, !tbaa !5
  call void (ptr, ...) @error(ptr noundef nonnull @.str.24) #8
  br label %69

24:                                               ; preds = %12
  %25 = call i32 @stat(ptr noundef nonnull @.str.25, ptr noundef nonnull %6) #8
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  call void (ptr, ...) @error(ptr noundef nonnull @.str.26) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %6, i8 0, i64 40, i1 false)
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 48
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %.sroa.3.0..sroa_idx, i8 0, i64 96, i1 false)
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 40
  store i64 -1, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !16
  br label %28

28:                                               ; preds = %27, %24
  %29 = load i32, ptr %0, align 8, !tbaa !17
  %30 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %8, i64 noundef 4096, ptr noundef nonnull @.str.27, i32 noundef %29) #8
  %31 = call ptr @opendir(ptr noundef nonnull %8)
  %32 = icmp eq ptr %31, null
  br i1 %32, label %69, label %.preheader

.preheader:                                       ; preds = %28
  %33 = call ptr @readdir(ptr noundef nonnull %31) #8
  %.not2330 = icmp eq ptr %33, null
  br i1 %.not2330, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %34 = getelementptr inbounds i8, ptr %7, i64 40
  %35 = getelementptr inbounds i8, ptr %5, i64 40
  %36 = getelementptr inbounds i8, ptr %6, i64 40
  br label %37

37:                                               ; preds = %.lr.ph, %.backedge
  %38 = phi ptr [ %33, %.lr.ph ], [ %64, %.backedge ]
  %39 = getelementptr inbounds i8, ptr %38, i64 19
  %40 = load i8, ptr %39, align 1, !tbaa !18
  %41 = icmp eq i8 %40, 46
  br i1 %41, label %.backedge, label %42

42:                                               ; preds = %37
  %43 = load i32, ptr %0, align 8, !tbaa !17
  %44 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %8, i64 noundef 4096, ptr noundef nonnull @.str.28, i32 noundef %43, ptr noundef nonnull %39) #8
  %45 = call i32 @stat(ptr noundef nonnull %8, ptr noundef nonnull %7) #8
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %.backedge, label %47

47:                                               ; preds = %42
  %48 = load i64, ptr %34, align 8, !tbaa !19
  %49 = load i64, ptr %13, align 8, !tbaa !13
  %50 = icmp eq i64 %48, %49
  %51 = load i64, ptr %35, align 8
  %52 = icmp eq i64 %48, %51
  %or.cond = select i1 %50, i1 true, i1 %52
  %53 = load i64, ptr %36, align 8
  %54 = icmp eq i64 %48, %53
  %or.cond29 = select i1 %or.cond, i1 true, i1 %54
  br i1 %or.cond29, label %55, label %.backedge

55:                                               ; preds = %47
  call void (ptr, ...) @debug(ptr noundef nonnull @.str.29, ptr noundef nonnull %39) #8
  %56 = call i32 @atoi(ptr nocapture noundef %39) #11
  %57 = call i32 @fd_array_push(ptr noundef nonnull %9, i32 noundef %56) #8
  %.not24 = icmp eq i32 %57, 0
  br i1 %.not24, label %.backedge, label %58

58:                                               ; preds = %55
  %59 = tail call ptr @__errno_location() #9
  %60 = load i32, ptr %59, align 4, !tbaa !15
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  call void (ptr, ...) @die(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #10
  unreachable

63:                                               ; preds = %58
  store i32 %60, ptr %11, align 8, !tbaa !5
  call void (ptr, ...) @error(ptr noundef nonnull @.str.30) #8
  br label %.loopexit

.backedge:                                        ; preds = %55, %47, %37, %42
  %64 = call ptr @readdir(ptr noundef nonnull %31) #8
  %.not23 = icmp eq ptr %64, null
  br i1 %.not23, label %.loopexit, label %37, !llvm.loop !22

.loopexit:                                        ; preds = %.backedge, %.preheader, %63
  %65 = getelementptr inbounds i8, ptr %9, i64 8
  %66 = load i32, ptr %65, align 8, !tbaa !24
  store i32 %66, ptr %2, align 4, !tbaa !15
  %67 = call i32 @closedir(ptr noundef nonnull %31)
  %68 = load ptr, ptr %9, align 8, !tbaa !27
  br label %69

69:                                               ; preds = %28, %3, %.loopexit, %23
  %.0 = phi ptr [ null, %23 ], [ %68, %.loopexit ], [ null, %3 ], [ null, %28 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #8
  ret ptr %.0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #4

declare i32 @fd_array_push(ptr noundef, i32 noundef) local_unnamed_addr #5

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 = { 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 = { noreturn "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 = { 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 #5 = { "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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #7 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { noreturn nounwind }
attributes #11 = { 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, !7, i64 16}
!6 = !{!"ptrace_child", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32, !11, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"user_regs_struct", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208}
!12 = !{!"long long", !8, i64 0}
!13 = !{!14, !10, i64 40}
!14 = !{!"proc_stat", !7, i64 0, !8, i64 4, !8, i64 21, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{!6, !7, i64 0}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !10, i64 40}
!20 = !{!"stat", !10, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !21, i64 72, !21, i64 88, !21, i64 104, !8, i64 120}
!21 = !{!"timespec", !10, i64 0, !10, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!25, !7, i64 8}
!25 = !{!"fd_array", !26, i64 0, !7, i64 8, !7, i64 12}
!26 = !{!"any pointer", !8, i64 0}
!27 = !{!25, !26, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass