; LLVM IR from BlueBrain/CoreNeuron :: coreneuron/utils/progressbar/progressbar.ll (Z27progressbar_new_with_formatPKcmS0_)

; 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.progressbar = type { i64, i64, i64, i64, i64, i64, i64, ptr, double, %struct.anon }
%struct.anon = type { i8, i8, i8 }

@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._Z27progressbar_new_with_formatPKcmS0_ = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z27progressbar_new_with_formatPKcmS0_(ptr noundef %0, i64 noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %10 = call noalias ptr @malloc(i64 noundef 80) #9
  store ptr %10, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %8, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %74

14:                                               ; preds = %3
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.progressbar, ptr %16, i32 0, i32 0
  store i64 %15, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.progressbar, ptr %18, i32 0, i32 1
  store i64 0, ptr %19, align 8, !tbaa !15
  %20 = call i32 @isatty(i32 noundef 1) #8
  %21 = icmp ne i32 %20, 0
  %22 = zext i1 %21 to i64
  %23 = select i1 %21, i32 1, i32 5
  %24 = zext i32 %23 to i64
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.progressbar, ptr %25, i32 0, i32 3
  store i64 %24, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.progressbar, ptr %27, i32 0, i32 8
  store double 0.000000e+00, ptr %28, align 8, !tbaa !17
  %29 = call i64 @time(ptr noundef null) #8
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.progressbar, ptr %30, i32 0, i32 5
  store i64 %29, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call i64 @strlen(ptr noundef %32) #10
  %34 = icmp eq i64 3, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %14
  br label %36

36:                                               ; preds = %35, %14
  %37 = phi i1 [ false, %14 ], [ true, %35 ]
  br i1 %37, label %38, label %39

38:                                               ; preds = %36
  br label %41

39:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 72, ptr noundef @__PRETTY_FUNCTION__._Z27progressbar_new_with_formatPKcmS0_) #11
  unreachable

40:                                               ; No predecessors!
  br label %41

41:                                               ; preds = %40, %38
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 0
  %44 = load i8, ptr %43, align 1, !tbaa !19
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.progressbar, ptr %45, i32 0, i32 9
  %47 = getelementptr inbounds %struct.anon, ptr %46, i32 0, i32 0
  store i8 %44, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 1
  %50 = load i8, ptr %49, align 1, !tbaa !19
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.progressbar, ptr %51, i32 0, i32 9
  %53 = getelementptr inbounds %struct.anon, ptr %52, i32 0, i32 1
  store i8 %50, ptr %53, align 1, !tbaa !21
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 2
  %56 = load i8, ptr %55, align 1, !tbaa !19
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.progressbar, ptr %57, i32 0, i32 9
  %59 = getelementptr inbounds %struct.anon, ptr %58, i32 0, i32 2
  store i8 %56, ptr %59, align 2, !tbaa !22
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_Z24progressbar_update_labelP11progressbarPKc(ptr noundef %60, ptr noundef %61)
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZL16progressbar_drawPK11progressbar(ptr noundef %62)
  %63 = call i64 @time(ptr noundef null) #8
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.progressbar, ptr %64, i32 0, i32 5
  %66 = load i64, ptr %65, align 8, !tbaa !18
  %67 = call double @difftime(i64 noundef %63, i64 noundef %66) #12
  %68 = fptosi double %67 to i64
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.progressbar, ptr %69, i32 0, i32 6
  store i64 %68, ptr %70, align 8, !tbaa !23
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.progressbar, ptr %71, i32 0, i32 4
  store i64 1, ptr %72, align 8, !tbaa !24
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %73, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %74

74:                                               ; preds = %41, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  %75 = load ptr, ptr %4, align 8
  ret ptr %75
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z24progressbar_update_labelP11progressbarPKc(ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL16progressbar_drawPK11progressbar(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(none)
declare double @difftime(i64 noundef, i64 noundef) #7

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

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

!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, !10, i64 0}
!12 = !{!"_ZTS11progressbar", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !13, i64 64, !14, i64 72}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTSN11progressbarUt_E", !7, i64 0, !7, i64 1, !7, i64 2}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 24}
!17 = !{!12, !13, i64 64}
!18 = !{!12, !10, i64 40}
!19 = !{!7, !7, i64 0}
!20 = !{!12, !7, i64 72}
!21 = !{!12, !7, i64 73}
!22 = !{!12, !7, i64 74}
!23 = !{!12, !10, i64 48}
!24 = !{!12, !10, i64 32}


; 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.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._Z27progressbar_new_with_formatPKcmS0_ = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z27progressbar_new_with_formatPKcmS0_(ptr noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(80) ptr @malloc(i64 noundef 80) #7
  %5 = icmp eq ptr %4, null
  br i1 %5, label %32, label %6

6:                                                ; preds = %3
  store i64 %1, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 0, ptr %7, align 8, !tbaa !13
  %8 = tail call i32 @isatty(i32 noundef 1) #8
  %.not = icmp eq i32 %8, 0
  %9 = select i1 %.not, i64 5, i64 1
  %10 = getelementptr inbounds i8, ptr %4, i64 24
  store i64 %9, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %4, i64 64
  store double 0.000000e+00, ptr %11, align 8, !tbaa !15
  %12 = tail call i64 @time(ptr noundef null) #8
  %13 = getelementptr inbounds i8, ptr %4, i64 40
  store i64 %12, ptr %13, align 8, !tbaa !16
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #9
  %15 = icmp eq i64 %14, 3
  br i1 %15, label %17, label %16

16:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 72, ptr noundef nonnull @__PRETTY_FUNCTION__._Z27progressbar_new_with_formatPKcmS0_) #10
  unreachable

17:                                               ; preds = %6
  %18 = load i8, ptr %2, align 1, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %4, i64 72
  store i8 %18, ptr %19, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %2, i64 1
  %21 = load i8, ptr %20, align 1, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %4, i64 73
  store i8 %21, ptr %22, align 1, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %2, i64 2
  %24 = load i8, ptr %23, align 1, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %4, i64 74
  store i8 %24, ptr %25, align 2, !tbaa !20
  tail call void @_Z24progressbar_update_labelP11progressbarPKc(ptr noundef nonnull %4, ptr noundef %0)
  tail call void @_ZL16progressbar_drawPK11progressbar(ptr noundef nonnull %4)
  %26 = tail call i64 @time(ptr noundef null) #8
  %27 = load i64, ptr %13, align 8, !tbaa !16
  %28 = tail call double @difftime(i64 noundef %26, i64 noundef %27) #11
  %29 = fptosi double %28 to i64
  %30 = getelementptr inbounds i8, ptr %4, i64 48
  store i64 %29, ptr %30, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %4, i64 32
  store i64 1, ptr %31, align 8, !tbaa !22
  br label %32

32:                                               ; preds = %3, %17
  ret ptr %4
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z24progressbar_update_labelP11progressbarPKc(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL16progressbar_drawPK11progressbar(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare double @difftime(i64 noundef, i64 noundef) local_unnamed_addr #6

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #4 = { 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 #5 = { mustprogress 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 #6 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { noreturn nounwind }
attributes #11 = { nounwind willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"_ZTS11progressbar", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !11, i64 64, !12, i64 72}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"_ZTSN11progressbarUt_E", !8, i64 0, !8, i64 1, !8, i64 2}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !11, i64 64}
!16 = !{!6, !7, i64 40}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !8, i64 72}
!19 = !{!6, !8, i64 73}
!20 = !{!6, !8, i64 74}
!21 = !{!6, !7, i64 48}
!22 = !{!6, !7, i64 32}


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