; LLVM IR from NTHU-LSALAB/Gemini :: src/scheduler.ll (Z12monitor_filePKcS0_)

; 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.inotify_event = type { i32, i32, i32, i32, [0 x i8] }

@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [31 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: mustprogress uwtable
declare dso_local void @_Z20read_resource_configv() #1

declare void @_Z5ERRORPKcz(ptr noundef, ...) #2

declare void @_Z4INFOPKcz(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12monitor_filePKcS0_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [32768 x i8], align 16
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef @.str.9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %11 = call i32 @inotify_init() #5
  store i32 %11, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef @.str.10)
  br label %15

15:                                               ; preds = %14, %2
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call i32 @inotify_add_watch(i32 noundef %16, ptr noundef %17, i32 noundef 8) #5
  store i32 %18, ptr %6, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp eq i32 %19, -1
  br i1 %20, label %21, label %23

21:                                               ; preds = %15
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef @.str.11, ptr noundef %22)
  br label %25

23:                                               ; preds = %15
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef @.str.12, ptr noundef %24)
  br label %25

25:                                               ; preds = %23, %21
  br label %26

26:                                               ; preds = %80, %25
  br label %27

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32768, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = getelementptr inbounds [32768 x i8], ptr %8, i64 0, i64 0
  %30 = call i64 @read(i32 noundef %28, ptr noundef %29, i64 noundef 32768)
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr %9, align 4, !tbaa !9
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef @.str.13)
  br label %35

35:                                               ; preds = %34, %27
  br label %36

36:                                               ; preds = %70, %35
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %80

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [32768 x i8], ptr %8, i64 0, i64 %42
  store ptr %43, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.inotify_event, ptr %44, i32 0, i32 3
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %70

48:                                               ; preds = %40
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.inotify_event, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = and i32 %51, 8
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %69

54:                                               ; preds = %48
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.inotify_event, ptr %55, i32 0, i32 4
  %57 = getelementptr inbounds [0 x i8], ptr %56, i64 0, i64 0
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.inotify_event, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 4, !tbaa !9
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef @.str.14, ptr noundef %57, i32 noundef %60)
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.inotify_event, ptr %61, i32 0, i32 4
  %63 = getelementptr inbounds [0 x i8], ptr %62, i64 0, i64 0
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @strcmp(ptr noundef %63, ptr noundef %64) #6
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %54
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef @.str.15)
  call void @_Z20read_resource_configv()
  br label %68

68:                                               ; preds = %67, %54
  br label %69

69:                                               ; preds = %68, %48
  br label %70

70:                                               ; preds = %69, %40
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.inotify_event, ptr %71, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = add i64 16, %74
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = add i64 %77, %75
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %36, !llvm.loop !11

80:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 32768, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %26, !llvm.loop !13
}

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

; Function Attrs: nounwind
declare i32 @inotify_add_watch(i32 noundef, ptr noundef, i32 noundef) #3

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

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

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 = { "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = 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.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [31 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 uwtable
declare dso_local void @_Z20read_resource_configv() local_unnamed_addr #1

declare void @_Z5ERRORPKcz(ptr noundef, ...) local_unnamed_addr #2

declare void @_Z4INFOPKcz(ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_Z12monitor_filePKcS0_(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = alloca [32768 x i8], align 16
  tail call void (ptr, ...) @_Z4INFOPKcz(ptr noundef nonnull @.str.9)
  %4 = tail call i32 @inotify_init() #7
  %5 = icmp slt i32 %4, 0
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef nonnull @.str.10)
  br label %7

7:                                                ; preds = %6, %2
  %8 = tail call i32 @inotify_add_watch(i32 noundef %4, ptr noundef %0, i32 noundef 8) #7
  %9 = icmp eq i32 %8, -1
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  tail call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef nonnull @.str.11, ptr noundef %0)
  br label %.preheader

11:                                               ; preds = %7
  tail call void (ptr, ...) @_Z4INFOPKcz(ptr noundef nonnull @.str.12, ptr noundef %0)
  br label %.preheader

.preheader:                                       ; preds = %11, %10
  br label %12

12:                                               ; preds = %.preheader, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %3) #7
  %13 = call i64 @read(i32 noundef %4, ptr noundef nonnull %3, i64 noundef 32768)
  %14 = trunc i64 %13 to i32
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %.thread, label %16

.thread:                                          ; preds = %12
  call void (ptr, ...) @_Z5ERRORPKcz(ptr noundef nonnull @.str.13)
  br label %._crit_edge

16:                                               ; preds = %12
  %.not20 = icmp eq i32 %14, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16, %31
  %.019 = phi i32 [ %34, %31 ], [ 0, %16 ]
  %17 = sext i32 %.019 to i64
  %18 = getelementptr inbounds [32768 x i8], ptr %3, i64 0, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %31, label %21

21:                                               ; preds = %.lr.ph
  %22 = getelementptr inbounds i8, ptr %18, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = and i32 %23, 8
  %.not18 = icmp eq i32 %24, 0
  br i1 %.not18, label %31, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %18, i64 16
  %27 = load i32, ptr %18, align 4, !tbaa !5
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef nonnull @.str.14, ptr noundef nonnull %26, i32 noundef %27)
  %28 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %26, ptr noundef nonnull dereferenceable(1) %1) #8
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  call void (ptr, ...) @_Z4INFOPKcz(ptr noundef nonnull @.str.15)
  call void @_Z20read_resource_configv()
  br label %31

31:                                               ; preds = %21, %30, %25, %.lr.ph
  %32 = load i32, ptr %19, align 4, !tbaa !5
  %33 = add i32 %.019, 16
  %34 = add i32 %33, %32
  %35 = icmp slt i32 %34, %14
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %31, %.thread, %16
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %3) #7
  br label %12, !llvm.loop !11
}

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

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

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

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

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 = { "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 noreturn 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 "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 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass