; LLVM IR from turi-code/SFrame :: oss_src/process/process_unix.ll (ZN8graphlab7process15close_read_pipeEv)

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

%class.anon.13 = type { i8 }
%class.anon.15 = type { i8 }
%class.anon.17 = type { i8 }
%"class.graphlab::process" = type <{ i32, i32, i8, i8, [2 x i8] }>

; 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 i32 @close(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8graphlab7process15close_read_pipeEv(ptr noundef nonnull align 4 dereferenceable(10) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %class.anon.13, align 1
  %4 = alloca %class.anon.15, align 1
  %5 = alloca %class.anon.17, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 2
  %8 = load i8, ptr %7, align 4, !tbaa !9, !range !13, !noundef !14
  %9 = trunc i8 %8 to i1
  br i1 %9, label %13, label %10

10:                                               ; preds = %1
  br label %11

11:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %3)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12, %1
  %14 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 3
  %15 = load i8, ptr %14, align 1, !tbaa !15, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %20, label %17

17:                                               ; preds = %13
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19, %13
  %21 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !16
  %23 = icmp eq i32 %22, -1
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1) %5)
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26, %20
  %28 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 0
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = icmp sgt i32 %29, -1
  br i1 %30, label %31, label %36

31:                                               ; preds = %27
  %32 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = call i32 @close(i32 noundef %33)
  %35 = getelementptr inbounds %"class.graphlab::process", ptr %6, i32 0, i32 0
  store i32 -1, ptr %35, align 4, !tbaa !16
  br label %36

36:                                               ; preds = %31, %27
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

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 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { 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++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"_ZTSN8graphlab7processE", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !12, i64 9}
!16 = !{!10, !11, 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"

%class.anon.13 = type { i8 }
%class.anon.15 = type { i8 }
%class.anon.17 = type { i8 }

; 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 i32 @close(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8graphlab7process15close_read_pipeEv(ptr nocapture noundef nonnull align 4 dereferenceable(10) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %class.anon.13, align 1
  %3 = alloca %class.anon.15, align 1
  %4 = alloca %class.anon.17, align 1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %2)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  br label %9

9:                                                ; preds = %8, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 9
  %11 = load i8, ptr %10, align 1, !tbaa !13, !range !11, !noundef !12
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1) %3)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  br label %14

14:                                               ; preds = %13, %9
  %15 = load i32, ptr %0, align 4, !tbaa !14
  %16 = icmp eq i32 %15, -1
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  call void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  %.pr = load i32, ptr %0, align 4, !tbaa !14
  br label %18

18:                                               ; preds = %17, %14
  %19 = phi i32 [ %.pr, %17 ], [ %15, %14 ]
  %20 = icmp sgt i32 %19, -1
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call i32 @close(i32 noundef %19)
  store i32 -1, ptr %0, align 4, !tbaa !14
  br label %23

23:                                               ; preds = %21, %18
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8graphlab7process15close_read_pipeEvENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

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 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { 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, !10, i64 8}
!6 = !{!"_ZTSN8graphlab7processE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 9}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !10, i64 9}
!14 = !{!6, !7, i64 0}


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