; LLVM IR from greensoftwarelab/Energy-Languages :: C/chameneos-redux/chameneosredux.gcc-5 (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"

%struct.cpu_set_t = type { [16 x i64] }

@__const.main.initial_colors1 = external hidden unnamed_addr constant [3 x i32], align 4
@__const.main.initial_colors2 = external hidden unnamed_addr constant [10 x i32], 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 void @print_colors() #1

; Function Attrs: nounwind uwtable
declare dso_local void @get_affinity(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

; Function Attrs: nounwind uwtable
declare dso_local void @init_and_start(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @join_and_output(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #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 [3 x i32], align 4
  %7 = alloca [10 x i32], align 16
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca %struct.cpu_set_t, align 8
  %16 = alloca %struct.cpu_set_t, align 8
  %17 = alloca i64, align 8
  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 12, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const.main.initial_colors1, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.main.initial_colors2, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i64 6000000, ptr %17, align 8, !tbaa !11
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp sgt i32 %18, 1
  br i1 %19, label %20, label %32

20:                                               ; preds = %2
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds ptr, ptr %21, i64 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = call i32 @atoi(ptr noundef %23) #5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %26, label %32

26:                                               ; preds = %20
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i64 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call i32 @atoi(ptr noundef %29) #5
  %31 = sext i32 %30 to i64
  store i64 %31, ptr %17, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %26, %20, %2
  call void @print_colors()
  call void @get_affinity(ptr noundef %14, ptr noundef %15, ptr noundef %16)
  store i64 3, ptr %10, align 8, !tbaa !11
  store i64 10, ptr %13, align 8, !tbaa !11
  %33 = load i32, ptr %14, align 4, !tbaa !5
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %52

35:                                               ; preds = %32
  %36 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %37 = load i64, ptr %10, align 8, !tbaa !11
  %38 = load i64, ptr %17, align 8, !tbaa !11
  %39 = load i32, ptr %14, align 4, !tbaa !5
  call void @init_and_start(ptr noundef %36, i64 noundef %37, ptr noundef %8, ptr noundef %9, i64 noundef %38, i32 noundef %39, ptr noundef %15)
  %40 = getelementptr inbounds [10 x i32], ptr %7, i64 0, i64 0
  %41 = load i64, ptr %13, align 8, !tbaa !11
  %42 = load i64, ptr %17, align 8, !tbaa !11
  %43 = load i32, ptr %14, align 4, !tbaa !5
  call void @init_and_start(ptr noundef %40, i64 noundef %41, ptr noundef %11, ptr noundef %12, i64 noundef %42, i32 noundef %43, ptr noundef %16)
  %44 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %45 = load i64, ptr %10, align 8, !tbaa !11
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  call void @join_and_output(ptr noundef %44, i64 noundef %45, ptr noundef %46, ptr noundef %47)
  %48 = getelementptr inbounds [10 x i32], ptr %7, i64 0, i64 0
  %49 = load i64, ptr %13, align 8, !tbaa !11
  %50 = load ptr, ptr %11, align 8, !tbaa !9
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  call void @join_and_output(ptr noundef %48, i64 noundef %49, ptr noundef %50, ptr noundef %51)
  br label %69

52:                                               ; preds = %32
  %53 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %54 = load i64, ptr %10, align 8, !tbaa !11
  %55 = load i64, ptr %17, align 8, !tbaa !11
  %56 = load i32, ptr %14, align 4, !tbaa !5
  call void @init_and_start(ptr noundef %53, i64 noundef %54, ptr noundef %8, ptr noundef %9, i64 noundef %55, i32 noundef %56, ptr noundef %15)
  %57 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %58 = load i64, ptr %10, align 8, !tbaa !11
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = load ptr, ptr %9, align 8, !tbaa !9
  call void @join_and_output(ptr noundef %57, i64 noundef %58, ptr noundef %59, ptr noundef %60)
  %61 = getelementptr inbounds [10 x i32], ptr %7, i64 0, i64 0
  %62 = load i64, ptr %13, align 8, !tbaa !11
  %63 = load i64, ptr %17, align 8, !tbaa !11
  %64 = load i32, ptr %14, align 4, !tbaa !5
  call void @init_and_start(ptr noundef %61, i64 noundef %62, ptr noundef %11, ptr noundef %12, i64 noundef %63, i32 noundef %64, ptr noundef %16)
  %65 = getelementptr inbounds [10 x i32], ptr %7, i64 0, i64 0
  %66 = load i64, ptr %13, align 8, !tbaa !11
  %67 = load ptr, ptr %11, align 8, !tbaa !9
  %68 = load ptr, ptr %12, align 8, !tbaa !9
  call void @join_and_output(ptr noundef %65, i64 noundef %66, ptr noundef %67, ptr noundef %68)
  br label %69

69:                                               ; preds = %52, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #4
  ret i32 0
}

; 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) #3

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 = { inlinehint nounwind willreturn memory(read) 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, 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"

%struct.cpu_set_t = type { [16 x i64] }

@__const.main.initial_colors1 = external hidden unnamed_addr constant [3 x i32], align 4
@__const.main.initial_colors2 = external hidden unnamed_addr constant [10 x i32], 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 void @print_colors() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @get_affinity(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @init_and_start(ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @join_and_output(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca [3 x i32], align 4
  %4 = alloca [10 x i32], align 16
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.cpu_set_t, align 8
  %11 = alloca %struct.cpu_set_t, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) @__const.main.initial_colors1, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %4, ptr noundef nonnull align 16 dereferenceable(40) @__const.main.initial_colors2, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %11) #4
  %12 = icmp sgt i32 %0, 1
  br i1 %12, label %13, label %18

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = tail call i32 @atoi(ptr nocapture noundef %15) #5
  %17 = icmp sgt i32 %16, 0
  %narrow = select i1 %17, i32 %16, i32 6000000
  %spec.select = zext i32 %narrow to i64
  br label %18

18:                                               ; preds = %13, %2
  %.0 = phi i64 [ 6000000, %2 ], [ %spec.select, %13 ]
  tail call void @print_colors()
  call void @get_affinity(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %26, label %20

20:                                               ; preds = %18
  call void @init_and_start(ptr noundef nonnull %3, i64 noundef 3, ptr noundef nonnull %5, ptr noundef nonnull %6, i64 noundef %.0, i32 noundef %19, ptr noundef nonnull %10)
  %21 = load i32, ptr %9, align 4, !tbaa !9
  call void @init_and_start(ptr noundef nonnull %4, i64 noundef 10, ptr noundef nonnull %7, ptr noundef nonnull %8, i64 noundef %.0, i32 noundef %21, ptr noundef nonnull %11)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @join_and_output(ptr noundef nonnull %3, i64 noundef 3, ptr noundef %22, ptr noundef %23)
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  call void @join_and_output(ptr noundef nonnull %4, i64 noundef 10, ptr noundef %24, ptr noundef %25)
  br label %32

26:                                               ; preds = %18
  call void @init_and_start(ptr noundef nonnull %3, i64 noundef 3, ptr noundef nonnull %5, ptr noundef nonnull %6, i64 noundef %.0, i32 noundef 0, ptr noundef nonnull %10)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  call void @join_and_output(ptr noundef nonnull %3, i64 noundef 3, ptr noundef %27, ptr noundef %28)
  %29 = load i32, ptr %9, align 4, !tbaa !9
  call void @init_and_start(ptr noundef nonnull %4, i64 noundef 10, ptr noundef nonnull %7, ptr noundef nonnull %8, i64 noundef %.0, i32 noundef %29, ptr noundef nonnull %11)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  call void @join_and_output(ptr noundef nonnull %4, i64 noundef 10, ptr noundef %30, ptr noundef %31)
  br label %32

32:                                               ; preds = %26, %20
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  ret i32 0
}

; 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) #3

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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { 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}


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