; LLVM IR from greensoftwarelab/Energy-Languages :: C/chameneos-redux/chameneosredux.gcc-5 (print_colors)

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

@color_names = external dso_local global [3 x ptr], align 16
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 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: nounwind uwtable
declare dso_local i32 @color_complement(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @print_colors() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %32, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp ule i32 %5, 2
  br i1 %6, label %7, label %35

7:                                                ; preds = %4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %28, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp ule i32 %9, 2
  br i1 %10, label %11, label %31

11:                                               ; preds = %8
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = call i32 @color_complement(i32 noundef %12, i32 noundef %13)
  store i32 %14, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %18, ptr noundef %22, ptr noundef %26)
  br label %28

28:                                               ; preds = %11
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !11

31:                                               ; preds = %8
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = add i32 %33, 1
  store i32 %34, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !13

35:                                               ; preds = %4
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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

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 = { "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 }

!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 = 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"

@color_names = external dso_local local_unnamed_addr global [3 x ptr], align 16
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @color_complement(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @print_colors() local_unnamed_addr #0 {
.preheader:
  %0 = tail call i32 @color_complement(i32 noundef 0, i32 noundef 0)
  %1 = load ptr, ptr @color_names, align 16, !tbaa !5
  %2 = zext i32 %0 to i64
  %3 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %2
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %1, ptr noundef %1, ptr noundef %4)
  %6 = tail call i32 @color_complement(i32 noundef 0, i32 noundef 1)
  %7 = load ptr, ptr @color_names, align 16, !tbaa !5
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 8), align 8, !tbaa !5
  %9 = zext i32 %6 to i64
  %10 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %9
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %7, ptr noundef %8, ptr noundef %11)
  %13 = tail call i32 @color_complement(i32 noundef 0, i32 noundef 2)
  %14 = load ptr, ptr @color_names, align 16, !tbaa !5
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 16), align 16, !tbaa !5
  %16 = zext i32 %13 to i64
  %17 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %14, ptr noundef %15, ptr noundef %18)
  %20 = tail call i32 @color_complement(i32 noundef 1, i32 noundef 0)
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 8), align 8, !tbaa !5
  %22 = load ptr, ptr @color_names, align 16, !tbaa !5
  %23 = zext i32 %20 to i64
  %24 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %21, ptr noundef %22, ptr noundef %25)
  %27 = tail call i32 @color_complement(i32 noundef 1, i32 noundef 1)
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 8), align 8, !tbaa !5
  %29 = zext i32 %27 to i64
  %30 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %28, ptr noundef %28, ptr noundef %31)
  %33 = tail call i32 @color_complement(i32 noundef 1, i32 noundef 2)
  %34 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 8), align 8, !tbaa !5
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 16), align 16, !tbaa !5
  %36 = zext i32 %33 to i64
  %37 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %34, ptr noundef %35, ptr noundef %38)
  %40 = tail call i32 @color_complement(i32 noundef 2, i32 noundef 0)
  %41 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 16), align 16, !tbaa !5
  %42 = load ptr, ptr @color_names, align 16, !tbaa !5
  %43 = zext i32 %40 to i64
  %44 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %41, ptr noundef %42, ptr noundef %45)
  %47 = tail call i32 @color_complement(i32 noundef 2, i32 noundef 1)
  %48 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 16), align 16, !tbaa !5
  %49 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 8), align 8, !tbaa !5
  %50 = zext i32 %47 to i64
  %51 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %48, ptr noundef %49, ptr noundef %52)
  %54 = tail call i32 @color_complement(i32 noundef 2, i32 noundef 2)
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @color_names, i64 16), align 16, !tbaa !5
  %56 = zext i32 %54 to i64
  %57 = getelementptr inbounds [3 x ptr], ptr @color_names, i64 0, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %55, ptr noundef %55, ptr noundef %58)
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  ret void
}

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

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 = { 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" }

!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"}


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