; LLVM IR from SvrAdityaReddy/RTOS :: Assignment_4/shared_memory (shared_memory_semaphore)

; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@__const.main.message = external hidden unnamed_addr constant [3 x ptr], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.stat, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [3 x ptr], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %12 = call i32 @shm_unlink(ptr noundef @.str)
  %13 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  %14 = call ptr (ptr, i32, ...) @sem_open(ptr noundef @.str.1, i32 noundef 64, i32 noundef 436, i32 noundef 1) #6
  store ptr %14, ptr %2, align 8, !tbaa !5
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %0
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %19

19:                                               ; preds = %17, %0
  %20 = call i32 @shm_open(ptr noundef @.str, i32 noundef 66, i32 noundef 436)
  store i32 %20, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = icmp eq i32 %21, -1
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = call i32 @sem_close(ptr noundef %25) #6
  %27 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

28:                                               ; preds = %19
  store i32 10, ptr %5, align 4, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = call i32 @ftruncate(i32 noundef %29, i64 noundef %31) #6
  %33 = icmp eq i32 %32, -1
  br i1 %33, label %34, label %42

34:                                               ; preds = %28
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = call i32 @close(i32 noundef %36)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = call i32 @sem_close(ptr noundef %38) #6
  %40 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  %41 = call i32 @shm_unlink(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

42:                                               ; preds = %28
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = call ptr @mmap(ptr noundef null, i64 noundef %44, i32 noundef 3, i32 noundef 1, i32 noundef %45, i64 noundef 0) #6
  store ptr %46, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = icmp eq ptr %47, inttoptr (i64 -1 to ptr)
  br i1 %48, label %49, label %57

49:                                               ; preds = %42
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = call i32 @close(i32 noundef %51)
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = call i32 @sem_close(ptr noundef %53) #6
  %55 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  %56 = call i32 @shm_unlink(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

57:                                               ; preds = %42
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = call i32 @sem_wait(ptr noundef %58)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %60, ptr align 1 @.str.6, i64 2, i1 false)
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = call i32 @sem_post(ptr noundef %61) #6
  %63 = call i32 @fork() #6
  store i32 %63, ptr %3, align 4, !tbaa !9
  %64 = load i32, ptr %3, align 4, !tbaa !9
  %65 = icmp eq i32 %64, -1
  br i1 %65, label %66, label %74

66:                                               ; preds = %57
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = call i32 @close(i32 noundef %68)
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = call i32 @sem_close(ptr noundef %70) #6
  %72 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  %73 = call i32 @shm_unlink(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

74:                                               ; preds = %57
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %121

77:                                               ; preds = %74
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = call i32 @sem_wait(ptr noundef %78)
  call void @llvm.lifetime.start.p0(i64 144, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  %80 = call i32 @shm_open(ptr noundef @.str, i32 noundef 0, i32 noundef 0)
  store i32 %80, ptr %4, align 4, !tbaa !9
  %81 = load i32, ptr %4, align 4, !tbaa !9
  %82 = call i32 @fstat(i32 noundef %81, ptr noundef %8) #6
  %83 = getelementptr inbounds %struct.stat, ptr %8, i32 0, i32 8
  %84 = load i64, ptr %83, align 8, !tbaa !11
  %85 = load i32, ptr %4, align 4, !tbaa !9
  %86 = call ptr @mmap(ptr noundef null, i64 noundef %84, i32 noundef 1, i32 noundef 1, i32 noundef %85, i64 noundef 0) #6
  store ptr %86, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = icmp eq ptr %87, inttoptr (i64 -1 to ptr)
  br i1 %88, label %89, label %94

89:                                               ; preds = %77
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = call i32 @close(i32 noundef %91)
  %93 = call i32 @shm_unlink(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %120

94:                                               ; preds = %77
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, ptr noundef %95)
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = call i32 @sem_post(ptr noundef %97) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %99

99:                                               ; preds = %110, %94
  %100 = load i32, ptr %9, align 4, !tbaa !9
  %101 = icmp slt i32 %100, 3
  br i1 %101, label %102, label %113

102:                                              ; preds = %99
  %103 = call i32 @sleep(i32 noundef 2)
  %104 = load ptr, ptr %2, align 8, !tbaa !5
  %105 = call i32 @sem_wait(ptr noundef %104)
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, ptr noundef %106)
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  %109 = call i32 @sem_post(ptr noundef %108) #6
  br label %110

110:                                              ; preds = %102
  %111 = load i32, ptr %9, align 4, !tbaa !9
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %9, align 4, !tbaa !9
  br label %99, !llvm.loop !15

113:                                              ; preds = %99
  %114 = load i32, ptr %4, align 4, !tbaa !9
  %115 = call i32 @close(i32 noundef %114)
  %116 = load ptr, ptr %2, align 8, !tbaa !5
  %117 = call i32 @sem_close(ptr noundef %116) #6
  %118 = call i32 @shm_unlink(ptr noundef @.str)
  %119 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %120

120:                                              ; preds = %113, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 144, ptr %8) #6
  br label %153

121:                                              ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 @__const.main.message, i64 24, i1 false)
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %141, %121
  %123 = load i32, ptr %10, align 4, !tbaa !9
  %124 = icmp slt i32 %123, 3
  br i1 %124, label %125, label %144

125:                                              ; preds = %122
  %126 = call i32 @sleep(i32 noundef 2)
  %127 = load ptr, ptr %2, align 8, !tbaa !5
  %128 = call i32 @sem_wait(ptr noundef %127)
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = load i32, ptr %10, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [3 x ptr], ptr %11, i64 0, i64 %131
  %133 = load ptr, ptr %132, align 8, !tbaa !5
  %134 = load i32, ptr %10, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [3 x ptr], ptr %11, i64 0, i64 %135
  %137 = load ptr, ptr %136, align 8, !tbaa !5
  %138 = call i64 @strlen(ptr noundef %137) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %129, ptr align 1 %133, i64 %138, i1 false)
  %139 = load ptr, ptr %2, align 8, !tbaa !5
  %140 = call i32 @sem_post(ptr noundef %139) #6
  br label %141

141:                                              ; preds = %125
  %142 = load i32, ptr %10, align 4, !tbaa !9
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %10, align 4, !tbaa !9
  br label %122, !llvm.loop !17

144:                                              ; preds = %122
  %145 = load i32, ptr %4, align 4, !tbaa !9
  %146 = call i32 @close(i32 noundef %145)
  %147 = load ptr, ptr %2, align 8, !tbaa !5
  %148 = call i32 @sem_close(ptr noundef %147) #6
  %149 = call i32 @shm_unlink(ptr noundef @.str)
  %150 = call i32 @sem_unlink(ptr noundef @.str.1) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %151

151:                                              ; preds = %144
  br label %152

152:                                              ; preds = %151
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

153:                                              ; preds = %152, %120, %66, %49, %34, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %154 = load i32, ptr %1, align 4
  ret i32 %154
}

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

declare i32 @shm_unlink(ptr noundef) #2

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

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

declare i32 @printf(ptr noundef, ...) #2

declare i32 @shm_open(ptr noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) #3

declare i32 @close(i32 noundef) #2

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

declare i32 @sem_wait(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

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

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

declare i32 @sleep(i32 noundef) #2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 48}
!12 = !{!"stat", !13, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !14, i64 72, !14, i64 88, !14, i64 104, !7, i64 120}
!13 = !{!"long", !7, i64 0}
!14 = !{!"timespec", !13, i64 0, !13, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@__const.main.message = external hidden unnamed_addr constant [3 x ptr], align 16

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.stat, align 8
  %2 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  %3 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  %4 = tail call ptr (ptr, i32, ...) @sem_open(ptr noundef nonnull @.str.1, i32 noundef 64, i32 noundef 436, i32 noundef 1) #7
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %8

6:                                                ; preds = %0
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %8

8:                                                ; preds = %6, %0
  %9 = tail call i32 @shm_open(ptr noundef nonnull @.str, i32 noundef 66, i32 noundef 436) #7
  %10 = icmp eq i32 %9, -1
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %13 = tail call i32 @sem_close(ptr noundef %4) #7
  %14 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  br label %95

15:                                               ; preds = %8
  %16 = tail call i32 @ftruncate(i32 noundef %9, i64 noundef 10) #7
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %20 = tail call i32 @close(i32 noundef %9) #7
  %21 = tail call i32 @sem_close(ptr noundef %4) #7
  %22 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  %23 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  br label %95

24:                                               ; preds = %15
  %25 = tail call ptr @mmap(ptr noundef null, i64 noundef 10, i32 noundef 3, i32 noundef 1, i32 noundef %9, i64 noundef 0) #7
  %26 = icmp eq ptr %25, inttoptr (i64 -1 to ptr)
  br i1 %26, label %27, label %33

27:                                               ; preds = %24
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %29 = tail call i32 @close(i32 noundef %9) #7
  %30 = tail call i32 @sem_close(ptr noundef %4) #7
  %31 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  %32 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  br label %95

33:                                               ; preds = %24
  %34 = tail call i32 @sem_wait(ptr noundef %4) #7
  %35 = load i16, ptr @.str.6, align 1
  store i16 %35, ptr %25, align 1
  %36 = tail call i32 @sem_post(ptr noundef %4) #7
  %37 = tail call i32 @fork() #7
  switch i32 %37, label %.preheader.preheader [
    i32 -1, label %57
    i32 0, label %63
  ]

.preheader.preheader:                             ; preds = %33
  %38 = tail call i32 @sleep(i32 noundef 2) #7
  %39 = tail call i32 @sem_wait(ptr noundef %4) #7
  %40 = load ptr, ptr @__const.main.message, align 16, !tbaa !5
  %41 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %40) #8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %25, ptr align 1 %40, i64 %41, i1 false)
  %42 = tail call i32 @sem_post(ptr noundef %4) #7
  %43 = tail call i32 @sleep(i32 noundef 2) #7
  %44 = tail call i32 @sem_wait(ptr noundef %4) #7
  %45 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.message, i64 8), align 8, !tbaa !5
  %46 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %45) #8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %25, ptr align 1 %45, i64 %46, i1 false)
  %47 = tail call i32 @sem_post(ptr noundef %4) #7
  %48 = tail call i32 @sleep(i32 noundef 2) #7
  %49 = tail call i32 @sem_wait(ptr noundef %4) #7
  %50 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.message, i64 16), align 16, !tbaa !5
  %51 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %50) #8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %25, ptr align 1 %50, i64 %51, i1 false)
  %52 = tail call i32 @sem_post(ptr noundef %4) #7
  %53 = tail call i32 @close(i32 noundef %9) #7
  %54 = tail call i32 @sem_close(ptr noundef %4) #7
  %55 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  %56 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  br label %95

57:                                               ; preds = %33
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %59 = tail call i32 @close(i32 noundef %9) #7
  %60 = tail call i32 @sem_close(ptr noundef %4) #7
  %61 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  %62 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  br label %95

63:                                               ; preds = %33
  %64 = tail call i32 @sem_wait(ptr noundef %4) #7
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %1) #7
  %65 = tail call i32 @shm_open(ptr noundef nonnull @.str, i32 noundef 0, i32 noundef 0) #7
  %66 = call i32 @fstat(i32 noundef %65, ptr noundef nonnull %1) #7
  %67 = getelementptr inbounds i8, ptr %1, i64 48
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = tail call ptr @mmap(ptr noundef null, i64 noundef %68, i32 noundef 1, i32 noundef 1, i32 noundef %65, i64 noundef 0) #7
  %70 = icmp eq ptr %69, inttoptr (i64 -1 to ptr)
  br i1 %70, label %71, label %75

71:                                               ; preds = %63
  %72 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %73 = tail call i32 @close(i32 noundef %65) #7
  %74 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  br label %94

75:                                               ; preds = %63
  %76 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %69)
  %77 = tail call i32 @sem_post(ptr noundef %4) #7
  %78 = tail call i32 @sleep(i32 noundef 2) #7
  %79 = tail call i32 @sem_wait(ptr noundef %4) #7
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %69)
  %81 = tail call i32 @sem_post(ptr noundef %4) #7
  %82 = tail call i32 @sleep(i32 noundef 2) #7
  %83 = tail call i32 @sem_wait(ptr noundef %4) #7
  %84 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %69)
  %85 = tail call i32 @sem_post(ptr noundef %4) #7
  %86 = tail call i32 @sleep(i32 noundef 2) #7
  %87 = tail call i32 @sem_wait(ptr noundef %4) #7
  %88 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %69)
  %89 = tail call i32 @sem_post(ptr noundef %4) #7
  %90 = tail call i32 @close(i32 noundef %65) #7
  %91 = tail call i32 @sem_close(ptr noundef %4) #7
  %92 = tail call i32 @shm_unlink(ptr noundef nonnull @.str) #7
  %93 = tail call i32 @sem_unlink(ptr noundef nonnull @.str.1) #7
  br label %94

94:                                               ; preds = %75, %71
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %1) #7
  br label %95

95:                                               ; preds = %.preheader.preheader, %94, %57, %27, %18, %11
  ret i32 0
}

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

declare i32 @shm_unlink(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @sem_unlink(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare ptr @sem_open(ptr noundef, i32 noundef, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

declare i32 @shm_open(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @sem_close(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) local_unnamed_addr #3

declare i32 @close(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare ptr @mmap(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #3

declare i32 @sem_wait(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: nounwind
declare i32 @sem_post(ptr noundef) local_unnamed_addr #3

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

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

declare i32 @sleep(i32 noundef) local_unnamed_addr #2

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 48}
!10 = !{!"stat", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !13, i64 72, !13, i64 88, !13, i64 104, !7, i64 120}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"timespec", !11, i64 0, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass