; 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.http_parser = type { i32, i32, i64, i16, i16, i32, ptr }
%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 }

@.str.151 = external hidden unnamed_addr constant [76 x i8], align 1
@parser = external hidden global %struct.http_parser, align 8
@.str.153 = external hidden unnamed_addr constant [13 x i8], align 1
@messages = external hidden global [5 x %struct.message], align 16
@num_messages = external hidden global i32, align 4
@stderr = external global ptr, align 8
@.str.154 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.message_complete_cb = external hidden unnamed_addr constant [39 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [135 x i8], align 1
@currently_parsing_eof = external hidden global i32, align 4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare i32 @http_body_is_final(ptr noundef) #2

declare i32 @http_should_keep_alive(ptr noundef) #2

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

5:                                                ; preds = %1
  br label %7

6:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.153, ptr noundef @.str.151, i32 noundef 2213, ptr noundef @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

7:                                                ; preds = %5
  %8 = load i32, ptr @num_messages, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %9
  %11 = getelementptr inbounds %struct.message, ptr %10, i32 0, i32 18
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = call i32 @http_should_keep_alive(ptr noundef @parser)
  %14 = icmp ne i32 %12, %13
  br i1 %14, label %15, label %18

15:                                               ; preds = %7
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.158) #5
  call void @__assert_fail(ptr noundef @.str.155, ptr noundef @.str.151, i32 noundef 2220, ptr noundef @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

18:                                               ; preds = %7
  %19 = load i32, ptr @num_messages, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.message, ptr %21, i32 0, i32 11
  %23 = load i64, ptr %22, align 8, !tbaa !15
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %39

25:                                               ; preds = %18
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = call i32 @http_body_is_final(ptr noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %39

29:                                               ; preds = %25
  %30 = load i32, ptr @num_messages, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.message, ptr %32, i32 0, i32 30
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %39, label %36

36:                                               ; preds = %29
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.154) #5
  call void @__assert_fail(ptr noundef @.str.155, ptr noundef @.str.151, i32 noundef 2231, ptr noundef @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

39:                                               ; preds = %29, %25, %18
  %40 = load i32, ptr @num_messages, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.message, ptr %42, i32 0, i32 27
  store i32 1, ptr %43, align 4, !tbaa !17
  %44 = load i32, ptr @currently_parsing_eof, align 4, !tbaa !9
  %45 = load i32, ptr @num_messages, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.message, ptr %47, i32 0, i32 29
  store i32 %44, ptr %48, align 4, !tbaa !18
  %49 = load i32, ptr @num_messages, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr @num_messages, align 4, !tbaa !9
  ret i32 0
}

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


; 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.http_parser = type { i32, i32, i64, i16, i16, i32, ptr }
%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 }

@.str.151 = external hidden unnamed_addr constant [76 x i8], align 1
@parser = external hidden global %struct.http_parser, align 8
@.str.153 = external hidden unnamed_addr constant [13 x i8], align 1
@messages = external hidden local_unnamed_addr global [5 x %struct.message], align 16
@num_messages = external hidden local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.154 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.message_complete_cb = external hidden unnamed_addr constant [39 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [135 x i8], align 1
@currently_parsing_eof = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

declare i32 @http_body_is_final(ptr noundef) local_unnamed_addr #2

declare i32 @http_should_keep_alive(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @message_complete_cb(ptr noundef readnone %0) local_unnamed_addr #3 {
  %2 = icmp eq ptr %0, @parser
  br i1 %2, label %4, label %3

3:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.153, ptr noundef nonnull @.str.151, i32 noundef 2213, ptr noundef nonnull @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

4:                                                ; preds = %1
  %5 = load i32, ptr @num_messages, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %6, i32 18
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = tail call i32 @http_should_keep_alive(ptr noundef nonnull @parser) #5
  %.not = icmp eq i32 %8, %9
  br i1 %.not, label %13, label %10

10:                                               ; preds = %4
  %11 = load ptr, ptr @stderr, align 8, !tbaa !14
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.158) #6
  tail call void @__assert_fail(ptr noundef nonnull @.str.155, ptr noundef nonnull @.str.151, i32 noundef 2220, ptr noundef nonnull @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

13:                                               ; preds = %4
  %14 = load i32, ptr @num_messages, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %15, i32 11
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %.not2 = icmp eq i64 %17, 0
  br i1 %.not2, label %._crit_edge, label %18

18:                                               ; preds = %13
  %19 = tail call i32 @http_body_is_final(ptr noundef nonnull @parser) #5
  %.not3 = icmp eq i32 %19, 0
  %.pre = load i32, ptr @num_messages, align 4, !tbaa !5
  %.pre5 = sext i32 %.pre to i64
  br i1 %.not3, label %._crit_edge, label %20

20:                                               ; preds = %18
  %21 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %.pre5, i32 30
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %.not4 = icmp eq i32 %22, 0
  br i1 %.not4, label %23, label %._crit_edge

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !14
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.154) #6
  tail call void @__assert_fail(ptr noundef nonnull @.str.155, ptr noundef nonnull @.str.151, i32 noundef 2231, ptr noundef nonnull @__PRETTY_FUNCTION__.message_complete_cb) #4
  unreachable

._crit_edge:                                      ; preds = %18, %20, %13
  %.pre-phi = phi i64 [ %.pre5, %20 ], [ %15, %13 ], [ %.pre5, %18 ]
  %26 = phi i32 [ %.pre, %20 ], [ %14, %13 ], [ %.pre, %18 ]
  %27 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %.pre-phi, i32 27
  store i32 1, ptr %27, align 4, !tbaa !17
  %28 = load i32, ptr @currently_parsing_eof, align 4, !tbaa !5
  %29 = getelementptr inbounds [5 x %struct.message], ptr @messages, i64 0, i64 %.pre-phi, i32 29
  store i32 %28, ptr %29, align 4, !tbaa !18
  %30 = add nsw i32 %26, 1
  store i32 %30, ptr @num_messages, align 4, !tbaa !5
  ret i32 0
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass