; LLVM IR from stolk/energygraph :: energygraph (main)

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

@head = external dso_local global i32, align 4
@tail = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [40 x i8], align 1
@numzones = external hidden global i32, align 4
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@dnames = external hidden global [10 x [128 x i8]], align 16
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@files = external hidden global [10 x ptr], align 16
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@hist = external dso_local global [200 x [10 x i64]], align 16

; 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 uwtable
declare dso_local i64 @elapsed_ms_since_last_call() #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [140 x i8], align 16
  %10 = alloca [10 x i64], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  %17 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr @.str, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %18 = load ptr, ptr %6, align 8, !tbaa !9
  %19 = call i32 @locate_rapl_data(ptr noundef %18, i32 noundef -1)
  store i32 %19, ptr %7, align 4, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %25, label %22

22:                                               ; preds = %2
  %23 = load ptr, ptr @stderr, align 8, !tbaa !9
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.1) #6
  call void @exit(i32 noundef 3) #7
  unreachable

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %56, %25
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = load i32, ptr @numzones, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %59

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 140, ptr %9) #6
  %32 = getelementptr inbounds [140 x i8], ptr %9, i64 0, i64 0
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x [128 x i8]], ptr @dnames, i64 0, i64 %34
  %36 = getelementptr inbounds [128 x i8], ptr %35, i64 0, i64 0
  %37 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %32, i64 noundef 139, ptr noundef @.str.2, ptr noundef %36) #6
  %38 = getelementptr inbounds [140 x i8], ptr %9, i64 0, i64 0
  %39 = call noalias ptr @fopen(ptr noundef %38, ptr noundef @.str.3)
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10 x ptr], ptr @files, i64 0, i64 %41
  store ptr %39, ptr %42, align 8, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [10 x ptr], ptr @files, i64 0, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  br i1 %47, label %55, label %48

48:                                               ; preds = %31
  %49 = load ptr, ptr @stderr, align 8, !tbaa !9
  %50 = getelementptr inbounds [140 x i8], ptr %9, i64 0, i64 0
  %51 = call ptr @__errno_location() #8
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = call ptr @strerror(i32 noundef %52) #6
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.4, ptr noundef %50, ptr noundef %53) #6
  call void @exit(i32 noundef 2) #7
  unreachable

55:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 140, ptr %9) #6
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !5
  br label %26, !llvm.loop !11

59:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 80, ptr %10) #6
  %60 = getelementptr inbounds [10 x i64], ptr %10, i64 0, i64 0
  call void @read_values(ptr noundef %60)
  %61 = call i64 @elapsed_ms_since_last_call()
  call void @choose_colours()
  call void @set_postscript()
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %62 = call i32 @grapher_init()
  store i32 %62, ptr %11, align 4, !tbaa !5
  %63 = load i32, ptr %11, align 4, !tbaa !5
  %64 = icmp slt i32 %63, 0
  br i1 %64, label %65, label %68

65:                                               ; preds = %59
  %66 = load ptr, ptr @stderr, align 8, !tbaa !9
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.5) #6
  call void @exit(i32 noundef 2) #7
  unreachable

68:                                               ; preds = %59
  call void @enableRawMode()
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %71 = call i32 @update_image()
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %136, %68
  %73 = call i32 @sleep(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %74 = load i32, ptr @tail, align 4, !tbaa !5
  store i32 %74, ptr %13, align 4, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !5
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %76
  %78 = getelementptr inbounds [10 x i64], ptr %77, i64 0, i64 0
  call void @read_values(ptr noundef %78)
  %79 = load i32, ptr @tail, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = srem i32 %80, 200
  store i32 %81, ptr @tail, align 4, !tbaa !5
  %82 = load i32, ptr @tail, align 4, !tbaa !5
  %83 = load i32, ptr @head, align 4, !tbaa !5
  %84 = icmp eq i32 %82, %83
  br i1 %84, label %85, label %89

85:                                               ; preds = %72
  %86 = load i32, ptr @head, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  %88 = srem i32 %87, 200
  store i32 %88, ptr @head, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %85, %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %90 = call i64 @elapsed_ms_since_last_call()
  store i64 %90, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %113, %89
  %92 = load i32, ptr %15, align 4, !tbaa !5
  %93 = load i32, ptr @numzones, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %116

96:                                               ; preds = %91
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %98
  %100 = load i32, ptr %15, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [10 x i64], ptr %99, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !13
  %104 = mul nsw i64 %103, 1000
  %105 = load i64, ptr %14, align 8, !tbaa !13
  %106 = sdiv i64 %104, %105
  %107 = load i32, ptr %13, align 4, !tbaa !5
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %108
  %110 = load i32, ptr %15, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [10 x i64], ptr %109, i64 0, i64 %111
  store i64 %106, ptr %112, align 8, !tbaa !13
  br label %113

113:                                              ; preds = %96
  %114 = load i32, ptr %15, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %15, align 4, !tbaa !5
  br label %91, !llvm.loop !15

116:                                              ; preds = %95
  call void @draw_overlay()
  call void @draw_samples()
  %117 = call i32 @update_image()
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #6
  store i8 0, ptr %16, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %118 = call i64 @read(i32 noundef 0, ptr noundef %16, i64 noundef 1)
  %119 = trunc i64 %118 to i32
  store i32 %119, ptr %17, align 4, !tbaa !5
  %120 = load i32, ptr %17, align 4, !tbaa !5
  %121 = icmp eq i32 %120, 1
  br i1 %121, label %122, label %135

122:                                              ; preds = %116
  %123 = load i8, ptr %16, align 1, !tbaa !16
  %124 = sext i8 %123 to i32
  %125 = icmp eq i32 %124, 27
  br i1 %125, label %134, label %126

126:                                              ; preds = %122
  %127 = load i8, ptr %16, align 1, !tbaa !16
  %128 = sext i8 %127 to i32
  %129 = icmp eq i32 %128, 113
  br i1 %129, label %134, label %130

130:                                              ; preds = %126
  %131 = load i8, ptr %16, align 1, !tbaa !16
  %132 = sext i8 %131 to i32
  %133 = icmp eq i32 %132, 81
  br i1 %133, label %134, label %135

134:                                              ; preds = %130, %126, %122
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %134, %130, %116
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %12, align 4, !tbaa !5
  %138 = icmp ne i32 %137, 0
  %139 = xor i1 %138, true
  br i1 %139, label %72, label %140, !llvm.loop !17

140:                                              ; preds = %136
  call void @grapher_exit()
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @locate_rapl_data(ptr noundef, i32 noundef) #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

; Function Attrs: nounwind uwtable
declare hidden void @read_values(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @choose_colours() #1

; Function Attrs: nounwind uwtable
declare hidden void @set_postscript() #1

declare i32 @grapher_init() #4

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

; Function Attrs: nounwind uwtable
declare hidden i32 @update_image() #1

declare i32 @sleep(i32 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @draw_overlay() #1

; Function Attrs: nounwind uwtable
declare hidden void @draw_samples() #1

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

declare void @grapher_exit() #4

; Function Attrs: nounwind uwtable
declare hidden void @enableRawMode() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { "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(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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !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"

@head = external dso_local local_unnamed_addr global i32, align 4
@tail = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [41 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [40 x i8], align 1
@numzones = external hidden local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@dnames = external hidden global [10 x [128 x i8]], align 16
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@files = external hidden local_unnamed_addr global [10 x ptr], align 16
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@hist = external dso_local global [200 x [10 x i64]], align 16

; 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: nounwind uwtable
declare dso_local i64 @elapsed_ms_since_last_call() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = alloca [140 x i8], align 16
  %4 = alloca [10 x i64], align 16
  %5 = alloca i8, align 1
  %6 = tail call i32 @locate_rapl_data(ptr noundef nonnull @.str, i32 noundef -1)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %9, label %.preheader

.preheader:                                       ; preds = %2
  %7 = load i32, ptr @numzones, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !9
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1) #8
  tail call void @exit(i32 noundef 3) #9
  unreachable

._crit_edge:                                      ; preds = %25, %.preheader
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %4) #10
  call void @read_values(ptr noundef nonnull %4)
  %12 = call i64 @elapsed_ms_since_last_call()
  call void @choose_colours()
  call void @set_postscript()
  %13 = call i32 @grapher_init() #10
  %14 = icmp slt i32 %13, 0
  br i1 %14, label %29, label %32

.lr.ph:                                           ; preds = %.preheader, %25
  %indvars.iv = phi i64 [ %indvars.iv.next, %25 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 140, ptr nonnull %3) #10
  %15 = getelementptr inbounds [10 x [128 x i8]], ptr @dnames, i64 0, i64 %indvars.iv
  %16 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %3, i64 noundef 139, ptr noundef nonnull @.str.2, ptr noundef nonnull %15) #10
  %17 = call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.3)
  %18 = getelementptr inbounds [10 x ptr], ptr @files, i64 0, i64 %indvars.iv
  store ptr %17, ptr %18, align 8, !tbaa !9
  %.not26 = icmp eq ptr %17, null
  br i1 %.not26, label %19, label %25

19:                                               ; preds = %.lr.ph
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = tail call ptr @__errno_location() #11
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = tail call ptr @strerror(i32 noundef %22) #10
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.4, ptr noundef nonnull %3, ptr noundef %23) #8
  call void @exit(i32 noundef 2) #9
  unreachable

25:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 140, ptr nonnull %3) #10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @numzones, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !11

29:                                               ; preds = %._crit_edge
  %30 = load ptr, ptr @stderr, align 8, !tbaa !9
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.5) #8
  call void @exit(i32 noundef 2) #9
  unreachable

32:                                               ; preds = %._crit_edge
  call void @enableRawMode()
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %35 = call i32 @update_image()
  br label %36

36:                                               ; preds = %72, %32
  %37 = call i32 @sleep(i32 noundef 1) #10
  %38 = load i32, ptr @tail, align 4, !tbaa !5
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %39
  call void @read_values(ptr noundef nonnull %40)
  %41 = load i32, ptr @tail, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  %43 = srem i32 %42, 200
  store i32 %43, ptr @tail, align 4, !tbaa !5
  %44 = load i32, ptr @head, align 4, !tbaa !5
  %45 = icmp eq i32 %43, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %36
  %47 = trunc nsw i32 %43 to i16
  %.lhs.trunc = add nsw i16 %47, 1
  %48 = srem i16 %.lhs.trunc, 200
  %.sext = sext i16 %48 to i32
  store i32 %.sext, ptr @head, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %46, %36
  %50 = call i64 @elapsed_ms_since_last_call()
  %51 = load i32, ptr @numzones, align 4, !tbaa !5
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %.lr.ph32.preheader, label %._crit_edge33

.lr.ph32.preheader:                               ; preds = %49
  %wide.trip.count = zext nneg i32 %51 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %53 = icmp eq i32 %51, 1
  br i1 %53, label %._crit_edge33.loopexit.unr-lcssa, label %.lr.ph32.preheader.new

.lr.ph32.preheader.new:                           ; preds = %.lr.ph32.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph32

._crit_edge33.loopexit.unr-lcssa:                 ; preds = %.lr.ph32, %.lr.ph32.preheader
  %indvars.iv35.unr = phi i64 [ 0, %.lr.ph32.preheader ], [ %indvars.iv.next36.1, %.lr.ph32 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge33, label %.lr.ph32.epil

.lr.ph32.epil:                                    ; preds = %._crit_edge33.loopexit.unr-lcssa
  %54 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %39, i64 %indvars.iv35.unr
  %55 = load i64, ptr %54, align 8, !tbaa !13
  %56 = mul nsw i64 %55, 1000
  %57 = sdiv i64 %56, %50
  store i64 %57, ptr %54, align 8, !tbaa !13
  br label %._crit_edge33

._crit_edge33:                                    ; preds = %.lr.ph32.epil, %._crit_edge33.loopexit.unr-lcssa, %49
  call void @draw_overlay()
  call void @draw_samples()
  %58 = call i32 @update_image()
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #10
  store i8 0, ptr %5, align 1, !tbaa !15
  %59 = call i64 @read(i32 noundef 0, ptr noundef nonnull %5, i64 noundef 1) #10
  %60 = and i64 %59, 4294967295
  %61 = icmp eq i64 %60, 1
  br i1 %61, label %70, label %72

.lr.ph32:                                         ; preds = %.lr.ph32, %.lr.ph32.preheader.new
  %indvars.iv35 = phi i64 [ 0, %.lr.ph32.preheader.new ], [ %indvars.iv.next36.1, %.lr.ph32 ]
  %niter = phi i64 [ 0, %.lr.ph32.preheader.new ], [ %niter.next.1, %.lr.ph32 ]
  %62 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %39, i64 %indvars.iv35
  %63 = load i64, ptr %62, align 16, !tbaa !13
  %64 = mul nsw i64 %63, 1000
  %65 = sdiv i64 %64, %50
  store i64 %65, ptr %62, align 16, !tbaa !13
  %indvars.iv.next36 = or disjoint i64 %indvars.iv35, 1
  %66 = getelementptr inbounds [200 x [10 x i64]], ptr @hist, i64 0, i64 %39, i64 %indvars.iv.next36
  %67 = load i64, ptr %66, align 8, !tbaa !13
  %68 = mul nsw i64 %67, 1000
  %69 = sdiv i64 %68, %50
  store i64 %69, ptr %66, align 8, !tbaa !13
  %indvars.iv.next36.1 = add nuw nsw i64 %indvars.iv35, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge33.loopexit.unr-lcssa, label %.lr.ph32, !llvm.loop !16

70:                                               ; preds = %._crit_edge33
  %71 = load i8, ptr %5, align 1
  switch i8 %71, label %72 [
    i8 113, label %.thread
    i8 81, label %.thread
    i8 27, label %.thread
  ]

.thread:                                          ; preds = %70, %70, %70
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #10
  call void @grapher_exit() #10
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %4) #10
  ret i32 0

72:                                               ; preds = %70, %._crit_edge33
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #10
  br label %36, !llvm.loop !17
}

; Function Attrs: nounwind uwtable
declare hidden i32 @locate_rapl_data(ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

; 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: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @read_values(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @choose_colours() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @set_postscript() local_unnamed_addr #1

declare i32 @grapher_init() local_unnamed_addr #6

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

; Function Attrs: nounwind uwtable
declare hidden i32 @update_image() local_unnamed_addr #1

declare i32 @sleep(i32 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare hidden void @draw_overlay() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @draw_samples() local_unnamed_addr #1

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

declare void @grapher_exit() local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare hidden void @enableRawMode() local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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 = { 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 #6 = { "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 = { 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 #8 = { cold nounwind }
attributes #9 = { noreturn nounwind }
attributes #10 = { 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass