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

@parser = external hidden global %struct.http_parser, align 8
@num_messages = external hidden global i32, align 4
@stderr = external global ptr, align 8
@.str.342 = external hidden unnamed_addr constant [49 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @parse(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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_multiple3(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call i64 (i64, ...) @count_parsed_messages(i64 noundef 3, ptr noundef %11, ptr noundef %12, ptr noundef %13)
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr %7, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.message, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = call i64 @strlen(ptr noundef %18) #7
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.message, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = call i64 @strlen(ptr noundef %22) #7
  %24 = add i64 %19, %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.message, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = call i64 @strlen(ptr noundef %27) #7
  %29 = add i64 %24, %28
  %30 = add i64 %29, 1
  %31 = call ptr @llvm.stacksave.p0()
  store ptr %31, ptr %8, align 8
  %32 = alloca i8, i64 %30, align 16
  store i64 %30, ptr %9, align 8
  %33 = getelementptr inbounds i8, ptr %32, i64 0
  store i8 0, ptr %33, align 16, !tbaa !15
  %34 = load ptr, ptr %4, 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 ptr @strcat(ptr noundef %32, ptr noundef %36) #6
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.message, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = call ptr @strcat(ptr noundef %32, ptr noundef %40) #6
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.message, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = call ptr @strcat(ptr noundef %32, ptr noundef %44) #6
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.message, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !16
  call void @parser_init(i32 noundef %48)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %49 = call i64 @strlen(ptr noundef %32) #7
  %50 = call i64 @parse(ptr noundef %32, i64 noundef %49)
  store i64 %50, ptr %10, align 8, !tbaa !17
  %51 = load i32, ptr getelementptr inbounds (%struct.http_parser, ptr @parser, i32 0, i32 5), align 4
  %52 = lshr i32 %51, 31
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %3
  %55 = load i64, ptr %10, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  call void (ptr, i64, i64, ...) @upgrade_message_fix(ptr noundef %32, i64 noundef %55, i64 noundef 3, ptr noundef %56, ptr noundef %57, ptr noundef %58)
  br label %72

59:                                               ; preds = %3
  %60 = load i64, ptr %10, align 8, !tbaa !17
  %61 = call i64 @strlen(ptr noundef %32) #7
  %62 = icmp ne i64 %60, %61
  br i1 %62, label %63, label %65

63:                                               ; preds = %59
  %64 = load i64, ptr %10, align 8, !tbaa !17
  call void @print_error(ptr noundef %32, i64 noundef %64)
  call void @abort() #8
  unreachable

65:                                               ; preds = %59
  %66 = call i64 @parse(ptr noundef null, i64 noundef 0)
  store i64 %66, ptr %10, align 8, !tbaa !17
  %67 = load i64, ptr %10, align 8, !tbaa !17
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %65
  %70 = load i64, ptr %10, align 8, !tbaa !17
  call void @print_error(ptr noundef %32, i64 noundef %70)
  call void @abort() #8
  unreachable

71:                                               ; preds = %65
  br label %72

72:                                               ; preds = %71, %54
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = load i32, ptr @num_messages, align 4, !tbaa !9
  %75 = icmp ne i32 %73, %74
  br i1 %75, label %76, label %80

76:                                               ; preds = %72
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = load i32, ptr @num_messages, align 4, !tbaa !9
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.342, i32 noundef %78) #6
  call void @abort() #8
  unreachable

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

84:                                               ; preds = %80
  call void @abort() #8
  unreachable

85:                                               ; preds = %80
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = icmp sgt i32 %86, 1
  br i1 %87, label %88, label %93

88:                                               ; preds = %85
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call i32 @message_eq(i32 noundef 1, i32 noundef 0, ptr noundef %89)
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %93, label %92

92:                                               ; preds = %88
  call void @abort() #8
  unreachable

93:                                               ; preds = %88, %85
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = icmp sgt i32 %94, 2
  br i1 %95, label %96, label %101

96:                                               ; preds = %93
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = call i32 @message_eq(i32 noundef 2, i32 noundef 0, ptr noundef %97)
  %99 = icmp ne i32 %98, 0
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  call void @abort() #8
  unreachable

101:                                              ; preds = %96, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %102 = load ptr, ptr %8, align 8
  call void @llvm.stackrestore.p0(ptr %102)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #1

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

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

@parser = external hidden local_unnamed_addr global %struct.http_parser, align 8
@num_messages = external hidden local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.342 = external hidden unnamed_addr constant [49 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @abort() 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(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: nounwind uwtable
declare dso_local i64 @count_parsed_messages(i64 noundef, ...) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_multiple3(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = tail call i64 (i64, ...) @count_parsed_messages(i64 noundef 3, ptr noundef %0, ptr noundef %1, ptr noundef %2)
  %5 = trunc i64 %4 to i32
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #5
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %10) #5
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #5
  %15 = add i64 %8, 1
  %16 = add i64 %15, %11
  %17 = add i64 %16, %14
  %18 = alloca i8, i64 %17, align 16
  store i8 0, ptr %18, align 16, !tbaa !13
  %19 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %7) #6
  %20 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %10) #6
  %21 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %13) #6
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !14
  call void @parser_init(i32 noundef %23)
  %24 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %18) #5
  %25 = call i64 @parse(ptr noundef nonnull %18, i64 noundef %24)
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @parser, i64 20), align 4
  %.not = icmp sgt i32 %26, -1
  br i1 %.not, label %28, label %27

