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

@num_messages = external hidden global i32, align 4
@.str.307 = external hidden unnamed_addr constant [48 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: nounwind uwtable
declare dso_local void @parser_init(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @parse_count_body(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @message_eq(i32 noundef, i32 noundef, ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden void @print_error(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_message_count_body(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.message, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !9
  call void @parser_init(i32 noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.message, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = call i64 @strlen(ptr noundef %13) #6
  store i64 %14, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 4024, ptr %7, align 8, !tbaa !15
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %49, %1
  %16 = load i64, ptr %5, align 8, !tbaa !15
  %17 = load i64, ptr %4, align 8, !tbaa !15
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %19, label %53

19:                                               ; preds = %15
  %20 = load i64, ptr %4, align 8, !tbaa !15
  %21 = load i64, ptr %5, align 8, !tbaa !15
  %22 = sub i64 %20, %21
  %23 = load i64, ptr %7, align 8, !tbaa !15
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %25, label %29

25:                                               ; preds = %19
  %26 = load i64, ptr %4, align 8, !tbaa !15
  %27 = load i64, ptr %5, align 8, !tbaa !15
  %28 = sub i64 %26, %27
  br label %31

29:                                               ; preds = %19
  %30 = load i64, ptr %7, align 8, !tbaa !15
  br label %31

31:                                               ; preds = %29, %25
  %32 = phi i64 [ %28, %25 ], [ %30, %29 ]
  store i64 %32, ptr %6, align 8, !tbaa !15
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.message, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load i64, ptr %5, align 8, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %35, i64 %36
  %38 = load i64, ptr %6, align 8, !tbaa !15
  %39 = call i64 @parse_count_body(ptr noundef %37, i64 noundef %38)
  store i64 %39, ptr %3, align 8, !tbaa !15
  %40 = load i64, ptr %3, align 8, !tbaa !15
  %41 = load i64, ptr %6, align 8, !tbaa !15
  %42 = icmp ne i64 %40, %41
  br i1 %42, label %43, label %48

43:                                               ; preds = %31
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.message, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = load i64, ptr %3, align 8, !tbaa !15
  call void @print_error(ptr noundef %46, i64 noundef %47)
  call void @abort() #7
  unreachable

48:                                               ; preds = %31
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %7, align 8, !tbaa !15
  %51 = load i64, ptr %5, align 8, !tbaa !15
  %52 = add i64 %51, %50
  store i64 %52, ptr %5, align 8, !tbaa !15
  br label %15, !llvm.loop !16

53:                                               ; preds = %15
  %54 = call i64 @parse_count_body(ptr noundef null, i64 noundef 0)
  store i64 %54, ptr %3, align 8, !tbaa !15
  %55 = load i64, ptr %3, align 8, !tbaa !15
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %57, label %62

57:                                               ; preds = %53
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.message, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = load i64, ptr %3, align 8, !tbaa !15
  call void @print_error(ptr noundef %60, i64 noundef %61)
  call void @abort() #7
  unreachable

62:                                               ; preds = %53
  %63 = load i32, ptr @num_messages, align 4, !tbaa !18
  %64 = icmp ne i32 %63, 1
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.message, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !19
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.307, ptr noundef %68)
  call void @abort() #7
  unreachable

70:                                               ; preds = %62
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call i32 @message_eq(i32 noundef 0, i32 noundef 0, ptr noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  call void @abort() #7
  unreachable

75:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

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 = { 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 = { "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 = { 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, !11, i64 16}
!10 = !{!"message", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !7, i64 2076, !7, i64 4124, !7, i64 6172, !7, i64 8220, !7, i64 10268, !12, i64 12320, !6, i64 12328, !6, i64 12336, !13, i64 12344, !11, i64 12348, !11, i64 12352, !7, i64 12356, !11, i64 65604, !11, i64 65608, !11, i64 65612, !7, i64 65616, !6, i64 65680, !13, i64 65688, !13, i64 65690, !11, i64 65692, !11, i64 65696, !11, i64 65700, !11, i64 65704, !11, i64 65708, !11, i64 65712}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!12, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !6, 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"

@num_messages = external hidden local_unnamed_addr global i32, align 4
@.str.307 = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @parser_init(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @parse_count_body(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @print_error(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_message_count_body(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i32, ptr %2, align 8, !tbaa !5
  tail call void @parser_init(i32 noundef %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %5) #5
  %.not30 = icmp eq i64 %6, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph

7:                                                ; preds = %.lr.ph
  %8 = add i64 %.029, 4024
  %9 = icmp ult i64 %8, %6
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !14

.lr.ph:                                           ; preds = %1, %7
  %.029 = phi i64 [ %8, %7 ], [ 0, %1 ]
  %10 = sub i64 %6, %.029
  %11 = tail call i64 @llvm.umin.i64(i64 %10, i64 4024)
  %12 = load ptr, ptr %4, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %12, i64 %.029
  %14 = tail call i64 @parse_count_body(ptr noundef %13, i64 noundef %11)
  %.not28 = icmp eq i64 %14, %11
  br i1 %.not28, label %7, label %15

15:                                               ; preds = %.lr.ph
  %16 = load ptr, ptr %4, align 8, !tbaa !13
  tail call void @print_error(ptr noundef %16, i64 noundef %14)
  tail call void @abort() #6
  unreachable

._crit_edge:                                      ; preds = %7, %1
  %17 = tail call i64 @parse_count_body(ptr noundef null, i64 noundef 0)
  %.not = icmp eq i64 %17, 0
  br i1 %.not, label %20, label %18

18:                                               ; preds = %._crit_edge
  %19 = load ptr, ptr %4, align 8, !tbaa !13
  tail call void @print_error(ptr noundef %19, i64 noundef %17)
  tail call void @abort() #6
  unreachable

20:                                               ; preds = %._crit_edge
  %21 = load i32, ptr @num_messages, align 4, !tbaa !16
  %.not26 = icmp eq i32 %21, 1
  br i1 %.not26, label %25, label %22

22:                                               ; preds = %20
  %23 = load ptr, ptr %0, align 8, !tbaa !17
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.307, ptr noundef %23)
  tail call void @abort() #6
  unreachable

25:                                               ; preds = %20
  %26 = tail call i32 @message_eq(i32 noundef 0, i32 noundef 0, ptr noundef nonnull %0)
  %.not27 = icmp eq i32 %26, 0
  br i1 %.not27, label %27, label %28

27:                                               ; preds = %25
  tail call void @abort() #6
  unreachable

28:                                               ; preds = %25
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #4

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


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