; 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
@messages = external hidden global [5 x %struct.message], align 16
@num_messages = external hidden global i32, align 4
@.str.307 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.357 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__.test_message_pause = external hidden unnamed_addr constant [48 x i8], align 1
@.str.358 = external hidden unnamed_addr constant [11 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 @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

declare void @http_parser_pause(ptr noundef, i32 noundef) #2

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

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

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

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

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

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

17:                                               ; preds = %61, %1
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i64, ptr %4, align 8, !tbaa !14
  %20 = call i64 @parse_pause(ptr noundef %18, i64 noundef %19)
  store i64 %20, ptr %5, align 8, !tbaa !14
  %21 = load i32, ptr getelementptr inbounds (%struct.message, ptr @messages, i32 0, i32 27), align 4, !tbaa !16
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %36

23:                                               ; preds = %17
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.message, ptr %24, i32 0, i32 22
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %36

28:                                               ; preds = %23
  %29 = load i32, ptr getelementptr inbounds (%struct.http_parser, ptr @parser, i32 0, i32 5), align 4
  %30 = lshr i32 %29, 31
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %28
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load i64, ptr %5, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  store ptr %35, ptr getelementptr inbounds (%struct.message, ptr @messages, i32 0, i32 22), align 16, !tbaa !17
  br label %71

36:                                               ; preds = %28, %23, %17
  %37 = load i64, ptr %5, align 8, !tbaa !14
  %38 = load i64, ptr %4, align 8, !tbaa !14
  %39 = icmp ult i64 %37, %38
  br i1 %39, label %40, label %54

40:                                               ; preds = %36
  %41 = load i32, ptr getelementptr inbounds (%struct.http_parser, ptr @parser, i32 0, i32 5), align 4
  %42 = lshr i32 %41, 24
  %43 = and i32 %42, 127
  %44 = icmp eq i32 %43, 30
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  store i32 1, ptr %6, align 4
  br label %85

46:                                               ; preds = %40
  %47 = load i32, ptr getelementptr inbounds (%struct.http_parser, ptr @parser, i32 0, i32 5), align 4
  %48 = lshr i32 %47, 24
  %49 = and i32 %48, 127
  %50 = icmp eq i32 %49, 31
  br i1 %50, label %51, label %52

51:                                               ; preds = %46
  br label %53

52:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.357, ptr noundef @.str.151, i32 noundef 4169, ptr noundef @__PRETTY_FUNCTION__.test_message_pause) #7
  unreachable

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53, %36
  %55 = load i64, ptr %5, align 8, !tbaa !14
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 %55
  store ptr %57, ptr %3, align 8, !tbaa !5
  %58 = load i64, ptr %5, align 8, !tbaa !14
  %59 = load i64, ptr %4, align 8, !tbaa !14
  %60 = sub i64 %59, %58
  store i64 %60, ptr %4, align 8, !tbaa !14
  call void @http_parser_pause(ptr noundef @parser, i32 noundef 0)
  br label %61

61:                                               ; preds = %54
  %62 = load i64, ptr %4, align 8, !tbaa !14
  %63 = icmp ugt i64 %62, 0
  br i1 %63, label %17, label %64, !llvm.loop !18

64:                                               ; preds = %61
  %65 = call i64 @parse_pause(ptr noundef null, i64 noundef 0)
  store i64 %65, ptr %5, align 8, !tbaa !14
  %66 = load i64, ptr %5, align 8, !tbaa !14
  %67 = icmp eq i64 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %64
  br label %70

69:                                               ; preds = %64
  call void @__assert_fail(ptr noundef @.str.358, ptr noundef @.str.151, i32 noundef 4178, ptr noundef @__PRETTY_FUNCTION__.test_message_pause) #7
  unreachable

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70, %32
  %72 = load i32, ptr @num_messages, align 4, !tbaa !20
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %74, label %79

74:                                               ; preds = %71
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.message, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.307, ptr noundef %77)
  call void @abort() #7
  unreachable

79:                                               ; preds = %71
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = call i32 @message_eq(i32 noundef 0, i32 noundef 0, ptr noundef %80)
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  call void @abort() #7
  unreachable

84:                                               ; preds = %79
  store i32 0, ptr %6, align 4
  br label %85

85:                                               ; preds = %84, %45
  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
  %86 = load i32, ptr %6, align 4
  switch i32 %86, label %88 [
    i32 0, label %87
    i32 1, label %87
  ]

87:                                               ; preds = %85, %85
  ret void

88:                                               ; preds = %85
  unreachable
}

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 = { "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 = { 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 #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, !6, i64 8}
!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 = !{!12, !12, i64 0}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !11, i64 65700}
!17 = !{!10, !6, i64 65680}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!11, !11, i64 0}
!21 = !{!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"

%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
@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.307 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.357 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__.test_message_pause = external hidden unnamed_addr constant [48 x i8], align 1
@.str.358 = external hidden unnamed_addr constant [11 x i8], align 1

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

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

declare void @http_parser_pause(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @message_eq(i32 noundef, i32 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @test_message_pause(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %3) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !13
  tail call void @parser_init(i32 noundef %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 65680
  br label %8

8:                                                ; preds = %23, %1
  %.017 = phi ptr [ %3, %1 ], [ %24, %23 ]
  %.0 = phi i64 [ %4, %1 ], [ %25, %23 ]
  %9 = tail call i64 @parse_pause(ptr noundef %.017, i64 noundef %.0)
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @messages, i64 65700), align 4, !tbaa !14
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %16, label %11

11:                                               ; preds = %8
  %12 = load ptr, ptr %7, align 8, !tbaa !15
  %.not20 = icmp eq ptr %12, null
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @parser, i64 20), align 4
  %.not21 = icmp sgt i32 %13, -1
  %or.cond = select i1 %.not20, i1 true, i1 %.not21
  br i1 %or.cond, label %16, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %.017, i64 %9
  store ptr %15, ptr getelementptr inbounds (i8, ptr @messages, i64 65680), align 16, !tbaa !15
  br label %30

16:                                               ; preds = %11, %8
  %17 = icmp ult i64 %9, %.0
  br i1 %17, label %18, label %23

18:                                               ; preds = %16
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @parser, i64 20), align 4
  %20 = lshr i32 %19, 24
  %21 = and i32 %20, 127
  switch i32 %21, label %22 [
    i32 30, label %.loopexit
    i32 31, label %23
  ]

22:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.357, ptr noundef nonnull @.str.151, i32 noundef 4169, ptr noundef nonnull @__PRETTY_FUNCTION__.test_message_pause) #6
  unreachable

23:                                               ; preds = %18, %16
  %24 = getelementptr inbounds i8, ptr %.017, i64 %9
  %25 = sub i64 %.0, %9
  tail call void @http_parser_pause(ptr noundef nonnull @parser, i32 noundef 0) #7
  %.not22 = icmp eq i64 %25, 0
  br i1 %.not22, label %26, label %8, !llvm.loop !16

26:                                               ; preds = %23
  %27 = tail call i64 @parse_pause(ptr noundef null, i64 noundef 0)
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  tail call void @__assert_fail(ptr noundef nonnull @.str.358, ptr noundef nonnull @.str.151, i32 noundef 4178, ptr noundef nonnull @__PRETTY_FUNCTION__.test_message_pause) #6
  unreachable

30:                                               ; preds = %26, %14
  %31 = load i32, ptr @num_messages, align 4, !tbaa !18
  %.not23 = icmp eq i32 %31, 1
  br i1 %.not23, label %35, label %32

32:                                               ; preds = %30
  %33 = load ptr, ptr %0, align 8, !tbaa !19
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.307, ptr noundef %33)
  tail call void @abort() #6
  unreachable

35:                                               ; preds = %30
  %36 = tail call i32 @message_eq(i32 noundef 0, i32 noundef 0, ptr noundef %0)
  %.not24 = icmp eq i32 %36, 0
  br i1 %.not24, label %37, label %.loopexit

37:                                               ; preds = %35
  tail call void @abort() #6
  unreachable

.loopexit:                                        ; preds = %18, %35
  ret void
}

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 = { "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 = { 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 = { 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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, !7, i64 8}
!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, !10, i64 16}
!14 = !{!6, !10, i64 65700}
!15 = !{!6, !7, i64 65680}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !7, i64 0}


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