; LLVM IR from DataDog/chaos-controller :: vendor/github.com/opencontainers/runc/libcontainer/userns (userns_maps)

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

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @bail(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: noreturn nounwind
declare void @exit(i32 noundef) #2

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

21:                                               ; preds = %4
  %22 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr %9) #6
  ret i32 %22

23:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 (ptr, i32, ...) @open(ptr noundef %24, i32 noundef 0)
  store i32 %25, ptr %11, align 4, !tbaa !9
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %23
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @bail(i32 noundef %29, ptr noundef @.str, ptr noundef %30)
  br label %31

31:                                               ; preds = %28, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = call i32 @setns(i32 noundef %32, i32 noundef 268435456) #6
  store i32 %33, ptr %12, align 4, !tbaa !9
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %31
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @bail(i32 noundef %37, ptr noundef @.str.1, ptr noundef %38)
  br label %39

39:                                               ; preds = %36, %31
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = call i32 @close(i32 noundef %40)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call i32 (ptr, i32, ...) @open(ptr noundef %42, i32 noundef 0)
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %39
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @bail(i32 noundef %47, ptr noundef @.str.2, ptr noundef %48, ptr noundef %49)
  br label %50

50:                                               ; preds = %46, %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %102, %50
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %54 = call i64 @read(i32 noundef %52, ptr noundef %53, i64 noundef 4096)
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %14, align 4, !tbaa !9
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %103

57:                                               ; preds = %51
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %57
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, ptr, ...) @bail(i32 noundef %61, ptr noundef @.str.3, ptr noundef %62, i32 noundef %63)
  br label %64

64:                                               ; preds = %60, %57
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = add nsw i32 %66, %65
  store i32 %67, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %90, %64
  %69 = load i32, ptr %16, align 4, !tbaa !9
  %70 = load i32, ptr %14, align 4, !tbaa !9
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %72, label %94

72:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %75 = load i32, ptr %14, align 4, !tbaa !9
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = sub nsw i32 %75, %76
  %78 = sext i32 %77 to i64
  %79 = call i64 @write(i32 noundef %73, ptr noundef %74, i64 noundef %78)
  %80 = trunc i64 %79 to i32
  store i32 %80, ptr %17, align 4, !tbaa !9
  %81 = load i32, ptr %17, align 4, !tbaa !9
  %82 = icmp slt i32 %81, 0
  br i1 %82, label %83, label %90

83:                                               ; preds = %72
  %84 = load i32, ptr %8, align 4, !tbaa !9
  %85 = load i32, ptr %14, align 4, !tbaa !9
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = sub nsw i32 %85, %86
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = load i32, ptr %16, align 4, !tbaa !9
  call void (i32, ptr, ...) @bail(i32 noundef %84, ptr noundef @.str.4, i32 noundef %87, ptr noundef %88, i32 noundef %89)
  br label %90

90:                                               ; preds = %83, %72
  %91 = load i32, ptr %17, align 4, !tbaa !9
  %92 = load i32, ptr %16, align 4, !tbaa !9
  %93 = add nsw i32 %92, %91
  store i32 %93, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %68, !llvm.loop !11

94:                                               ; preds = %68
  %95 = load i32, ptr %14, align 4, !tbaa !9
  %96 = load i32, ptr %16, align 4, !tbaa !9
  %97 = icmp ne i32 %95, %96
  br i1 %97, label %98, label %102

98:                                               ; preds = %94
  %99 = load i32, ptr %8, align 4, !tbaa !9
  %100 = load i32, ptr %14, align 4, !tbaa !9
  %101 = load i32, ptr %16, align 4, !tbaa !9
  call void (i32, ptr, ...) @bail(i32 noundef %99, ptr noundef @.str.5, i32 noundef %100, i32 noundef %101)
  br label %102

102:                                              ; preds = %98, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %51, !llvm.loop !13

103:                                              ; preds = %51
  %104 = load i32, ptr %13, align 4, !tbaa !9
  %105 = call i32 @close(i32 noundef %104)
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = call i32 @close(i32 noundef %106)
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = call i32 @close(i32 noundef %108)
  call void @exit(i32 noundef 0) #7
  unreachable
}

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

; Function Attrs: nounwind
declare i32 @fork() #4

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

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

declare i32 @close(i32 noundef) #5

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

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

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

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 = { noreturn 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 #3 = { 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 = { "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 = { nounwind }
attributes #7 = { noreturn 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}


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

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @bail(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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 1, 0) i32 @spawn_userns_cat(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca [4096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %5) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4096) %5, i8 0, i64 4096, i1 false)
  %6 = tail call i32 @fork() #8
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %5) #8
  ret i32 %6

8:                                                ; preds = %4
  %9 = tail call i32 (ptr, i32, ...) @open(ptr noundef %0, i32 noundef 0) #8
  %10 = icmp slt i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str, ptr noundef %0)
  br label %12

12:                                               ; preds = %11, %8
  %13 = tail call i32 @setns(i32 noundef %9, i32 noundef 268435456) #8
  %14 = icmp slt i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str.1, ptr noundef %0)
  br label %16

16:                                               ; preds = %15, %12
  %17 = tail call i32 @close(i32 noundef %9) #8
  %18 = tail call i32 (ptr, i32, ...) @open(ptr noundef %1, i32 noundef 0) #8
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %16
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str.2, ptr noundef %1, ptr noundef %0)
  br label %21

21:                                               ; preds = %20, %16
  %22 = call i64 @read(i32 noundef %18, ptr noundef nonnull %5, i64 noundef 4096) #8
  %23 = trunc i64 %22 to i32
  %.not4649 = icmp eq i32 %23, 0
  br i1 %.not4649, label %._crit_edge53, label %.lr.ph52

.lr.ph52:                                         ; preds = %21, %38
  %24 = phi i32 [ %40, %38 ], [ %23, %21 ]
  %.050 = phi i32 [ %36, %38 ], [ 0, %21 ]
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %26, label %.lr.ph

26:                                               ; preds = %.lr.ph52
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str.3, ptr noundef %1, i32 noundef %.050)
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph52, %33
  %.04348 = phi i32 [ %34, %33 ], [ 0, %.lr.ph52 ]
  %27 = sub nsw i32 %24, %.04348
  %28 = sext i32 %27 to i64
  %29 = call i64 @write(i32 noundef %2, ptr noundef nonnull %5, i64 noundef %28) #8
  %30 = trunc i64 %29 to i32
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %.lr.ph
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str.4, i32 noundef %27, ptr noundef %1, i32 noundef %.04348)
  br label %33

33:                                               ; preds = %32, %.lr.ph
  %34 = add nsw i32 %.04348, %30
  %35 = icmp slt i32 %34, %24
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %33, %26
  %.043.lcssa = phi i32 [ 0, %26 ], [ %34, %33 ]
  %36 = add nsw i32 %24, %.050
  %.not47 = icmp eq i32 %.043.lcssa, %24
  br i1 %.not47, label %38, label %37

37:                                               ; preds = %._crit_edge
  tail call void (i32, ptr, ...) @bail(i32 noundef %3, ptr noundef nonnull @.str.5, i32 noundef %24, i32 noundef %.043.lcssa)
  br label %38

38:                                               ; preds = %37, %._crit_edge
  %39 = call i64 @read(i32 noundef %18, ptr noundef nonnull %5, i64 noundef 4096) #8
  %40 = trunc i64 %39 to i32
  %.not46 = icmp eq i32 %40, 0
  br i1 %.not46, label %._crit_edge53, label %.lr.ph52, !llvm.loop !7

._crit_edge53:                                    ; preds = %38, %21
  %41 = tail call i32 @close(i32 noundef %18) #8
  %42 = tail call i32 @close(i32 noundef %2) #8
  %43 = tail call i32 @close(i32 noundef %3) #8
  tail call void @exit(i32 noundef 0) #9
  unreachable
}

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

; Function Attrs: nofree nounwind
declare i32 @fork() local_unnamed_addr #4

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

; Function Attrs: nounwind
declare i32 @setns(i32 noundef, i32 noundef) local_unnamed_addr #6

declare i32 @close(i32 noundef) local_unnamed_addr #7

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

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

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

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 = { noreturn 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #6 = { 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 = { "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 #8 = { nounwind }
attributes #9 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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