; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/gtx/gtx_integer.ll (Z8test_nlzv)

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

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z8test_nlzv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %18, %0
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 33
  br i1 %5, label %7, label %6

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

7:                                                ; preds = %3
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = call noundef i32 @_ZN3glm3nlzEj(i32 noundef %8)
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef %10)
  %12 = sub i32 31, %11
  %13 = icmp eq i32 %9, %12
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 0, i32 1
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr %1, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %7
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = add i32 %19, 1
  store i32 %20, ptr %2, align 4, !tbaa !5
  br label %3, !llvm.loop !9

21:                                               ; preds = %6
  %22 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %22
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3nlzEj(i32 noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { inlinehint mustprogress 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 #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 = distinct !{!9, !10}
!10 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z8test_nlzv() local_unnamed_addr #0 {
  %1 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 1)
  %2 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 1)
  %3 = sub i32 31, %2
  %4 = icmp ne i32 %1, %3
  %5 = zext i1 %4 to i32
  %6 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 2)
  %7 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 2)
  %8 = sub i32 31, %7
  %9 = icmp ne i32 %6, %8
  %10 = zext i1 %9 to i32
  %11 = add nuw nsw i32 %5, %10
  %12 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 3)
  %13 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 3)
  %14 = sub i32 31, %13
  %15 = icmp ne i32 %12, %14
  %16 = zext i1 %15 to i32
  %17 = add nuw nsw i32 %11, %16
  %18 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 4)
  %19 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 4)
  %20 = sub i32 31, %19
  %21 = icmp ne i32 %18, %20
  %22 = zext i1 %21 to i32
  %23 = add nuw nsw i32 %17, %22
  %24 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 5)
  %25 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 5)
  %26 = sub i32 31, %25
  %27 = icmp ne i32 %24, %26
  %28 = zext i1 %27 to i32
  %29 = add nuw nsw i32 %23, %28
  %30 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 6)
  %31 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 6)
  %32 = sub i32 31, %31
  %33 = icmp ne i32 %30, %32
  %34 = zext i1 %33 to i32
  %35 = add nuw nsw i32 %29, %34
  %36 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 7)
  %37 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 7)
  %38 = sub i32 31, %37
  %39 = icmp ne i32 %36, %38
  %40 = zext i1 %39 to i32
  %41 = add nuw nsw i32 %35, %40
  %42 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 8)
  %43 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 8)
  %44 = sub i32 31, %43
  %45 = icmp ne i32 %42, %44
  %46 = zext i1 %45 to i32
  %47 = add nuw nsw i32 %41, %46
  %48 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 9)
  %49 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 9)
  %50 = sub i32 31, %49
  %51 = icmp ne i32 %48, %50
  %52 = zext i1 %51 to i32
  %53 = add nuw nsw i32 %47, %52
  %54 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 10)
  %55 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 10)
  %56 = sub i32 31, %55
  %57 = icmp ne i32 %54, %56
  %58 = zext i1 %57 to i32
  %59 = add nuw nsw i32 %53, %58
  %60 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 11)
  %61 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 11)
  %62 = sub i32 31, %61
  %63 = icmp ne i32 %60, %62
  %64 = zext i1 %63 to i32
  %65 = add nuw nsw i32 %59, %64
  %66 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 12)
  %67 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 12)
  %68 = sub i32 31, %67
  %69 = icmp ne i32 %66, %68
  %70 = zext i1 %69 to i32
  %71 = add nuw nsw i32 %65, %70
  %72 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 13)
  %73 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 13)
  %74 = sub i32 31, %73
  %75 = icmp ne i32 %72, %74
  %76 = zext i1 %75 to i32
  %77 = add nuw nsw i32 %71, %76
  %78 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 14)
  %79 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 14)
  %80 = sub i32 31, %79
  %81 = icmp ne i32 %78, %80
  %82 = zext i1 %81 to i32
  %83 = add nuw nsw i32 %77, %82
  %84 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 15)
  %85 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 15)
  %86 = sub i32 31, %85
  %87 = icmp ne i32 %84, %86
  %88 = zext i1 %87 to i32
  %89 = add nuw nsw i32 %83, %88
  %90 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 16)
  %91 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 16)
  %92 = sub i32 31, %91
  %93 = icmp ne i32 %90, %92
  %94 = zext i1 %93 to i32
  %95 = add nuw nsw i32 %89, %94
  %96 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 17)
  %97 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 17)
  %98 = sub i32 31, %97
  %99 = icmp ne i32 %96, %98
  %100 = zext i1 %99 to i32
  %101 = add nuw nsw i32 %95, %100
  %102 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 18)
  %103 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 18)
  %104 = sub i32 31, %103
  %105 = icmp ne i32 %102, %104
  %106 = zext i1 %105 to i32
  %107 = add nuw nsw i32 %101, %106
  %108 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 19)
  %109 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 19)
  %110 = sub i32 31, %109
  %111 = icmp ne i32 %108, %110
  %112 = zext i1 %111 to i32
  %113 = add nuw nsw i32 %107, %112
  %114 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 20)
  %115 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 20)
  %116 = sub i32 31, %115
  %117 = icmp ne i32 %114, %116
  %118 = zext i1 %117 to i32
  %119 = add nuw nsw i32 %113, %118
  %120 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 21)
  %121 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 21)
  %122 = sub i32 31, %121
  %123 = icmp ne i32 %120, %122
  %124 = zext i1 %123 to i32
  %125 = add nuw nsw i32 %119, %124
  %126 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 22)
  %127 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 22)
  %128 = sub i32 31, %127
  %129 = icmp ne i32 %126, %128
  %130 = zext i1 %129 to i32
  %131 = add nuw nsw i32 %125, %130
  %132 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 23)
  %133 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 23)
  %134 = sub i32 31, %133
  %135 = icmp ne i32 %132, %134
  %136 = zext i1 %135 to i32
  %137 = add nuw nsw i32 %131, %136
  %138 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 24)
  %139 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 24)
  %140 = sub i32 31, %139
  %141 = icmp ne i32 %138, %140
  %142 = zext i1 %141 to i32
  %143 = add nuw nsw i32 %137, %142
  %144 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 25)
  %145 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 25)
  %146 = sub i32 31, %145
  %147 = icmp ne i32 %144, %146
  %148 = zext i1 %147 to i32
  %149 = add nuw nsw i32 %143, %148
  %150 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 26)
  %151 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 26)
  %152 = sub i32 31, %151
  %153 = icmp ne i32 %150, %152
  %154 = zext i1 %153 to i32
  %155 = add nuw nsw i32 %149, %154
  %156 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 27)
  %157 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 27)
  %158 = sub i32 31, %157
  %159 = icmp ne i32 %156, %158
  %160 = zext i1 %159 to i32
  %161 = add nuw nsw i32 %155, %160
  %162 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 28)
  %163 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 28)
  %164 = sub i32 31, %163
  %165 = icmp ne i32 %162, %164
  %166 = zext i1 %165 to i32
  %167 = add nuw nsw i32 %161, %166
  %168 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 29)
  %169 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 29)
  %170 = sub i32 31, %169
  %171 = icmp ne i32 %168, %170
  %172 = zext i1 %171 to i32
  %173 = add nuw nsw i32 %167, %172
  %174 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 30)
  %175 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 30)
  %176 = sub i32 31, %175
  %177 = icmp ne i32 %174, %176
  %178 = zext i1 %177 to i32
  %179 = add nuw nsw i32 %173, %178
  %180 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 31)
  %181 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 31)
  %182 = sub i32 31, %181
  %183 = icmp ne i32 %180, %182
  %184 = zext i1 %183 to i32
  %185 = add nuw nsw i32 %179, %184
  %186 = tail call noundef i32 @_ZN3glm3nlzEj(i32 noundef 32)
  %187 = tail call noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef 32)
  %188 = sub i32 31, %187
  %189 = icmp ne i32 %186, %188
  %190 = zext i1 %189 to i32
  %191 = add nuw nsw i32 %185, %190
  ret i32 %191
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3glm3nlzEj(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3glm7findMSBIjEEiT_(i32 noundef) local_unnamed_addr #2

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


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