; 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.syscall_numbers = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }

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

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

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

declare ptr @ptrace_syscall_numbers(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @ptrace_socketcall(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) #2 {
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca [5 x i32], align 16
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i64 %1, ptr %11, align 8, !tbaa !9
  store i64 %2, ptr %12, align 8, !tbaa !9
  store i64 %3, ptr %13, align 8, !tbaa !9
  store i64 %4, ptr %14, align 8, !tbaa !9
  store i64 %5, ptr %15, align 8, !tbaa !9
  store i64 %6, ptr %16, align 8, !tbaa !9
  store i64 %7, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 20, ptr %18) #3
  %21 = load i64, ptr %13, align 8, !tbaa !9
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %18, align 4, !tbaa !11
  %23 = getelementptr inbounds i32, ptr %18, i64 1
  %24 = load i64, ptr %14, align 8, !tbaa !9
  %25 = trunc i64 %24 to i32
  store i32 %25, ptr %23, align 4, !tbaa !11
  %26 = getelementptr inbounds i32, ptr %18, i64 2
  %27 = load i64, ptr %15, align 8, !tbaa !9
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %26, align 4, !tbaa !11
  %29 = getelementptr inbounds i32, ptr %18, i64 3
  %30 = load i64, ptr %16, align 8, !tbaa !9
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr %29, align 4, !tbaa !11
  %32 = getelementptr inbounds i32, ptr %18, i64 4
  %33 = load i64, ptr %17, align 8, !tbaa !9
  %34 = trunc i64 %33 to i32
  store i32 %34, ptr %32, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = call i32 @ptrace_memcpy_to_child(ptr noundef %35, i64 noundef %36, ptr noundef %18, i64 noundef 20)
  store i32 %37, ptr %19, align 4, !tbaa !11
  %38 = load i32, ptr %19, align 4, !tbaa !11
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %8
  %41 = load i32, ptr %19, align 4, !tbaa !11
  %42 = sext i32 %41 to i64
  store i64 %42, ptr %9, align 8
  store i32 1, ptr %20, align 4
  br label %52

43:                                               ; preds = %8
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = call ptr @ptrace_syscall_numbers(ptr noundef %45)
  %47 = getelementptr inbounds %struct.syscall_numbers, ptr %46, i32 0, i32 19
  %48 = load i64, ptr %47, align 8, !tbaa !13
  %49 = load i64, ptr %12, align 8, !tbaa !9
  %50 = load i64, ptr %11, align 8, !tbaa !9
  %51 = call i64 @ptrace_remote_syscall(ptr noundef %44, i64 noundef %48, i64 noundef %49, i64 noundef %50, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0)
  store i64 %51, ptr %9, align 8
  store i32 1, ptr %20, align 4
  br label %52

52:                                               ; preds = %43, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 20, ptr %18) #3
  %53 = load i64, ptr %9, align 8
  ret i64 %53
}

declare i32 @ptrace_memcpy_to_child(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 152}
!14 = !{!"syscall_numbers", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152}


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

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

declare ptr @ptrace_syscall_numbers(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @ptrace_socketcall(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) local_unnamed_addr #2 {
  %9 = alloca [5 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %9) #3
  %10 = trunc i64 %3 to i32
  store i32 %10, ptr %9, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %9, i64 4
  %12 = trunc i64 %4 to i32
  store i32 %12, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %9, i64 8
  %14 = trunc i64 %5 to i32
  store i32 %14, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %9, i64 12
  %16 = trunc i64 %6 to i32
  store i32 %16, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %9, i64 16
  %18 = trunc i64 %7 to i32
  store i32 %18, ptr %17, align 16, !tbaa !5
  %19 = call i32 @ptrace_memcpy_to_child(ptr noundef %0, i64 noundef %1, ptr noundef nonnull %9, i64 noundef 20) #3
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %8
  %22 = sext i32 %19 to i64
  br label %28

23:                                               ; preds = %8
  %24 = call ptr @ptrace_syscall_numbers(ptr noundef %0) #3
  %25 = getelementptr inbounds i8, ptr %24, i64 152
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = call i64 @ptrace_remote_syscall(ptr noundef %0, i64 noundef %26, i64 noundef %2, i64 noundef %1, i64 noundef 0, i64 noundef 0, i64 noundef 0, i64 noundef 0) #3
  br label %28

28:                                               ; preds = %23, %21
  %.0 = phi i64 [ %22, %21 ], [ %27, %23 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %9) #3
  ret i64 %.0
}

declare i32 @ptrace_memcpy_to_child(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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, !11, i64 152}
!10 = !{!"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}
!11 = !{!"long", !7, i64 0}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass