; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/gtc/gtc_round.ll (ZN23ceilPowerOfTwo_advanced10test_int32Ev)

; 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.ceilPowerOfTwo_advanced::type" = type { i32, i32 }

@__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data = external hidden unnamed_addr constant [12 x %"struct.ceilPowerOfTwo_advanced::type"], 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 noundef i32 @_ZN23ceilPowerOfTwo_advanced10test_int32Ev() #2 {
  %1 = alloca [12 x %"struct.ceilPowerOfTwo_advanced::type"], align 16
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 96, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 96, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 12, ptr %4, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %27, %0
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = load i64, ptr %4, align 8, !tbaa !9
  %9 = icmp ult i64 %7, %8
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %12 = load i64, ptr %3, align 8, !tbaa !9
  %13 = getelementptr inbounds [12 x %"struct.ceilPowerOfTwo_advanced::type"], ptr %1, i64 0, i64 %12
  %14 = getelementptr inbounds %"struct.ceilPowerOfTwo_advanced::type", ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %15)
  store i32 %16, ptr %5, align 4, !tbaa !5
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds [12 x %"struct.ceilPowerOfTwo_advanced::type"], ptr %1, i64 0, i64 %17
  %19 = getelementptr inbounds %"struct.ceilPowerOfTwo_advanced::type", ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp eq i32 %20, %21
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 0, i32 1
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, %24
  store i32 %26, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %27

27:                                               ; preds = %11
  %28 = load i64, ptr %3, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !14

30:                                               ; preds = %10
  %31 = load i32, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr %1) #4
  ret i32 %31
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN23ceilPowerOfTwo_advanced4typeIiEE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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.ceilPowerOfTwo_advanced::type" = type { i32, i32 }

@__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data = external hidden unnamed_addr constant [12 x %"struct.ceilPowerOfTwo_advanced::type"], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN23ceilPowerOfTwo_advanced10test_int32Ev() local_unnamed_addr #0 {
  %1 = load i32, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, align 16, !tbaa !5
  %2 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %1)
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 4), align 4, !tbaa !10
  %4 = icmp ne i32 %3, %2
  %5 = zext i1 %4 to i32
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 8), align 8, !tbaa !5
  %7 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %6)
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 12), align 4, !tbaa !10
  %9 = icmp ne i32 %8, %7
  %10 = zext i1 %9 to i32
  %11 = add nuw nsw i32 %5, %10
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 16), align 16, !tbaa !5
  %13 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %12)
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 20), align 4, !tbaa !10
  %15 = icmp ne i32 %14, %13
  %16 = zext i1 %15 to i32
  %17 = add nuw nsw i32 %11, %16
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 24), align 8, !tbaa !5
  %19 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %18)
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 28), align 4, !tbaa !10
  %21 = icmp ne i32 %20, %19
  %22 = zext i1 %21 to i32
  %23 = add nuw nsw i32 %17, %22
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 32), align 16, !tbaa !5
  %25 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %24)
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 36), align 4, !tbaa !10
  %27 = icmp ne i32 %26, %25
  %28 = zext i1 %27 to i32
  %29 = add nuw nsw i32 %23, %28
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 40), align 8, !tbaa !5
  %31 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %30)
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 44), align 4, !tbaa !10
  %33 = icmp ne i32 %32, %31
  %34 = zext i1 %33 to i32
  %35 = add nuw nsw i32 %29, %34
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 48), align 16, !tbaa !5
  %37 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %36)
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 52), align 4, !tbaa !10
  %39 = icmp ne i32 %38, %37
  %40 = zext i1 %39 to i32
  %41 = add nuw nsw i32 %35, %40
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 56), align 8, !tbaa !5
  %43 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %42)
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 60), align 4, !tbaa !10
  %45 = icmp ne i32 %44, %43
  %46 = zext i1 %45 to i32
  %47 = add nuw nsw i32 %41, %46
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 64), align 16, !tbaa !5
  %49 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %48)
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 68), align 4, !tbaa !10
  %51 = icmp ne i32 %50, %49
  %52 = zext i1 %51 to i32
  %53 = add nuw nsw i32 %47, %52
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 72), align 8, !tbaa !5
  %55 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %54)
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 76), align 4, !tbaa !10
  %57 = icmp ne i32 %56, %55
  %58 = zext i1 %57 to i32
  %59 = add nuw nsw i32 %53, %58
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 80), align 16, !tbaa !5
  %61 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %60)
  %62 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 84), align 4, !tbaa !10
  %63 = icmp ne i32 %62, %61
  %64 = zext i1 %63 to i32
  %65 = add nuw nsw i32 %59, %64
  %66 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 88), align 8, !tbaa !5
  %67 = tail call noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef %66)
  %68 = load i32, ptr getelementptr inbounds (i8, ptr @__const._ZN23ceilPowerOfTwo_advanced10test_int32Ev.Data, i64 92), align 4, !tbaa !10
  %69 = icmp ne i32 %68, %67
  %70 = zext i1 %69 to i32
  %71 = add nuw nsw i32 %65, %70
  ret i32 %71
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3glm14ceilPowerOfTwoIiEET_S1_(i32 noundef) 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 = { inlinehint 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, !7, i64 0}
!6 = !{!"_ZTSN23ceilPowerOfTwo_advanced4typeIiEE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass