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

; 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 = type { i8 }
%class.anon.5 = type { i8 }
%class.anon.7 = 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

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

14:                                               ; preds = %3
  br label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  call void @"_ZZN8graphlab7process15read_from_childEPvmENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) %7)
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16, %3
  %18 = getelementptr inbounds %"class.graphlab::process", ptr %10, i32 0, i32 3
  %19 = load i8, ptr %18, align 1, !tbaa !17, !range !15, !noundef !16
  %20 = trunc i8 %19 to i1
  br i1 %20, label %24, label %21

21:                                               ; preds = %17
  br label %22

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  call void @"_ZZN8graphlab7process15read_from_childEPvmENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1) %8)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23, %17
  %25 = getelementptr inbounds %"class.graphlab::process", ptr %10, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !18
  %27 = icmp eq i32 %26, -1
  br i1 %27, label %28, label %31

28:                                               ; preds = %24
  br label %29

29:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  call void @"_ZZN8graphlab7process15read_from_childEPvmENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1) %9)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30, %24
  %32 = getelementptr inbounds %"class.graphlab::process", ptr %10, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = call i64 @read(i32 noundef %33, ptr noundef %34, i64 noundef %35)
  ret i64 %36
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTSN8graphlab7processE", !13, i64 0, !13, i64 4, !14, i64 8, !14, i64 9}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !14, i64 9}
!18 = !{!12, !13, 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 = type { i8 }
%class.anon.5 = type { i8 }
%class.anon.7 = 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

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

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

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

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #4
  call void @"_ZZN8graphlab7process15read_from_childEPvmENK3$_1clEv"(ptr noundef nonnull align 1 dereferenceable(1) %5)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #4
  br label %16

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

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #4
  call void @"_ZZN8graphlab7process15read_from_childEPvmENK3$_2clEv"(ptr noundef nonnull align 1 dereferenceable(1) %6)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #4
  %.pre = load i32, ptr %0, align 4, !tbaa !14
  br label %20

20:                                               ; preds = %19, %16
  %21 = phi i32 [ %.pre, %19 ], [ %17, %16 ]
  %22 = call i64 @read(i32 noundef %21, ptr noundef %1, i64 noundef %2)
  ret i64 %22
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass