; LLVM IR from Dovyski/opengl-demos :: src/culling/main.ll (Z8keyboardiii)

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

@rX = external dso_local global float, align 4
@rY = external dso_local global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 102
  br i1 %8, label %9, label %12

9:                                                ; preds = %3
  %10 = load float, ptr @rY, align 4, !tbaa !9
  %11 = fadd float %10, 5.000000e+00
  store float %11, ptr @rY, align 4, !tbaa !9
  br label %33

12:                                               ; preds = %3
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 100
  br i1 %14, label %15, label %18

15:                                               ; preds = %12
  %16 = load float, ptr @rY, align 4, !tbaa !9
  %17 = fsub float %16, 5.000000e+00
  store float %17, ptr @rY, align 4, !tbaa !9
  br label %32

18:                                               ; preds = %12
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 103
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load float, ptr @rX, align 4, !tbaa !9
  %23 = fsub float %22, 5.000000e+00
  store float %23, ptr @rX, align 4, !tbaa !9
  br label %31

24:                                               ; preds = %18
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 101
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load float, ptr @rX, align 4, !tbaa !9
  %29 = fadd float %28, 5.000000e+00
  store float %29, ptr @rX, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %27, %24
  br label %31

31:                                               ; preds = %30, %21
  br label %32

32:                                               ; preds = %31, %15
  br label %33

33:                                               ; preds = %32, %9
  call void @glutPostRedisplay()
  ret void
}

declare void @glutPostRedisplay() #1

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

!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 = !{!"float", !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"

@rX = external dso_local local_unnamed_addr global float, align 4
@rY = external dso_local local_unnamed_addr global float, align 4
@switch.table._Z8keyboardiii = private unnamed_addr constant [4 x ptr] [ptr @rY, ptr @rX, ptr @rY, ptr @rX], align 8
@switch.table._Z8keyboardiii.1 = private unnamed_addr constant [4 x float] [float -5.000000e+00, float 5.000000e+00, float 5.000000e+00, float -5.000000e+00], align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %switch.tableidx = add i32 %0, -100
  %4 = icmp ult i32 %switch.tableidx, 4
  br i1 %4, label %switch.lookup, label %9

switch.lookup:                                    ; preds = %3
  %5 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x ptr], ptr @switch.table._Z8keyboardiii, i64 0, i64 %5
  %switch.load = load ptr, ptr %switch.gep, align 8
  %6 = zext nneg i32 %switch.tableidx to i64
  %switch.gep7 = getelementptr inbounds [4 x float], ptr @switch.table._Z8keyboardiii.1, i64 0, i64 %6
  %switch.load8 = load float, ptr %switch.gep7, align 4
  %7 = load float, ptr %switch.load, align 4, !tbaa !5
  %8 = fadd float %7, %switch.load8
  store float %8, ptr %switch.load, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %3, %switch.lookup
  tail call void @glutPostRedisplay()
  ret void
}

declare void @glutPostRedisplay() local_unnamed_addr #1

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

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


; Effective O3 passes: GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass