; LLVM IR from hoytech/vmtouch :: vmtouch (parse_size)

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

@.str.31 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden void @fatal(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i64 @parse_size(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call i64 @strlen(ptr noundef %11) #6
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store ptr @.str.31, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %16, label %18

16:                                               ; preds = %1
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ...) @fatal(ptr noundef %17)
  br label %18

18:                                               ; preds = %16, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %19 = call ptr @__ctype_tolower_loc() #7
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %21, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %20, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  store i32 %30, ptr %9, align 4, !tbaa !9
  %31 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %31, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = trunc i32 %32 to i8
  store i8 %33, ptr %6, align 1, !tbaa !11
  %34 = call ptr @__ctype_b_loc() #7
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = load i8, ptr %6, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i16, ptr %35, i64 %38
  %40 = load i16, ptr %39, align 2, !tbaa !12
  %41 = zext i16 %40 to i32
  %42 = and i32 %41, 1024
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %59

44:                                               ; preds = %18
  %45 = load i8, ptr %6, align 1, !tbaa !11
  %46 = sext i8 %45 to i32
  switch i32 %46, label %50 [
    i32 107, label %47
    i32 109, label %48
    i32 103, label %49
  ]

47:                                               ; preds = %44
  store i32 1024, ptr %7, align 4, !tbaa !9
  br label %53

48:                                               ; preds = %44
  store i32 1048576, ptr %7, align 4, !tbaa !9
  br label %53

49:                                               ; preds = %44
  store i32 1073741824, ptr %7, align 4, !tbaa !9
  br label %53

50:                                               ; preds = %44
  %51 = load i8, ptr %6, align 1, !tbaa !11
  %52 = sext i8 %51 to i32
  call void (ptr, ...) @fatal(ptr noundef @.str.32, i32 noundef %52)
  br label %53

53:                                               ; preds = %50, %49, %48, %47
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %54, i64 %57
  store i8 0, ptr %58, align 1, !tbaa !11
  br label %59

59:                                               ; preds = %53, %18
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = call double @strtod(ptr noundef %60, ptr noundef %3) #5
  store double %61, ptr %8, align 8, !tbaa !14
  %62 = load double, ptr %8, align 8, !tbaa !14
  %63 = fcmp olt double %62, 0.000000e+00
  br i1 %63, label %72, label %64

64:                                               ; preds = %59
  %65 = load double, ptr %8, align 8, !tbaa !14
  %66 = fcmp oeq double %65, 0x7FF0000000000000
  br i1 %66, label %72, label %67

67:                                               ; preds = %64
  %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 ne i32 %70, 0
  br i1 %71, label %72, label %74

72:                                               ; preds = %67, %64, %59
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ...) @fatal(ptr noundef %73)
  br label %74

74:                                               ; preds = %72, %67
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = sitofp i32 %75 to double
  %77 = load double, ptr %8, align 8, !tbaa !14
  %78 = fmul double %77, %76
  store double %78, ptr %8, align 8, !tbaa !14
  %79 = load double, ptr %8, align 8, !tbaa !14
  %80 = fcmp ogt double %79, 0x43E0000000000000
  br i1 %80, label %81, label %83

81:                                               ; preds = %74
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ...) @fatal(ptr noundef %82)
  br label %83

83:                                               ; preds = %81, %74
  %84 = load double, ptr %8, align 8, !tbaa !14
  %85 = fptosi double %84 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret i64 %85
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nounwind
declare double @strtod(ptr noundef, ptr noundef) #4

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 = { 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 #4 = { nounwind "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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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 = !{!15, !15, i64 0}
!15 = !{!"double", !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"

@.str.31 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden void @fatal(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @parse_size(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %4 = trunc i64 %3 to i32
  %5 = icmp slt i32 %4, 1
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  tail call void (ptr, ...) @fatal(ptr noundef nonnull @.str.31)
  br label %7

7:                                                ; preds = %6, %1
  %8 = tail call ptr @__ctype_tolower_loc() #8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = shl i64 %3, 32
  %sext = add i64 %10, -4294967296
  %11 = ashr exact i64 %sext, 32
  %12 = getelementptr inbounds i8, ptr %0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = sext i8 %13 to i64
  %15 = getelementptr inbounds i32, ptr %9, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !10
  %17 = tail call ptr @__ctype_b_loc() #8
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %sext21 = shl i32 %16, 24
  %19 = ashr exact i32 %sext21, 24
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i16, ptr %18, i64 %20
  %22 = load i16, ptr %21, align 2, !tbaa !12
  %23 = and i16 %22, 1024
  %.not = icmp eq i16 %23, 0
  br i1 %.not, label %29, label %24

24:                                               ; preds = %7
  switch i32 %19, label %27 [
    i32 107, label %28
    i32 109, label %25
    i32 103, label %26
  ]

25:                                               ; preds = %24
  br label %28

26:                                               ; preds = %24
  br label %28

27:                                               ; preds = %24
  tail call void (ptr, ...) @fatal(ptr noundef nonnull @.str.32, i32 noundef %19)
  br label %28

28:                                               ; preds = %24, %27, %26, %25
  %.0 = phi double [ 1.000000e+00, %27 ], [ 0x41D0000000000000, %26 ], [ 0x4130000000000000, %25 ], [ 1.024000e+03, %24 ]
  store i8 0, ptr %12, align 1, !tbaa !9
  br label %29

29:                                               ; preds = %28, %7
  %.1 = phi double [ %.0, %28 ], [ 1.000000e+00, %7 ]
  %30 = call double @strtod(ptr noundef nonnull %0, ptr noundef nonnull %2) #6
  %or.cond = tail call i1 @llvm.is.fpclass.f64(double %30, i32 540)
  br i1 %or.cond, label %34, label %31

31:                                               ; preds = %29
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %.not22 = icmp eq i8 %33, 0
  br i1 %.not22, label %35, label %34

34:                                               ; preds = %31, %29
  tail call void (ptr, ...) @fatal(ptr noundef nonnull @.str.31)
  br label %35

35:                                               ; preds = %34, %31
  %36 = fmul double %.1, %30
  %37 = fcmp ogt double %36, 0x43E0000000000000
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  tail call void (ptr, ...) @fatal(ptr noundef nonnull @.str.31)
  br label %39

39:                                               ; preds = %38, %35
  %40 = fptosi double %36 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret i64 %40
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress nofree nounwind willreturn
declare double @strtod(ptr noundef readonly, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f64(double, i32 immarg) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { 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 #4 = { mustprogress nofree nounwind willreturn "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass