; LLVM IR from ekoontz/graphlab :: src/graphlab/logger/logger.ll (ZN11file_logger7_logbufEiPKcS1_iS1_i)

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.file_logger = type <{ %"class.std::basic_ofstream", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_stringstream", i32, i8, i8, [2 x i8], i32, [4 x i8] }>
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.0 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.0 = type { i64, [8 x i8] }
%"class.std::__cxx11::basic_stringstream" = type { %"class.std::basic_iostream.base", %"class.std::__cxx11::basic_stringbuf", %"class.std::basic_ios" }
%"class.std::basic_iostream.base" = type { %"class.std::basic_istream.base", %"class.std::basic_ostream.base" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }

@messages = external dso_local global [4 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str.10 = external hidden unnamed_addr constant [36 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind willreturn memory(read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11file_logger7_logbufEiPKcS1_iS1_i(ptr noundef nonnull align 8 dereferenceable(948) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i32 noundef %6) #4 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca [2048 x i8], align 16
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i32 %6, ptr %14, align 4, !tbaa !9
  %19 = load ptr, ptr %8, align 8
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = icmp sge i32 %20, 0
  br i1 %21, label %22, label %76

22:                                               ; preds = %7
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = icmp sle i32 %23, 3
  br i1 %24, label %25, label %76

25:                                               ; preds = %22
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = getelementptr inbounds %class.file_logger, ptr %19, i32 0, i32 7
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = icmp sge i32 %26, %28
  br i1 %29, label %30, label %76

30:                                               ; preds = %25
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call noundef ptr @strrchr(ptr noundef %31, i32 noundef 47) #5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  br label %38

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 -1
  br label %38

38:                                               ; preds = %35, %34
  %39 = phi ptr [ %32, %34 ], [ %37, %35 ]
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  store ptr %40, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [4 x ptr], ptr @messages, i64 0, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load i32, ptr %12, align 4, !tbaa !9
  %48 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef null, i64 noundef 0, ptr noundef @.str.8, ptr noundef %44, ptr noundef %45, ptr noundef %46, i32 noundef %47) #6
  %49 = sext i32 %48 to i64
  store i64 %49, ptr %15, align 8, !tbaa !29
  %50 = load i64, ptr %15, align 8, !tbaa !29
  %51 = icmp ugt i64 %50, 2047
  br i1 %51, label %52, label %54

52:                                               ; preds = %38
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef @.str.10)
  br label %75

54:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 2048, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store ptr @.str.9, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %55 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [4 x ptr], ptr @messages, i64 0, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %55, i64 noundef 2047, ptr noundef @.str.8, ptr noundef %59, ptr noundef %60, ptr noundef %61, i32 noundef %62) #6
  store i32 %63, ptr %18, align 4, !tbaa !9
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  %66 = load i32, ptr %18, align 4, !tbaa !9
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %19, i32 noundef %64, ptr noundef %65, i32 noundef %66)
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = load i32, ptr %14, align 4, !tbaa !9
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %19, i32 noundef %67, ptr noundef %68, i32 noundef %69)
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = call i64 @strlen(ptr noundef %72) #5
  %74 = trunc i64 %73 to i32
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %19, i32 noundef %70, ptr noundef %71, i32 noundef %74)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr %16) #6
  br label %75

75:                                               ; preds = %54, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %76

76:                                               ; preds = %75, %25, %22, %7
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948), i32 noundef, ptr noundef, i32 noundef) #4 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 "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 = { 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 944}
!12 = !{!"_ZTS11file_logger", !13, i64 0, !23, i64 512, !25, i64 544, !10, i64 936, !19, i64 940, !19, i64 941, !10, i64 944}
!13 = !{!"_ZTSSt14basic_ofstreamIcSt11char_traitsIcEE", !14, i64 0, !15, i64 8}
!14 = !{!"_ZTSSo"}
!15 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !16, i64 0, !7, i64 64, !18, i64 104, !20, i64 120, !21, i64 124, !21, i64 132, !21, i64 140, !6, i64 152, !22, i64 160, !19, i64 168, !19, i64 169, !19, i64 170, !7, i64 171, !6, i64 176, !6, i64 184, !19, i64 192, !6, i64 200, !6, i64 208, !22, i64 216, !6, i64 224, !6, i64 232}
!16 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !17, i64 56}
!17 = !{!"_ZTSSt6locale", !6, i64 0}
!18 = !{!"_ZTSSt12__basic_fileIcE", !6, i64 0, !19, i64 8}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSSt13_Ios_Openmode", !7, i64 0}
!21 = !{!"_ZTS11__mbstate_t", !10, i64 0, !7, i64 4}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !22, i64 8, !7, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!25 = !{!"_ZTSNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE", !26, i64 0, !28, i64 24}
!26 = !{!"_ZTSSd", !27, i64 0, !14, i64 16}
!27 = !{!"_ZTSSi", !22, i64 8}
!28 = !{!"_ZTSNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE", !16, i64 0, !20, i64 64, !23, i64 72}
!29 = !{!22, !22, 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@messages = external dso_local local_unnamed_addr global [4 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str.10 = external hidden unnamed_addr constant [36 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11file_logger7_logbufEiPKcS1_iS1_i(ptr noundef nonnull align 8 dereferenceable(948) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i32 noundef %6) local_unnamed_addr #4 align 2 {
  %8 = alloca [2048 x i8], align 16
  %or.cond = icmp ugt i32 %1, 3
  %9 = getelementptr inbounds i8, ptr %0, i64 944
  %10 = load i32, ptr %9, align 8
  %.not = icmp sgt i32 %10, %1
  %or.cond25 = select i1 %or.cond, i1 true, i1 %.not
  br i1 %or.cond25, label %28, label %11

11:                                               ; preds = %7
  %12 = tail call noundef ptr @strrchr(ptr noundef nonnull dereferenceable(1) %2, i32 noundef 47) #5
  %.not23 = icmp eq ptr %12, null
  %13 = getelementptr inbounds i8, ptr %2, i64 -1
  %14 = select i1 %.not23, ptr %13, ptr %12
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  %16 = zext nneg i32 %1 to i64
  %17 = getelementptr inbounds [4 x ptr], ptr @messages, i64 0, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef null, i64 noundef 0, ptr noundef nonnull @.str.8, ptr noundef %18, ptr noundef nonnull %15, ptr noundef %3, i32 noundef %4) #6
  %20 = icmp ugt i32 %19, 2047
  br i1 %20, label %21, label %23

21:                                               ; preds = %11
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef nonnull @.str.10)
  br label %28

23:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %8) #6
  %24 = load ptr, ptr %17, align 8, !tbaa !5
  %25 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %8, i64 noundef 2047, ptr noundef nonnull @.str.8, ptr noundef %24, ptr noundef nonnull %15, ptr noundef %3, i32 noundef %4) #6
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %0, i32 noundef %1, ptr noundef nonnull %8, i32 noundef %25)
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %0, i32 noundef %1, ptr noundef %5, i32 noundef %6)
  %26 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.9) #5
  %27 = trunc i64 %26 to i32
  call void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948) %0, i32 noundef %1, ptr noundef nonnull @.str.9, i32 noundef %27)
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %8) #6
  br label %28

28:                                               ; preds = %21, %23, %7
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11file_logger7_lograwEiPKci(ptr noundef nonnull align 8 dereferenceable(948), i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { 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 #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 = { 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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"}


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