; LLVM IR from nelhage/reptyr :: attach (steal_pty)

; 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.steal_pty_state = type { %struct.proc_stat, i32, i32, %struct.fd_array, [4096 x i8], %union.anon.0, i32, %struct.ptrace_child, i64, i32, i32 }
%struct.proc_stat = type { i32, [17 x i8], i8, i32, i32, i32, i64 }
%struct.fd_array = type { ptr, i32, i32 }
%union.anon.0 = type { %struct.sockaddr_un }
%struct.sockaddr_un = type { i16, [108 x i8] }
%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.syscall_numbers = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }

@.str.32 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [35 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
declare void @free(ptr noundef) #1

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

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

declare i32 @ptrace_restore_regs(ptr noundef) #2

declare i64 @ptrace_remote_syscall(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #2

declare ptr @ptrace_syscall_numbers(ptr noundef) #2

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

declare i32 @ptrace_detach_child(ptr noundef) #2

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

declare i32 @close(i32 noundef) #2

; Function Attrs: nounwind
declare i64 @sysconf(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @preflight_check(i32 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @do_unmap(ptr noundef, i64 noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @setup_steal_socket(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @setup_steal_socket_child(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @steal_child_pty(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @steal_block_hup(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @steal_cleanup_child(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @steal_pty(i32 noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.steal_pty_state, align 8
  %7 = 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) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4560, ptr %6) #5
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 4560, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %8 = call i64 @sysconf(i32 noundef 30) #5
  store i64 %8, ptr %7, align 8, !tbaa !11
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = call i32 @preflight_check(i32 noundef %9)
  store i32 %10, ptr %5, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %58

13:                                               ; preds = %2
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = call i32 @get_terminal_state(ptr noundef %6, i32 noundef %14)
  store i32 %15, ptr %5, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  br label %58

18:                                               ; preds = %13
  %19 = call i32 @setup_steal_socket(ptr noundef %6)
  store i32 %19, ptr %5, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %58

22:                                               ; preds = %18
  %23 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 5
  %24 = getelementptr inbounds %struct.sockaddr_un, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds [108 x i8], ptr %24, i64 0, i64 0
  call void (ptr, ...) @debug(ptr noundef @.str.32, ptr noundef %25)
  %26 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !13
  call void (ptr, ...) @debug(ptr noundef @.str.33, i32 noundef %27)
  %28 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %31 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 8
  %32 = call i32 @grab_pid(i32 noundef %29, ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %5, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %22
  br label %58

35:                                               ; preds = %22
  %36 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !13
  call void (ptr, ...) @debug(ptr noundef @.str.34, i32 noundef %37)
  %38 = call i32 @find_master_fd(ptr noundef %6)
  store i32 %38, ptr %5, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %35
  call void (ptr, ...) @error(ptr noundef @.str.35)
  br label %58

41:                                               ; preds = %35
  %42 = call i32 @setup_steal_socket_child(ptr noundef %6)
  store i32 %42, ptr %5, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %41
  br label %58

45:                                               ; preds = %41
  %46 = call i32 @steal_child_pty(ptr noundef %6)
  store i32 %46, ptr %5, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  br label %58

49:                                               ; preds = %45
  %50 = call i32 @steal_block_hup(ptr noundef %6)
  store i32 %50, ptr %5, align 4, !tbaa !5
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  br label %58

53:                                               ; preds = %49
  %54 = call i32 @steal_cleanup_child(ptr noundef %6)
  store i32 %54, ptr %5, align 4, !tbaa !5
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  br label %58

57:                                               ; preds = %53
  br label %101

58:                                               ; preds = %56, %52, %48, %44, %40, %34, %21, %17, %12
  %59 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 10
  %60 = load i32, ptr %59, align 4, !tbaa !20
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %67

62:                                               ; preds = %58
  %63 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 10
  %64 = load i32, ptr %63, align 4, !tbaa !20
  %65 = call i32 @close(i32 noundef %64)
  %66 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 10
  store i32 0, ptr %66, align 4, !tbaa !20
  br label %67

67:                                               ; preds = %62, %58
  %68 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 9
  %69 = load i32, ptr %68, align 8, !tbaa !21
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %71, label %81

71:                                               ; preds = %67
  %72 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %73 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %74 = call ptr @ptrace_syscall_numbers(ptr noundef %73)
  %75 = getelementptr inbounds %struct.syscall_numbers, ptr %74, i32 0, i32 12
  %76 = load i64, ptr %75, align 8, !tbaa !22
  %77 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 9
  %78 = load i32, ptr %77, align 8, !tbaa !21
  %79 = sext i32 %78 to i64
  %80 = call i64 @ptrace_remote_syscall(ptr noundef %72, i64 noundef %76, i64 noundef %79, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0)
  br label %81

81:                                               ; preds = %71, %67
  %82 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 8
  %83 = load i64, ptr %82, align 8, !tbaa !24
  %84 = icmp ugt i64 %83, 0
  br i1 %84, label %85, label %90

85:                                               ; preds = %81
  %86 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %87 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 8
  %88 = load i64, ptr %87, align 8, !tbaa !24
  %89 = load i64, ptr %7, align 8, !tbaa !11
  call void @do_unmap(ptr noundef %86, i64 noundef %88, i64 noundef %89)
  br label %90

90:                                               ; preds = %85, %81
  %91 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %92 = getelementptr inbounds %struct.ptrace_child, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !25
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %100

95:                                               ; preds = %90
  %96 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %97 = call i32 @ptrace_restore_regs(ptr noundef %96)
  %98 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 7
  %99 = call i32 @ptrace_detach_child(ptr noundef %98)
  br label %100

100:                                              ; preds = %95, %90
  br label %101

101:                                              ; preds = %100, %57
  %102 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 6
  %103 = load i32, ptr %102, align 8, !tbaa !26
  %104 = icmp sgt i32 %103, 0
  br i1 %104, label %105, label %113

105:                                              ; preds = %101
  %106 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 6
  %107 = load i32, ptr %106, align 8, !tbaa !26
  %108 = call i32 @close(i32 noundef %107)
  %109 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 5
  %110 = getelementptr inbounds %struct.sockaddr_un, ptr %109, i32 0, i32 1
  %111 = getelementptr inbounds [108 x i8], ptr %110, i64 0, i64 0
  %112 = call i32 @unlink(ptr noundef %111) #5
  br label %113

113:                                              ; preds = %105, %101
  %114 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 4
  %115 = getelementptr inbounds [4096 x i8], ptr %114, i64 0, i64 0
  %116 = load i8, ptr %115, align 8, !tbaa !27
  %117 = icmp ne i8 %116, 0
  br i1 %117, label %118, label %122

118:                                              ; preds = %113
  %119 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 4
  %120 = getelementptr inbounds [4096 x i8], ptr %119, i64 0, i64 0
  %121 = call i32 @rmdir(ptr noundef %120) #5
  br label %122

122:                                              ; preds = %118, %113
  %123 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 10
  %124 = load i32, ptr %123, align 4, !tbaa !20
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %130

126:                                              ; preds = %122
  %127 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 10
  %128 = load i32, ptr %127, align 4, !tbaa !20
  %129 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 %128, ptr %129, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %126, %122
  %131 = getelementptr inbounds %struct.steal_pty_state, ptr %6, i32 0, i32 3
  %132 = getelementptr inbounds %struct.fd_array, ptr %131, i32 0, i32 0
  %133 = load ptr, ptr %132, align 8, !tbaa !28
  call void @free(ptr noundef %133) #5
  %134 = load i32, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4560, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 %134
}

declare i32 @get_terminal_state(ptr noundef, i32 noundef) #2

declare i32 @find_master_fd(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @unlink(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @rmdir(ptr noundef) #1

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 = { "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 nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = { 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 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 48}
!14 = !{!"steal_pty_state", !15, i64 0, !6, i64 48, !6, i64 52, !16, i64 56, !7, i64 72, !7, i64 4168, !6, i64 4280, !17, i64 4288, !12, i64 4544, !6, i64 4552, !6, i64 4556}
!15 = !{!"proc_stat", !6, i64 0, !7, i64 4, !7, i64 21, !6, i64 24, !6, i64 28, !6, i64 32, !12, i64 40}
!16 = !{!"fd_array", !10, i64 0, !6, i64 8, !6, i64 12}
!17 = !{!"ptrace_child", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !12, i64 24, !12, i64 32, !18, i64 40}
!18 = !{!"user_regs_struct", !19, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !19, i64 32, !19, i64 40, !19, i64 48, !19, i64 56, !19, i64 64, !19, i64 72, !19, i64 80, !19, i64 88, !19, i64 96, !19, i64 104, !19, i64 112, !19, i64 120, !19, i64 128, !19, i64 136, !19, i64 144, !19, i64 152, !19, i64 160, !19, i64 168, !19, i64 176, !19, i64 184, !19, i64 192, !19, i64 200, !19, i64 208}
!19 = !{!"long long", !7, i64 0}
!20 = !{!14, !6, i64 4556}
!21 = !{!14, !6, i64 4552}
!22 = !{!23, !12, i64 96}
!23 = !{!"syscall_numbers", !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}
!24 = !{!14, !12, i64 4544}
!25 = !{!14, !6, i64 4292}
!26 = !{!14, !6, i64 4280}
!27 = !{!7, !7, i64 0}
!28 = !{!14, !10, i64 56}


; 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.steal_pty_state = type { %struct.proc_stat, i32, i32, %struct.fd_array, [4096 x i8], %union.anon.0, i32, %struct.ptrace_child, i64, i32, i32 }
%struct.proc_stat = type { i32, [17 x i8], i8, i32, i32, i32, i64 }
%struct.fd_array = type { ptr, i32, i32 }
%union.anon.0 = type { %struct.sockaddr_un }
%struct.sockaddr_un = type { i16, [108 x i8] }
%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 }

@.str.32 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [35 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

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

declare i32 @ptrace_restore_regs(ptr noundef) local_unnamed_addr #2

declare i64 @ptrace_remote_syscall(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare ptr @ptrace_syscall_numbers(ptr noundef) local_unnamed_addr #2

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

declare i32 @ptrace_detach_child(ptr noundef) local_unnamed_addr #2

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

declare i32 @close(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @grab_pid(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @preflight_check(i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @do_unmap(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #5

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @steal_pty(i32 noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #5 {
  %3 = alloca %struct.steal_pty_state, align 8
  call void @llvm.lifetime.start.p0(i64 4560, ptr nonnull %3) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(4560) %3, i8 0, i64 4560, i1 false)
  %4 = tail call i64 @sysconf(i32 noundef 30) #7
  %5 = tail call i32 @preflight_check(i32 noundef %0)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %30

6:                                                ; preds = %2
  %7 = call i32 @get_terminal_state(ptr noundef nonnull %3, i32 noundef %0) #7
  %.not18 = icmp eq i32 %7, 0
  br i1 %.not18, label %8, label %30

8:                                                ; preds = %6
  %9 = call i32 @setup_steal_socket(ptr noundef nonnull %3)
  %.not19 = icmp eq i32 %9, 0
  br i1 %.not19, label %10, label %30

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %3, i64 4170
  call void (ptr, ...) @debug(ptr noundef nonnull @.str.32, ptr noundef nonnull %11) #7
  %12 = getelementptr inbounds i8, ptr %3, i64 48
  %13 = load i32, ptr %12, align 8, !tbaa !5
  call void (ptr, ...) @debug(ptr noundef nonnull @.str.33, i32 noundef %13) #7
  %14 = load i32, ptr %12, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %3, i64 4288
  %16 = getelementptr inbounds i8, ptr %3, i64 4544
  %17 = call i32 @grab_pid(i32 noundef %14, ptr noundef nonnull %15, ptr noundef nonnull %16)
  %.not20 = icmp eq i32 %17, 0
  br i1 %.not20, label %18, label %30

18:                                               ; preds = %10
  %19 = load i32, ptr %12, align 8, !tbaa !5
  call void (ptr, ...) @debug(ptr noundef nonnull @.str.34, i32 noundef %19) #7
  %20 = call i32 @find_master_fd(ptr noundef nonnull %3) #7
  %.not21 = icmp eq i32 %20, 0
  br i1 %.not21, label %22, label %21

21:                                               ; preds = %18
  call void (ptr, ...) @error(ptr noundef nonnull @.str.35) #7
  br label %30

22:                                               ; preds = %18
  %23 = call i32 @setup_steal_socket_child(ptr noundef nonnull %3)
  %.not22 = icmp eq i32 %23, 0
  br i1 %.not22, label %24, label %30

24:                                               ; preds = %22
  %25 = call i32 @steal_child_pty(ptr noundef nonnull %3)
  %.not23 = icmp eq i32 %25, 0
  br i1 %.not23, label %26, label %30

26:                                               ; preds = %24
  %27 = call i32 @steal_block_hup(ptr noundef nonnull %3)
  %.not24 = icmp eq i32 %27, 0
  br i1 %.not24, label %28, label %30

28:                                               ; preds = %26
  %29 = call i32 @steal_cleanup_child(ptr noundef nonnull %3)
  %.not25 = icmp eq i32 %29, 0
  br i1 %.not25, label %59, label %30

30:                                               ; preds = %28, %26, %24, %22, %10, %8, %6, %2, %21
  %.0 = phi i32 [ %5, %2 ], [ %7, %6 ], [ %9, %8 ], [ %17, %10 ], [ %20, %21 ], [ %23, %22 ], [ %25, %24 ], [ %27, %26 ], [ %29, %28 ]
  %31 = getelementptr inbounds i8, ptr %3, i64 4556
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %.not26 = icmp eq i32 %32, 0
  br i1 %.not26, label %35, label %33

33:                                               ; preds = %30
  %34 = call i32 @close(i32 noundef %32) #7
  store i32 0, ptr %31, align 4, !tbaa !17
  br label %35

35:                                               ; preds = %33, %30
  %36 = getelementptr inbounds i8, ptr %3, i64 4552
  %37 = load i32, ptr %36, align 8, !tbaa !18
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %39, label %47

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %3, i64 4288
  %41 = call ptr @ptrace_syscall_numbers(ptr noundef nonnull %40) #7
  %42 = getelementptr inbounds i8, ptr %41, i64 96
  %43 = load i64, ptr %42, align 8, !tbaa !19
  %44 = load i32, ptr %36, align 8, !tbaa !18
  %45 = sext i32 %44 to i64
  %46 = call i64 @ptrace_remote_syscall(ptr noundef nonnull %40, i64 noundef %43, i64 noundef %45, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0) #7
  br label %47

47:                                               ; preds = %39, %35
  %48 = getelementptr inbounds i8, ptr %3, i64 4544
  %49 = load i64, ptr %48, align 8, !tbaa !21
  %.not27 = icmp eq i64 %49, 0
  br i1 %.not27, label %52, label %50

50:                                               ; preds = %47
  %51 = getelementptr inbounds i8, ptr %3, i64 4288
  call void @do_unmap(ptr noundef nonnull %51, i64 noundef %49, i64 noundef %4)
  br label %52

52:                                               ; preds = %50, %47
  %53 = getelementptr inbounds i8, ptr %3, i64 4292
  %54 = load i32, ptr %53, align 4, !tbaa !22
  %.not28 = icmp eq i32 %54, 0
  br i1 %.not28, label %59, label %55

55:                                               ; preds = %52
  %56 = getelementptr inbounds i8, ptr %3, i64 4288
  %57 = call i32 @ptrace_restore_regs(ptr noundef nonnull %56) #7
  %58 = call i32 @ptrace_detach_child(ptr noundef nonnull %56) #7
  br label %59

59:                                               ; preds = %52, %55, %28
  %.1 = phi i32 [ %.0, %55 ], [ %.0, %52 ], [ 0, %28 ]
  %60 = getelementptr inbounds i8, ptr %3, i64 4280
  %61 = load i32, ptr %60, align 8, !tbaa !23
  %62 = icmp sgt i32 %61, 0
  br i1 %62, label %63, label %67

63:                                               ; preds = %59
  %64 = call i32 @close(i32 noundef %61) #7
  %65 = getelementptr inbounds i8, ptr %3, i64 4170
  %66 = call i32 @unlink(ptr noundef nonnull %65) #7
  br label %67

67:                                               ; preds = %63, %59
  %68 = getelementptr inbounds i8, ptr %3, i64 72
  %69 = load i8, ptr %68, align 8, !tbaa !24
  %.not29 = icmp eq i8 %69, 0
  br i1 %.not29, label %72, label %70

70:                                               ; preds = %67
  %71 = call i32 @rmdir(ptr noundef nonnull %68) #7
  br label %72

72:                                               ; preds = %70, %67
  %73 = getelementptr inbounds i8, ptr %3, i64 4556
  %74 = load i32, ptr %73, align 4, !tbaa !17
  %.not30 = icmp eq i32 %74, 0
  br i1 %.not30, label %76, label %75

75:                                               ; preds = %72
  store i32 %74, ptr %1, align 4, !tbaa !25
  br label %76

76:                                               ; preds = %75, %72
  %77 = getelementptr inbounds i8, ptr %3, i64 56
  %78 = load ptr, ptr %77, align 8, !tbaa !26
  call void @free(ptr noundef %78) #7
  call void @llvm.lifetime.end.p0(i64 4560, ptr nonnull %3) #7
  ret i32 %.1
}

declare i32 @get_terminal_state(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @find_master_fd(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @unlink(ptr nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @rmdir(ptr nocapture noundef readonly) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 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 = { 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 #7 = { 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, !8, i64 48}
!6 = !{!"steal_pty_state", !7, i64 0, !8, i64 48, !8, i64 52, !12, i64 56, !9, i64 72, !9, i64 4168, !8, i64 4280, !14, i64 4288, !11, i64 4544, !8, i64 4552, !8, i64 4556}
!7 = !{!"proc_stat", !8, i64 0, !9, i64 4, !9, i64 21, !8, i64 24, !8, i64 28, !8, i64 32, !11, i64 40}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"fd_array", !13, i64 0, !8, i64 8, !8, i64 12}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"ptrace_child", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !11, i64 24, !11, i64 32, !15, i64 40}
!15 = !{!"user_regs_struct", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112, !16, i64 120, !16, i64 128, !16, i64 136, !16, i64 144, !16, i64 152, !16, i64 160, !16, i64 168, !16, i64 176, !16, i64 184, !16, i64 192, !16, i64 200, !16, i64 208}
!16 = !{!"long long", !9, i64 0}
!17 = !{!6, !8, i64 4556}
!18 = !{!6, !8, i64 4552}
!19 = !{!20, !11, i64 96}
!20 = !{!"syscall_numbers", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152}
!21 = !{!6, !11, i64 4544}
!22 = !{!6, !8, i64 4292}
!23 = !{!6, !8, i64 4280}
!24 = !{!9, !9, i64 0}
!25 = !{!8, !8, i64 0}
!26 = !{!6, !13, i64 56}


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