27:                                               ; preds = %3
  call void (ptr, i64, i64, ...) @upgrade_message_fix(ptr noundef nonnull %18, i64 noundef %25, i64 noundef 3, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2)
  br label %34

28:                                               ; preds = %3
  %29 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %18) #5
  %.not27 = icmp eq i64 %25, %29
  br i1 %.not27, label %31, label %30

30:                                               ; preds = %28
  call void @print_error(ptr noundef nonnull %18, i64 noundef %25)
  call void @abort() #7
  unreachable

31:                                               ; preds = %28
  %32 = call i64 @parse(ptr noundef null, i64 noundef 0)
  %.not28 = icmp eq i64 %32, 0
  br i1 %.not28, label %34, label %33

33:                                               ; preds = %31
  call void @print_error(ptr noundef nonnull %18, i64 noundef %32)
  call void @abort() #7
  unreachable

34:                                               ; preds = %31, %27
  %35 = load i32, ptr @num_messages, align 4, !tbaa !15
  %.not29 = icmp eq i32 %35, %5
  br i1 %.not29, label %39, label %36

36:                                               ; preds = %34
  %37 = load ptr, ptr @stderr, align 8, !tbaa !16
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.342, i32 noundef %35) #8
  call void @abort() #7
  unreachable

39:                                               ; preds = %34
  %40 = call i32 @message_eq(i32 noundef 0, i32 noundef 0, ptr noundef nonnull %0)
  %.not30 = icmp eq i32 %40, 0
  br i1 %.not30, label %41, label %42

41:                                               ; preds = %39
  call void @abort() #7
  unreachable

42:                                               ; preds = %39
  %43 = icmp sgt i32 %5, 1
  br i1 %43, label %44, label %.thread

44:                                               ; preds = %42
  %45 = call i32 @message_eq(i32 noundef 1, i32 noundef 0, ptr noundef nonnull %1)
  %.not31 = icmp eq i32 %45, 0
  br i1 %.not31, label %46, label %47

46:                                               ; preds = %44
  call void @abort() #7
  unreachable

47:                                               ; preds = %44
  %.not33 = icmp eq i32 %5, 2
  br i1 %.not33, label %.thread, label %48

48:                                               ; preds = %47
  %49 = call i32 @message_eq(i32 noundef 2, i32 noundef 0, ptr noundef nonnull %2)
  %.not32 = icmp eq i32 %49, 0
  br i1 %.not32, label %50, label %.thread

50:                                               ; preds = %48
  call void @abort() #7
  unreachable

.thread:                                          ; preds = %42, %48, %47
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #4

attributes #0 = { 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 #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 = { 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 nofree nounwind willreturn memory(argmem: readwrite) "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 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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, !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 = !{!8, !8, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!10, !10, i64 0}
!16 = !{!7, !7, i64 0}


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