; LLVM IR from apigee/apib :: third_party/http_parser (test)

; 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.message = type { ptr, ptr, i32, i32, i32, [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], i64, ptr, ptr, i16, i32, i32, [13 x [2 x [2048 x i8]]], i32, i32, i32, [16 x i32], ptr, i16, i16, i32, i32, i32, i32, i32, i32 }
%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@messages = external hidden global [5 x %struct.message], align 16
@num_messages = external hidden global i32, align 4
@.str.197 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.198 = external hidden unnamed_addr constant [50 x i8], align 1

; 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: noreturn nounwind
declare void @abort() #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_str_eq(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #4

; Function Attrs: nounwind uwtable
define dso_local void @upgrade_message_fix(ptr noundef %0, i64 noundef %1, i64 noundef %2, ...) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca [1 x %struct.__va_list_tag], align 16
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !9
  %12 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %7, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %12)
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %83, %3
  %14 = load i64, ptr %8, align 8, !tbaa !9
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %17, label %86

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %18 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %7, i64 0, i64 0
  %19 = getelementptr inbounds %struct.__va_list_tag, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 16
  %21 = icmp ule i32 %20, 40
  br i1 %21, label %22, label %27

22:                                               ; preds = %17
  %23 = getelementptr inbounds %struct.__va_list_tag, ptr %18, i32 0, i32 3
  %24 = load ptr, ptr %23, align 16
  %25 = getelementptr i8, ptr %24, i32 %20
  %26 = add i32 %20, 8
  store i32 %26, ptr %19, align 16
  br label %31

27:                                               ; preds = %17
  %28 = getelementptr inbounds %struct.__va_list_tag, ptr %18, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8
  %30 = getelementptr i8, ptr %29, i32 8
  store ptr %30, ptr %28, align 8
  br label %31

31:                                               ; preds = %27, %22
  %32 = phi ptr [ %25, %22 ], [ %29, %27 ]
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  store ptr %33, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.message, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = call i64 @strlen(ptr noundef %36) #8
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = add i64 %38, %37
  store i64 %39, ptr %9, align 8, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.message, ptr %40, i32 0, i32 22
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %79

44:                                               ; preds = %31
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.message, ptr %45, i32 0, i32 22
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = call i64 @strlen(ptr noundef %47) #8
  %49 = load i64, ptr %9, align 8, !tbaa !9
  %50 = sub i64 %49, %48
  store i64 %50, ptr %9, align 8, !tbaa !9
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = call i32 @check_str_eq(ptr noundef %51, ptr noundef @.str.197, ptr noundef %54, ptr noundef %57)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %44
  call void @abort() #9
  unreachable

61:                                               ; preds = %44
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds i8, ptr %62, i64 %63
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.message, ptr %65, i32 0, i32 22
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = call i64 @strlen(ptr noundef %67) #8
  %69 = getelementptr inbounds i8, ptr %64, i64 %68
  store i8 0, ptr %69, align 1, !tbaa !16
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i64, ptr %5, align 8, !tbaa !9
  %72 = getelementptr inbounds i8, ptr %70, i64 %71
  %73 = load i32, ptr @num_messages, align 4, !tbaa !17
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.message, ptr %76, i32 0, i32 22
  store ptr %72, ptr %77, align 8, !tbaa !15
  %78 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %7, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %78)
  store i32 1, ptr %11, align 4
  br label %80

79:                                               ; preds = %31
  store i32 0, ptr %11, align 4
  br label %80

80:                                               ; preds = %79, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  %81 = load i32, ptr %11, align 4
  switch i32 %81, label %89 [
    i32 0, label %82
  ]

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %8, align 8, !tbaa !9
  %85 = add i64 %84, 1
  store i64 %85, ptr %8, align 8, !tbaa !9
  br label %13, !llvm.loop !18

86:                                               ; preds = %13
  %87 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %7, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %87)
  %88 = call i32 (ptr, ...) @printf(ptr noundef @.str.198)
  call void @abort() #9
  unreachable

89:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #7
  ret void
}

declare i32 @printf(ptr noundef, ...) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { inlinehint 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 = { 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 #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #6 = { "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"message", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !7, i64 28, !7, i64 2076, !7, i64 4124, !7, i64 6172, !7, i64 8220, !7, i64 10268, !10, i64 12320, !6, i64 12328, !6, i64 12336, !14, i64 12344, !13, i64 12348, !13, i64 12352, !7, i64 12356, !13, i64 65604, !13, i64 65608, !13, i64 65612, !7, i64 65616, !6, i64 65680, !14, i64 65688, !14, i64 65690, !13, i64 65692, !13, i64 65696, !13, i64 65700, !13, i64 65704, !13, i64 65708, !13, i64 65712}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 65680}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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.message = type { ptr, ptr, i32, i32, i32, [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], i64, ptr, ptr, i16, i32, i32, [13 x [2 x [2048 x i8]]], i32, i32, i32, [16 x i32], ptr, i16, i16, i32, i32, i32, i32, i32, i32 }
%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@messages = external hidden local_unnamed_addr global [5 x %struct.message], align 16
@num_messages = external hidden local_unnamed_addr global i32, align 4
@.str.197 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.198 = external hidden unnamed_addr constant [50 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_str_eq(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #4

; Function Attrs: nounwind uwtable
define dso_local void @upgrade_message_fix(ptr noundef %0, i64 noundef %1, i64 noundef %2, ...) local_unnamed_addr #5 {
  %4 = alloca [1 x %struct.__va_list_tag], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #7
  call void @llvm.va_start.p0(ptr nonnull %4)
  %.not32 = icmp eq i64 %2, 0
  br i1 %.not32, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %.promoted = load i32, ptr %4, align 16
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  %7 = load ptr, ptr %6, align 16
  %.promoted31 = load ptr, ptr %5, align 8
  br label %10

8:                                                ; preds = %20
  %9 = add nuw i64 %.01830, 1
  %exitcond.not = icmp eq i64 %9, %2
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !5

10:                                               ; preds = %.lr.ph, %8
  %11 = phi ptr [ %.promoted31, %.lr.ph ], [ %21, %8 ]
  %.01830 = phi i64 [ 0, %.lr.ph ], [ %9, %8 ]
  %.01929 = phi i64 [ 0, %.lr.ph ], [ %28, %8 ]
  %12 = phi i32 [ %.promoted, %.lr.ph ], [ %22, %8 ]
  %13 = icmp ult i32 %12, 41
  br i1 %13, label %14, label %18

14:                                               ; preds = %10
  %15 = zext nneg i32 %12 to i64
  %16 = getelementptr i8, ptr %7, i64 %15
  %17 = add nuw nsw i32 %12, 8
  store i32 %17, ptr %4, align 16
  br label %20

18:                                               ; preds = %10
  %19 = getelementptr i8, ptr %11, i64 8
  store ptr %19, ptr %5, align 8
  br label %20

20:                                               ; preds = %18, %14
  %21 = phi ptr [ %11, %14 ], [ %19, %18 ]
  %22 = phi i32 [ %17, %14 ], [ %12, %18 ]
  %23 = phi ptr [ %16, %14 ], [ %11, %18 ]
  %24 = load ptr, ptr %23, align 8, !tbaa !7
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %26) #8
  %28 = add i64 %27, %.01929
  %29 = getelementptr inbounds i8, ptr %24, i64 65680
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %.not = icmp eq ptr %30, null
  br i1 %.not, label %8, label %31

31:                                               ; preds = %20
  %32 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %30) #8
  %33 = sub i64 %28, %32
  %34 = getelementptr inbounds i8, ptr %0, i64 %33
  %35 = getelementptr inbounds i8, ptr %0, i64 %1
  %36 = call i32 @check_str_eq(ptr noundef nonnull %24, ptr noundef nonnull @.str.197, ptr noundef %34, ptr noundef %35)
  %.not22 = icmp eq i32 %36, 0
  br i1 %.not22, label %37, label %39

37:                                               ; preds = %31
  call void @abort() #9
  unreachable

._crit_edge:                                      ; preds = %8, %3
  call void @llvm.va_end.p0(ptr nonnull %4)
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.198)
  call void @abort() #9
  unreachable

39:                                               ; preds = %31
  %40 = getelementptr inbounds i8, ptr %24, i64 65680
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %41) #8
  %43 = getelementptr inbounds i8, ptr %35, i64 %42
  store i8 0, ptr %43, align 1, !tbaa !17
  %44 = load i32, ptr @num_messages, align 4, !tbaa !18
  %45 = add nsw i32 %44, -1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %46, i32 22
  store ptr %35, ptr %47, align 8, !tbaa !16
  call void @llvm.va_end.p0(ptr nonnull %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #7
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { inlinehint 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 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #6 = { nofree 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !8, i64 8}
!12 = !{!"message", !8, i64 0, !8, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !9, i64 28, !9, i64 2076, !9, i64 4124, !9, i64 6172, !9, i64 8220, !9, i64 10268, !14, i64 12320, !8, i64 12328, !8, i64 12336, !15, i64 12344, !13, i64 12348, !13, i64 12352, !9, i64 12356, !13, i64 65604, !13, i64 65608, !13, i64 65612, !9, i64 65616, !8, i64 65680, !15, i64 65688, !15, i64 65690, !13, i64 65692, !13, i64 65696, !13, i64 65700, !13, i64 65704, !13, i64 65708, !13, i64 65712}
!13 = !{!"int", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = !{!"short", !9, i64 0}
!16 = !{!12, !8, i64 65680}
!17 = !{!9, !9, i64 0}
!18 = !{!13, !13, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass