; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/ply.ll (Z13get_prop_typePc)

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

@type_names = external dso_local global [9 x ptr], align 16
@_ZZ13get_prop_typePcE14new_type_names = external hidden global [9 x ptr], 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @equal_strings(ptr noundef, ptr noundef) #1

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

6:                                                ; preds = %20, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 9
  br i1 %8, label %9, label %23

9:                                                ; preds = %6
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [9 x ptr], ptr @type_names, i64 0, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = call i32 @equal_strings(ptr noundef %10, ptr noundef %14)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %9
  %18 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %18, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %42

19:                                               ; preds = %9
  br label %20

20:                                               ; preds = %19
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !11

23:                                               ; preds = %6
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %38, %23
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 9
  br i1 %26, label %27, label %41

27:                                               ; preds = %24
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [9 x ptr], ptr @_ZZ13get_prop_typePcE14new_type_names, i64 0, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call i32 @equal_strings(ptr noundef %28, ptr noundef %32)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %27
  %36 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %36, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %42

37:                                               ; preds = %27
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %4, align 4, !tbaa !9
  br label %24, !llvm.loop !13

41:                                               ; preds = %24
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %42

42:                                               ; preds = %41, %35, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %43 = load i32, ptr %2, align 4
  ret i32 %43
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@type_names = external dso_local local_unnamed_addr global [9 x ptr], align 16
@_ZZ13get_prop_typePcE14new_type_names = external hidden local_unnamed_addr global [9 x ptr], align 16

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z13get_prop_typePc(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 8), align 8, !tbaa !5
  %3 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %2)
  %.not11 = icmp eq i32 %3, 0
  br i1 %.not11, label %4, label %.loopexit

4:                                                ; preds = %1
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 16), align 16, !tbaa !5
  %6 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %5)
  %.not11.1 = icmp eq i32 %6, 0
  br i1 %.not11.1, label %7, label %.loopexit

7:                                                ; preds = %4
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 24), align 8, !tbaa !5
  %9 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %8)
  %.not11.2 = icmp eq i32 %9, 0
  br i1 %.not11.2, label %10, label %.loopexit

10:                                               ; preds = %7
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 32), align 16, !tbaa !5
  %12 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %11)
  %.not11.3 = icmp eq i32 %12, 0
  br i1 %.not11.3, label %13, label %.loopexit

13:                                               ; preds = %10
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 40), align 8, !tbaa !5
  %15 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %14)
  %.not11.4 = icmp eq i32 %15, 0
  br i1 %.not11.4, label %16, label %.loopexit

16:                                               ; preds = %13
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 48), align 16, !tbaa !5
  %18 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %17)
  %.not11.5 = icmp eq i32 %18, 0
  br i1 %.not11.5, label %19, label %.loopexit

19:                                               ; preds = %16
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 56), align 8, !tbaa !5
  %21 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %20)
  %.not11.6 = icmp eq i32 %21, 0
  br i1 %.not11.6, label %22, label %.loopexit

22:                                               ; preds = %19
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @type_names, i64 64), align 16, !tbaa !5
  %24 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %23)
  %.not11.7 = icmp eq i32 %24, 0
  br i1 %.not11.7, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %22
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 8), align 8, !tbaa !5
  %26 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %25)
  %.not = icmp eq i32 %26, 0
  br i1 %.not, label %.preheader.1, label %.loopexit

.preheader.1:                                     ; preds = %.preheader.preheader
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 16), align 16, !tbaa !5
  %28 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %27)
  %.not.1 = icmp eq i32 %28, 0
  br i1 %.not.1, label %.preheader.2, label %.loopexit

.preheader.2:                                     ; preds = %.preheader.1
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 24), align 8, !tbaa !5
  %30 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %29)
  %.not.2 = icmp eq i32 %30, 0
  br i1 %.not.2, label %.preheader.3, label %.loopexit

.preheader.3:                                     ; preds = %.preheader.2
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 32), align 16, !tbaa !5
  %32 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %31)
  %.not.3 = icmp eq i32 %32, 0
  br i1 %.not.3, label %.preheader.4, label %.loopexit

.preheader.4:                                     ; preds = %.preheader.3
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 40), align 8, !tbaa !5
  %34 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %33)
  %.not.4 = icmp eq i32 %34, 0
  br i1 %.not.4, label %.preheader.5, label %.loopexit

.preheader.5:                                     ; preds = %.preheader.4
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 48), align 16, !tbaa !5
  %36 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %35)
  %.not.5 = icmp eq i32 %36, 0
  br i1 %.not.5, label %.preheader.6, label %.loopexit

.preheader.6:                                     ; preds = %.preheader.5
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 56), align 8, !tbaa !5
  %38 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %37)
  %.not.6 = icmp eq i32 %38, 0
  br i1 %.not.6, label %.preheader.7, label %.loopexit

.preheader.7:                                     ; preds = %.preheader.6
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZ13get_prop_typePcE14new_type_names, i64 64), align 16, !tbaa !5
  %40 = tail call i32 @equal_strings(ptr noundef %0, ptr noundef %39)
  %.not.7 = icmp eq i32 %40, 0
  %spec.select = select i1 %.not.7, i32 0, i32 8
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.7, %1, %4, %7, %10, %13, %16, %19, %22, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %.preheader.5, %.preheader.6
  %.010 = phi i32 [ 1, %.preheader.preheader ], [ 2, %.preheader.1 ], [ 3, %.preheader.2 ], [ 4, %.preheader.3 ], [ 5, %.preheader.4 ], [ 6, %.preheader.5 ], [ 7, %.preheader.6 ], [ 1, %1 ], [ 2, %4 ], [ 3, %7 ], [ 4, %10 ], [ 5, %13 ], [ 6, %16 ], [ 7, %19 ], [ 8, %22 ], [ %spec.select, %.preheader.7 ]
  ret i32 %.010
}

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

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


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