; LLVM IR from uNetworking/uSockets :: examples (http_load_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.us_socket_context_options_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

@request_template = external dso_local global [79 x i8], align 16
@request_template_post = external dso_local global [110 x i8], align 16
@pipeline = external dso_local global i32, align 4
@is_post = external dso_local global i32, align 4
@request = external dso_local global ptr, align 8
@request_size = external dso_local global i32, align 4
@connections = external dso_local global i32, align 4
@host = external dso_local global ptr, align 8
@port = external dso_local global i32, align 4
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @on_wakeup(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_pre(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_post(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_writable(ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_end(ptr noundef) #0

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

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

declare ptr @us_socket_context_connect(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_long_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_timeout(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.us_socket_context_options_t, align 8
  %11 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 5
  br i1 %13, label %14, label %22

14:                                               ; preds = %2
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 4
  br i1 %16, label %17, label %22

17:                                               ; preds = %14
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 6
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %3, align 4
  br label %122

22:                                               ; preds = %17, %14, %2
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = icmp sge i32 %23, 5
  br i1 %24, label %25, label %32

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds ptr, ptr %26, i64 4
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = call i32 @atoi(ptr noundef %28) #9
  store i32 %29, ptr @pipeline, align 4, !tbaa !5
  %30 = load i32, ptr @pipeline, align 4, !tbaa !5
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %30)
  br label %32

32:                                               ; preds = %25, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #10
  store ptr @request_template, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #10
  store i32 78, ptr %7, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp sge i32 %33, 6
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i64 5
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = call i32 @atoi(ptr noundef %38) #9
  store i32 %39, ptr @is_post, align 4, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  store ptr @request_template_post, ptr %6, align 8, !tbaa !9
  store i32 109, ptr %7, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %35, %32
  %42 = load i32, ptr @pipeline, align 4, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = mul nsw i32 %42, %43
  store i32 %44, ptr @request_size, align 4, !tbaa !5
  %45 = load i32, ptr @request_size, align 4, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %45)
  %47 = load i32, ptr @request_size, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = call noalias ptr @malloc(i64 noundef %48) #11
  store ptr %49, ptr @request, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #10
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %65, %41
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr @pipeline, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #10
  br label %68

55:                                               ; preds = %50
  %56 = load ptr, ptr @request, align 8, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = mul nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %56, i64 %60
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %61, ptr align 1 %62, i64 %64, i1 false)
  br label %65

65:                                               ; preds = %55
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %8, align 4, !tbaa !5
  br label %50, !llvm.loop !11

68:                                               ; preds = %54
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %69, i64 3
  %71 = load ptr, ptr %70, align 8, !tbaa !9
  %72 = call i32 @atoi(ptr noundef %71) #9
  store i32 %72, ptr @port, align 4, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %73, i64 2
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = call i64 @strlen(ptr noundef %75) #9
  %77 = add i64 %76, 1
  %78 = call noalias ptr @malloc(i64 noundef %77) #11
  store ptr %78, ptr @host, align 8, !tbaa !9
  %79 = load ptr, ptr @host, align 8, !tbaa !9
  %80 = load ptr, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds ptr, ptr %80, i64 2
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = getelementptr inbounds ptr, ptr %83, i64 2
  %85 = load ptr, ptr %84, align 8, !tbaa !9
  %86 = call i64 @strlen(ptr noundef %85) #9
  %87 = add i64 %86, 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %79, ptr align 1 %82, i64 %87, i1 false)
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = getelementptr inbounds ptr, ptr %88, i64 1
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  %91 = call i32 @atoi(ptr noundef %90) #9
  store i32 %91, ptr @connections, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #10
  %92 = call ptr @us_create_loop(ptr noundef null, ptr noundef @on_wakeup, ptr noundef @on_pre, ptr noundef @on_post, i32 noundef 0)
  store ptr %92, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 56, ptr %10) #10
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 56, i1 false)
  %93 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %10, i32 0, i32 0
  store ptr @.str.8, ptr %93, align 8, !tbaa !13
  %94 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %10, i32 0, i32 1
  store ptr @.str.9, ptr %94, align 8, !tbaa !15
  %95 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %10, i32 0, i32 2
  store ptr @.str.10, ptr %95, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #10
  %96 = load ptr, ptr %9, align 8, !tbaa !9
  %97 = call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %96, i32 noundef 0, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %10)
  store ptr %97, ptr %11, align 8, !tbaa !9
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  %99 = icmp ne ptr %98, null
  br i1 %99, label %102, label %100

100:                                              ; preds = %68
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @exit(i32 noundef 0) #12
  unreachable

102:                                              ; preds = %68
  %103 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_open(i32 noundef 1, ptr noundef %103, ptr noundef @on_http_socket_open)
  %104 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_data(i32 noundef 1, ptr noundef %104, ptr noundef @on_http_socket_data)
  %105 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef %105, ptr noundef @on_http_socket_writable)
  %106 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_close(i32 noundef 1, ptr noundef %106, ptr noundef @on_http_socket_close)
  %107 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef %107, ptr noundef @on_http_socket_timeout)
  %108 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_long_timeout(i32 noundef 1, ptr noundef %108, ptr noundef @on_http_socket_long_timeout)
  %109 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_end(i32 noundef 1, ptr noundef %109, ptr noundef @on_http_socket_end)
  %110 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_on_connect_error(i32 noundef 1, ptr noundef %110, ptr noundef @on_http_socket_connect_error)
  %111 = load ptr, ptr %11, align 8, !tbaa !9
  %112 = load ptr, ptr @host, align 8, !tbaa !9
  %113 = load i32, ptr @port, align 4, !tbaa !5
  %114 = call ptr @us_socket_context_connect(i32 noundef 1, ptr noundef %111, ptr noundef %112, i32 noundef %113, ptr noundef null, i32 noundef 0, i32 noundef 4)
  %115 = icmp ne ptr %114, null
  br i1 %115, label %118, label %116

116:                                              ; preds = %102
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %118

118:                                              ; preds = %116, %102
  %119 = load ptr, ptr %9, align 8, !tbaa !9
  call void @us_loop_run(ptr noundef %119)
  %120 = load ptr, ptr %11, align 8, !tbaa !9
  call void @us_socket_context_free(i32 noundef 1, ptr noundef %120)
  %121 = load ptr, ptr %9, align 8, !tbaa !9
  call void @us_loop_free(ptr noundef %121)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #10
  call void @llvm.lifetime.end.p0(i64 56, ptr %10) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #10
  br label %122

122:                                              ; preds = %118, %20
  %123 = load i32, ptr %3, align 4
  ret i32 %123
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

declare ptr @us_create_loop(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

declare ptr @us_create_socket_context(i32 noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.us_socket_context_options_t) align 8) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #8

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

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

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

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

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

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

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

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

declare void @us_loop_run(ptr noundef) #2

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

declare void @us_loop_free(ptr noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint nounwind willreturn memory(read) 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 allocsize(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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { 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 #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind }
attributes #11 = { nounwind allocsize(0) }
attributes #12 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"us_socket_context_options_t", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !10, i64 16}


; 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.us_socket_context_options_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

@request_template = external dso_local local_unnamed_addr global [79 x i8], align 16
@request_template_post = external dso_local local_unnamed_addr global [110 x i8], align 16
@pipeline = external dso_local local_unnamed_addr global i32, align 4
@is_post = external dso_local local_unnamed_addr global i32, align 4
@request = external dso_local local_unnamed_addr global ptr, align 8
@request_size = external dso_local local_unnamed_addr global i32, align 4
@connections = external dso_local local_unnamed_addr global i32, align 4
@host = external dso_local local_unnamed_addr global ptr, align 8
@port = external dso_local local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @on_wakeup(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_pre(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_post(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_writable(ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_end(ptr noundef) #0

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

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

declare ptr @us_socket_context_connect(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 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 dso_local ptr @on_http_socket_long_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_http_socket_timeout(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.us_socket_context_options_t, align 8
  %4 = add i32 %0, -7
  %or.cond3 = icmp ult i32 %4, -3
  br i1 %or.cond3, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %62

7:                                                ; preds = %2
  %8 = icmp ugt i32 %0, 4
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call i32 @atoi(ptr nocapture noundef %11) #10
  store i32 %12, ptr @pipeline, align 4, !tbaa !9
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %12)
  %.not40 = icmp eq i32 %0, 5
  br i1 %.not40, label %.thread, label %14

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %1, i64 40
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call i32 @atoi(ptr nocapture noundef %16) #10
  store i32 %17, ptr @is_post, align 4, !tbaa !9
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  br label %.thread

.thread:                                          ; preds = %7, %14, %9
  %.038 = phi i32 [ 109, %14 ], [ 78, %9 ], [ 78, %7 ]
  %.036 = phi ptr [ @request_template_post, %14 ], [ @request_template, %9 ], [ @request_template, %7 ]
  %19 = load i32, ptr @pipeline, align 4, !tbaa !9
  %20 = mul nsw i32 %19, %.038
  store i32 %20, ptr @request_size, align 4, !tbaa !9
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %20)
  %22 = load i32, ptr @request_size, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = tail call noalias ptr @malloc(i64 noundef %23) #11
  store ptr %24, ptr @request, align 8, !tbaa !5
  %25 = load i32, ptr @pipeline, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.thread
  %27 = zext nneg i32 %.038 to i64
  br label %46

._crit_edge:                                      ; preds = %46, %.thread
  %28 = getelementptr inbounds i8, ptr %1, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = tail call i32 @atoi(ptr nocapture noundef %29) #10
  store i32 %30, ptr @port, align 4, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %1, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %32) #10
  %34 = add i64 %33, 1
  %35 = tail call noalias ptr @malloc(i64 noundef %34) #11
  store ptr %35, ptr @host, align 8, !tbaa !5
  %36 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %32) #10
  %37 = add i64 %36, 1
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %35, ptr align 1 %32, i64 %37, i1 false)
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = tail call i32 @atoi(ptr nocapture noundef %39) #10
  store i32 %40, ptr @connections, align 4, !tbaa !9
  %41 = tail call ptr @us_create_loop(ptr noundef null, ptr noundef nonnull @on_wakeup, ptr noundef nonnull @on_pre, ptr noundef nonnull @on_post, i32 noundef 0) #12
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %3) #12
  %42 = getelementptr inbounds i8, ptr %3, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %42, i8 0, i64 32, i1 false)
  store ptr @.str.8, ptr %3, align 8, !tbaa !11
  %43 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @.str.9, ptr %43, align 8, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr @.str.10, ptr %44, align 8, !tbaa !14
  %45 = tail call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %41, i32 noundef 0, ptr noundef nonnull byval(%struct.us_socket_context_options_t) align 8 %3) #12
  %.not = icmp eq ptr %45, null
  br i1 %.not, label %53, label %55

46:                                               ; preds = %.lr.ph, %46
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %46 ]
  %47 = load ptr, ptr @request, align 8, !tbaa !5
  %48 = mul nuw nsw i64 %indvars.iv, %27
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %49, ptr noundef nonnull align 16 dereferenceable(1) %.036, i64 %27, i1 false)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = load i32, ptr @pipeline, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next, %51
  br i1 %52, label %46, label %._crit_edge, !llvm.loop !15

53:                                               ; preds = %._crit_edge
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  tail call void @exit(i32 noundef 0) #13
  unreachable

55:                                               ; preds = %._crit_edge
  tail call void @us_socket_context_on_open(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_open) #12
  tail call void @us_socket_context_on_data(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_data) #12
  tail call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_writable) #12
  tail call void @us_socket_context_on_close(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_close) #12
  tail call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_timeout) #12
  tail call void @us_socket_context_on_long_timeout(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_long_timeout) #12
  tail call void @us_socket_context_on_end(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_end) #12
  tail call void @us_socket_context_on_connect_error(i32 noundef 1, ptr noundef nonnull %45, ptr noundef nonnull @on_http_socket_connect_error) #12
  %56 = load ptr, ptr @host, align 8, !tbaa !5
  %57 = load i32, ptr @port, align 4, !tbaa !9
  %58 = tail call ptr @us_socket_context_connect(i32 noundef 1, ptr noundef nonnull %45, ptr noundef %56, i32 noundef %57, ptr noundef null, i32 noundef 0, i32 noundef 4) #12
  %.not39 = icmp eq ptr %58, null
  br i1 %.not39, label %59, label %61

59:                                               ; preds = %55
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %61

61:                                               ; preds = %59, %55
  tail call void @us_loop_run(ptr noundef %41) #12
  tail call void @us_socket_context_free(i32 noundef 1, ptr noundef nonnull %45) #12
  tail call void @us_loop_free(ptr noundef %41) #12
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #12
  br label %62

62:                                               ; preds = %61, %5
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

declare ptr @us_create_loop(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #8

declare ptr @us_create_socket_context(i32 noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.us_socket_context_options_t) align 8) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #9

declare void @us_socket_context_on_open(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_data(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_writable(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_close(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_timeout(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_long_timeout(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_end(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_on_connect_error(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @us_loop_run(ptr noundef) local_unnamed_addr #2

declare void @us_socket_context_free(i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @us_loop_free(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { 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 #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind allocsize(0) }
attributes #12 = { nounwind }
attributes #13 = { 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 0}
!12 = !{!"us_socket_context_options_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass