; LLVM IR from holzschu/ios_system :: ssh-agent/y.tab (is_integer)

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

@nonposix = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @is_integer(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load i32, ptr @nonposix, align 4, !tbaa !9
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %29

6:                                                ; preds = %1
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !11
  %9 = sext i8 %8 to i32
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  store i32 1, ptr %2, align 4
  br label %73

12:                                               ; preds = %6
  br label %13

13:                                               ; preds = %25, %12
  %14 = call ptr @__ctype_b_loc() #2
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i16, ptr %15, i64 %19
  %21 = load i16, ptr %20, align 2, !tbaa !12
  %22 = zext i16 %21 to i32
  %23 = and i32 %22, 8192
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %13
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i32 1
  store ptr %27, ptr %3, align 8, !tbaa !5
  br label %13, !llvm.loop !14

28:                                               ; preds = %13
  br label %29

29:                                               ; preds = %28, %1
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 45
  br i1 %33, label %42, label %34

34:                                               ; preds = %29
  %35 = load i32, ptr @nonposix, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %45

37:                                               ; preds = %34
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 43
  br i1 %41, label %42, label %45

42:                                               ; preds = %37, %29
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i32 1
  store ptr %44, ptr %3, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %42, %37, %34
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  store i32 0, ptr %2, align 4
  br label %73

51:                                               ; preds = %45
  br label %52

52:                                               ; preds = %64, %51
  %53 = call ptr @__ctype_b_loc() #2
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i8, ptr %55, align 1, !tbaa !11
  %57 = zext i8 %56 to i32
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i16, ptr %54, i64 %58
  %60 = load i16, ptr %59, align 2, !tbaa !12
  %61 = zext i16 %60 to i32
  %62 = and i32 %61, 2048
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %52
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i32 1
  store ptr %66, ptr %3, align 8, !tbaa !5
  br label %52, !llvm.loop !16

67:                                               ; preds = %52
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = sext i8 %69 to i32
  %71 = icmp eq i32 %70, 0
  %72 = zext i1 %71 to i32
  store i32 %72, ptr %2, align 4
  br label %73

73:                                               ; preds = %67, %50, %11
  %74 = load i32, ptr %2, align 4
  ret i32 %74
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #1

attributes #0 = { 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 #1 = { nounwind willreturn memory(none) "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 willreturn memory(none) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

@nonposix = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nofree nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @is_integer(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @nonposix, align 4, !tbaa !5
  %.not = icmp eq i32 %2, 0
  %.pre = load i8, ptr %0, align 1, !tbaa !9
  br i1 %.not, label %.loopexit, label %3

3:                                                ; preds = %1
  %4 = icmp eq i8 %.pre, 0
  br i1 %4, label %35, label %.preheader15

.preheader15:                                     ; preds = %3
  %5 = tail call ptr @__ctype_b_loc() #2
  %6 = load ptr, ptr %5, align 8, !tbaa !10
  br label %7

7:                                                ; preds = %7, %.preheader15
  %.0 = phi ptr [ %13, %7 ], [ %0, %.preheader15 ]
  %8 = load i8, ptr %.0, align 1, !tbaa !9
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds i16, ptr %6, i64 %9
  %11 = load i16, ptr %10, align 2, !tbaa !12
  %12 = and i16 %11, 8192
  %.not12 = icmp eq i16 %12, 0
  %13 = getelementptr inbounds i8, ptr %.0, i64 1
  br i1 %.not12, label %.loopexit, label %7, !llvm.loop !14

.loopexit:                                        ; preds = %7, %1
  %14 = phi i8 [ %.pre, %1 ], [ %8, %7 ]
  %.1 = phi ptr [ %0, %1 ], [ %.0, %7 ]
  %15 = icmp eq i8 %14, 45
  br i1 %15, label %18, label %16

16:                                               ; preds = %.loopexit
  %.not13 = icmp ne i32 %2, 0
  %17 = icmp eq i8 %14, 43
  %or.cond = and i1 %.not13, %17
  br i1 %or.cond, label %18, label %20

18:                                               ; preds = %16, %.loopexit
  %19 = getelementptr inbounds i8, ptr %.1, i64 1
  %.pre16 = load i8, ptr %19, align 1, !tbaa !9
  br label %20

20:                                               ; preds = %18, %16
  %21 = phi i8 [ %.pre16, %18 ], [ %14, %16 ]
  %.2 = phi ptr [ %19, %18 ], [ %.1, %16 ]
  %22 = icmp eq i8 %21, 0
  br i1 %22, label %35, label %.preheader

.preheader:                                       ; preds = %20
  %23 = tail call ptr @__ctype_b_loc() #2
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  br label %25

25:                                               ; preds = %25, %.preheader
  %.3 = phi ptr [ %31, %25 ], [ %.2, %.preheader ]
  %26 = load i8, ptr %.3, align 1, !tbaa !9
  %27 = zext i8 %26 to i64
  %28 = getelementptr inbounds i16, ptr %24, i64 %27
  %29 = load i16, ptr %28, align 2, !tbaa !12
  %30 = and i16 %29, 2048
  %.not14 = icmp eq i16 %30, 0
  %31 = getelementptr inbounds i8, ptr %.3, i64 1
  br i1 %.not14, label %32, label %25, !llvm.loop !16

32:                                               ; preds = %25
  %33 = icmp eq i8 %26, 0
  %34 = zext i1 %33 to i32
  br label %35

35:                                               ; preds = %20, %3, %32
  %.010 = phi i32 [ %34, %32 ], [ 1, %3 ], [ 0, %20 ]
  ret i32 %.010
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #1

attributes #0 = { nofree nosync nounwind memory(read, inaccessiblemem: none) 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }

!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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass