; LLVM IR from indjev99/Evolving-Snakes :: sources/draw.ll (Z14drawGridSquareiidddd)

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

@BACKGROUND_COLOUR_R = external constant double, align 8
@BACKGROUND_COLOUR_G = external constant double, align 8
@BACKGROUND_COLOUR_B = external constant double, align 8

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

declare void @glVertex2f(float noundef, float noundef) #1

; 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
define dso_local void @_Z14drawGridSquareiidddd(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  store double %4, ptr %11, align 8, !tbaa !9
  store double %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %18, 7.000000e+01
  store double %19, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %21, 7.000000e+01
  store double %22, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %23 = load double, ptr %13, align 8, !tbaa !9
  %24 = fadd double %23, 0x3F8D41D41D41D41D
  store double %24, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %25 = load double, ptr %14, align 8, !tbaa !9
  %26 = fadd double %25, 0x3F8D41D41D41D41D
  store double %26, ptr %16, align 8, !tbaa !9
  %27 = load double, ptr %9, align 8, !tbaa !9
  %28 = fptrunc double %27 to float
  %29 = load double, ptr %10, align 8, !tbaa !9
  %30 = fptrunc double %29 to float
  %31 = load double, ptr %11, align 8, !tbaa !9
  %32 = fptrunc double %31 to float
  call void @glColor3f(float noundef %28, float noundef %30, float noundef %32)
  %33 = load double, ptr %13, align 8, !tbaa !9
  %34 = fptrunc double %33 to float
  %35 = load double, ptr %14, align 8, !tbaa !9
  %36 = fptrunc double %35 to float
  call void @glVertex2f(float noundef %34, float noundef %36)
  %37 = load double, ptr %15, align 8, !tbaa !9
  %38 = fptrunc double %37 to float
  %39 = load double, ptr %14, align 8, !tbaa !9
  %40 = fptrunc double %39 to float
  call void @glVertex2f(float noundef %38, float noundef %40)
  %41 = load double, ptr %15, align 8, !tbaa !9
  %42 = fptrunc double %41 to float
  %43 = load double, ptr %16, align 8, !tbaa !9
  %44 = fptrunc double %43 to float
  call void @glVertex2f(float noundef %42, float noundef %44)
  %45 = load double, ptr %13, align 8, !tbaa !9
  %46 = fptrunc double %45 to float
  %47 = load double, ptr %16, align 8, !tbaa !9
  %48 = fptrunc double %47 to float
  call void @glVertex2f(float noundef %46, float noundef %48)
  %49 = load double, ptr @BACKGROUND_COLOUR_R, align 8, !tbaa !9
  %50 = fptrunc double %49 to float
  %51 = load double, ptr @BACKGROUND_COLOUR_G, align 8, !tbaa !9
  %52 = fptrunc double %51 to float
  %53 = load double, ptr @BACKGROUND_COLOUR_B, align 8, !tbaa !9
  %54 = fptrunc double %53 to float
  call void @glColor3f(float noundef %50, float noundef %52, float noundef %54)
  %55 = load double, ptr %12, align 8, !tbaa !9
  %56 = fdiv double %55, 7.000000e+01
  %57 = load double, ptr %13, align 8, !tbaa !9
  %58 = fadd double %57, %56
  store double %58, ptr %13, align 8, !tbaa !9
  %59 = load double, ptr %12, align 8, !tbaa !9
  %60 = fdiv double %59, 7.000000e+01
  %61 = load double, ptr %14, align 8, !tbaa !9
  %62 = fadd double %61, %60
  store double %62, ptr %14, align 8, !tbaa !9
  %63 = load double, ptr %12, align 8, !tbaa !9
  %64 = fdiv double %63, 7.000000e+01
  %65 = load double, ptr %15, align 8, !tbaa !9
  %66 = fsub double %65, %64
  store double %66, ptr %15, align 8, !tbaa !9
  %67 = load double, ptr %12, align 8, !tbaa !9
  %68 = fdiv double %67, 7.000000e+01
  %69 = load double, ptr %16, align 8, !tbaa !9
  %70 = fsub double %69, %68
  store double %70, ptr %16, align 8, !tbaa !9
  %71 = load double, ptr %13, align 8, !tbaa !9
  %72 = fptrunc double %71 to float
  %73 = load double, ptr %14, align 8, !tbaa !9
  %74 = fptrunc double %73 to float
  call void @glVertex2f(float noundef %72, float noundef %74)
  %75 = load double, ptr %15, align 8, !tbaa !9
  %76 = fptrunc double %75 to float
  %77 = load double, ptr %14, align 8, !tbaa !9
  %78 = fptrunc double %77 to float
  call void @glVertex2f(float noundef %76, float noundef %78)
  %79 = load double, ptr %15, align 8, !tbaa !9
  %80 = fptrunc double %79 to float
  %81 = load double, ptr %16, align 8, !tbaa !9
  %82 = fptrunc double %81 to float
  call void @glVertex2f(float noundef %80, float noundef %82)
  %83 = load double, ptr %13, align 8, !tbaa !9
  %84 = fptrunc double %83 to float
  %85 = load double, ptr %16, align 8, !tbaa !9
  %86 = fptrunc double %85 to float
  call void @glVertex2f(float noundef %84, float noundef %86)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret void
}

declare void @glColor3f(float noundef, float noundef, float noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

@BACKGROUND_COLOUR_R = external local_unnamed_addr constant double, align 8
@BACKGROUND_COLOUR_G = external local_unnamed_addr constant double, align 8
@BACKGROUND_COLOUR_B = external local_unnamed_addr constant double, align 8

declare void @glVertex2f(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14drawGridSquareiidddd(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5) local_unnamed_addr #1 {
  %7 = sitofp i32 %0 to double
  %8 = sitofp i32 %1 to double
  %9 = fdiv double %8, 7.000000e+01
  %10 = fadd double %9, 0x3F8D41D41D41D41D
  %11 = fptrunc double %2 to float
  %12 = fptrunc double %3 to float
  %13 = fptrunc double %4 to float
  tail call void @glColor3f(float noundef %11, float noundef %12, float noundef %13)
  %14 = fptrunc double %9 to float
  %15 = fptrunc double %10 to float
  %16 = insertelement <2 x double> poison, double %7, i64 0
  %17 = insertelement <2 x double> %16, double %5, i64 1
  %18 = fdiv <2 x double> %17, <double 7.000000e+01, double 7.000000e+01>
  %19 = extractelement <2 x double> %18, i64 0
  %20 = fadd double %19, 0x3F8D41D41D41D41D
  %21 = fptrunc double %19 to float
  tail call void @glVertex2f(float noundef %21, float noundef %14)
  %22 = fptrunc double %20 to float
  tail call void @glVertex2f(float noundef %22, float noundef %14)
  tail call void @glVertex2f(float noundef %22, float noundef %15)
  tail call void @glVertex2f(float noundef %21, float noundef %15)
  %23 = load double, ptr @BACKGROUND_COLOUR_R, align 8, !tbaa !5
  %24 = fptrunc double %23 to float
  %25 = load double, ptr @BACKGROUND_COLOUR_G, align 8, !tbaa !5
  %26 = fptrunc double %25 to float
  %27 = load double, ptr @BACKGROUND_COLOUR_B, align 8, !tbaa !5
  %28 = fptrunc double %27 to float
  tail call void @glColor3f(float noundef %24, float noundef %26, float noundef %28)
  %29 = extractelement <2 x double> %18, i64 1
  %30 = fadd double %19, %29
  %31 = fadd double %9, %29
  %32 = fsub double %20, %29
  %33 = fsub double %10, %29
  %34 = fptrunc double %30 to float
  %35 = fptrunc double %31 to float
  tail call void @glVertex2f(float noundef %34, float noundef %35)
  %36 = fptrunc double %32 to float
  tail call void @glVertex2f(float noundef %36, float noundef %35)
  %37 = fptrunc double %33 to float
  tail call void @glVertex2f(float noundef %36, float noundef %37)
  tail call void @glVertex2f(float noundef %34, float noundef %37)
  ret void
}

declare void @glColor3f(float noundef, float noundef, float noundef) local_unnamed_addr #0

attributes #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 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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass