; LLVM IR from attractivechaos/klib :: kurl (kurl_open)

; 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.s3aux_t = type { ptr, ptr, ptr }
%struct.kurl_t = type { ptr, ptr, ptr, i64, i32, i32, i32, i32, i32, i32, ptr }
%struct.kurl_opt_t = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @kurl_open(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.s3aux_t, align 8
  %14 = alloca %struct.s3aux_t, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 -1, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call ptr @strstr(ptr noundef %15, ptr noundef @.str) #9
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %53

19:                                               ; preds = %2
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = sext i8 %21 to i32
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %53

24:                                               ; preds = %19
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %25, ptr %7, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %44, %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = icmp ne ptr %27, %28
  br i1 %29, label %30, label %47

30:                                               ; preds = %26
  %31 = call ptr @__ctype_b_loc() #10
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i16, ptr %32, i64 %36
  %38 = load i16, ptr %37, align 2, !tbaa !12
  %39 = zext i16 %38 to i32
  %40 = and i32 %39, 8
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %30
  br label %47

43:                                               ; preds = %30
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i32 1
  store ptr %46, ptr %7, align 8, !tbaa !5
  br label %26, !llvm.loop !14

47:                                               ; preds = %42, %26
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = icmp eq ptr %48, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %51, %47
  br label %53

53:                                               ; preds = %52, %19, %2
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %61

56:                                               ; preds = %53
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = call i32 (ptr, i32, ...) @open(ptr noundef %57, i32 noundef 0)
  store i32 %58, ptr %9, align 4, !tbaa !9
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %56
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %256

61:                                               ; preds = %56, %53
  %62 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 64) #11
  store ptr %62, ptr %8, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %67

65:                                               ; preds = %61
  %66 = load i32, ptr %9, align 4, !tbaa !9
  br label %68

67:                                               ; preds = %61
  br label %68

68:                                               ; preds = %67, %65
  %69 = phi i32 [ %66, %65 ], [ -1, %67 ]
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.kurl_t, ptr %70, i32 0, i32 4
  store i32 %69, ptr %71, align 8, !tbaa !16
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.kurl_t, ptr %72, i32 0, i32 4
  %74 = load i32, ptr %73, align 8, !tbaa !16
  %75 = icmp sge i32 %74, 0
  br i1 %75, label %205, label %76

76:                                               ; preds = %68
  %77 = call ptr @curl_multi_init()
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.kurl_t, ptr %78, i32 0, i32 0
  store ptr %77, ptr %79, align 8, !tbaa !19
  %80 = call ptr @curl_easy_init()
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.kurl_t, ptr %81, i32 0, i32 1
  store ptr %80, ptr %82, align 8, !tbaa !20
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = call ptr @strstr(ptr noundef %83, ptr noundef @.str.1) #9
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = icmp eq ptr %84, %85
  br i1 %86, label %87, label %169

87:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #8
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %95

91:                                               ; preds = %87
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.kurl_opt_t, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !21
  br label %96

95:                                               ; preds = %87
  br label %96

96:                                               ; preds = %95, %91
  %97 = phi ptr [ %94, %91 ], [ null, %95 ]
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %104

100:                                              ; preds = %96
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.kurl_opt_t, ptr %101, i32 0, i32 1
  %103 = load ptr, ptr %102, align 8, !tbaa !23
  br label %105

104:                                              ; preds = %96
  br label %105

105:                                              ; preds = %104, %100
  %106 = phi ptr [ %103, %100 ], [ null, %104 ]
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %113

109:                                              ; preds = %105
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.kurl_opt_t, ptr %110, i32 0, i32 2
  %112 = load ptr, ptr %111, align 8, !tbaa !24
  br label %114

113:                                              ; preds = %105
  br label %114

114:                                              ; preds = %113, %109
  %115 = phi ptr [ %112, %109 ], [ null, %113 ]
  call void @s3_parse(ptr dead_on_unwind writable sret(%struct.s3aux_t) align 8 %14, ptr noundef %88, ptr noundef %97, ptr noundef %106, ptr noundef %115)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %14, i64 24, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #8
  %116 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !21
  %118 = icmp eq ptr %117, null
  br i1 %118, label %127, label %119

119:                                              ; preds = %114
  %120 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 1
  %121 = load ptr, ptr %120, align 8, !tbaa !23
  %122 = icmp eq ptr %121, null
  br i1 %122, label %127, label %123

123:                                              ; preds = %119
  %124 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 2
  %125 = load ptr, ptr %124, align 8, !tbaa !24
  %126 = icmp eq ptr %125, null
  br i1 %126, label %127, label %130

127:                                              ; preds = %123, %119, %114
  %128 = load ptr, ptr %8, align 8, !tbaa !5
  %129 = call i32 @kurl_close(ptr noundef %128)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %166

130:                                              ; preds = %123
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.kurl_t, ptr %131, i32 0, i32 10
  %133 = load ptr, ptr %132, align 8, !tbaa !26
  %134 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 1
  %135 = load ptr, ptr %134, align 8, !tbaa !23
  %136 = call ptr @curl_slist_append(ptr noundef %133, ptr noundef %135)
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.kurl_t, ptr %137, i32 0, i32 10
  store ptr %136, ptr %138, align 8, !tbaa !26
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.kurl_t, ptr %139, i32 0, i32 10
  %141 = load ptr, ptr %140, align 8, !tbaa !26
  %142 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 2
  %143 = load ptr, ptr %142, align 8, !tbaa !24
  %144 = call ptr @curl_slist_append(ptr noundef %141, ptr noundef %143)
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.kurl_t, ptr %145, i32 0, i32 10
  store ptr %144, ptr %146, align 8, !tbaa !26
  %147 = load ptr, ptr %8, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.kurl_t, ptr %147, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !20
  %150 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !21
  %152 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %149, i32 noundef 10002, ptr noundef %151)
  %153 = load ptr, ptr %8, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.kurl_t, ptr %153, i32 0, i32 1
  %155 = load ptr, ptr %154, align 8, !tbaa !20
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.kurl_t, ptr %156, i32 0, i32 10
  %158 = load ptr, ptr %157, align 8, !tbaa !26
  %159 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %155, i32 noundef 10023, ptr noundef %158)
  %160 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 1
  %161 = load ptr, ptr %160, align 8, !tbaa !23
  call void @free(ptr noundef %161) #8
  %162 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 2
  %163 = load ptr, ptr %162, align 8, !tbaa !24
  call void @free(ptr noundef %163) #8
  %164 = getelementptr inbounds %struct.s3aux_t, ptr %13, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !21
  call void @free(ptr noundef %165) #8
  store i32 0, ptr %12, align 4
  br label %166

166:                                              ; preds = %130, %127
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #8
  %167 = load i32, ptr %12, align 4
  switch i32 %167, label %256 [
    i32 0, label %168
  ]

168:                                              ; preds = %166
  br label %175

169:                                              ; preds = %76
  %170 = load ptr, ptr %8, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.kurl_t, ptr %170, i32 0, i32 1
  %172 = load ptr, ptr %171, align 8, !tbaa !20
  %173 = load ptr, ptr %4, align 8, !tbaa !5
  %174 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %172, i32 noundef 10002, ptr noundef %173)
  br label %175

175:                                              ; preds = %169, %168
  %176 = load ptr, ptr %8, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.kurl_t, ptr %176, i32 0, i32 1
  %178 = load ptr, ptr %177, align 8, !tbaa !20
  %179 = load ptr, ptr %8, align 8, !tbaa !5
  %180 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %178, i32 noundef 10001, ptr noundef %179)
  %181 = load ptr, ptr %8, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.kurl_t, ptr %181, i32 0, i32 1
  %183 = load ptr, ptr %182, align 8, !tbaa !20
  %184 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %183, i32 noundef 41, i64 noundef 0)
  %185 = load ptr, ptr %8, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.kurl_t, ptr %185, i32 0, i32 1
  %187 = load ptr, ptr %186, align 8, !tbaa !20
  %188 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %187, i32 noundef 99, i64 noundef 1)
  %189 = load ptr, ptr %8, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.kurl_t, ptr %189, i32 0, i32 1
  %191 = load ptr, ptr %190, align 8, !tbaa !20
  %192 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %191, i32 noundef 20011, ptr noundef @write_cb)
  %193 = load ptr, ptr %8, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.kurl_t, ptr %193, i32 0, i32 1
  %195 = load ptr, ptr %194, align 8, !tbaa !20
  %196 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %195, i32 noundef 64, i64 noundef 0)
  %197 = load ptr, ptr %8, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.kurl_t, ptr %197, i32 0, i32 1
  %199 = load ptr, ptr %198, align 8, !tbaa !20
  %200 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %199, i32 noundef 81, i64 noundef 0)
  %201 = load ptr, ptr %8, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.kurl_t, ptr %201, i32 0, i32 1
  %203 = load ptr, ptr %202, align 8, !tbaa !20
  %204 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %203, i32 noundef 52, i64 noundef 1)
  br label %205

205:                                              ; preds = %175, %68
  %206 = load ptr, ptr %8, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.kurl_t, ptr %206, i32 0, i32 5
  store i32 32768, ptr %207, align 4, !tbaa !27
  %208 = load ptr, ptr %8, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.kurl_t, ptr %208, i32 0, i32 4
  %210 = load i32, ptr %209, align 8, !tbaa !16
  %211 = icmp sge i32 %210, 0
  br i1 %211, label %220, label %212

212:                                              ; preds = %205
  %213 = load ptr, ptr %8, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.kurl_t, ptr %213, i32 0, i32 5
  %215 = load i32, ptr %214, align 4, !tbaa !27
  %216 = icmp slt i32 %215, 32768
  br i1 %216, label %217, label %220

217:                                              ; preds = %212
  %218 = load ptr, ptr %8, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.kurl_t, ptr %218, i32 0, i32 5
  store i32 32768, ptr %219, align 4, !tbaa !27
  br label %220

220:                                              ; preds = %217, %212, %205
  %221 = load ptr, ptr %8, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.kurl_t, ptr %221, i32 0, i32 5
  %223 = load i32, ptr %222, align 4, !tbaa !27
  %224 = sext i32 %223 to i64
  %225 = call noalias ptr @calloc(i64 noundef %224, i64 noundef 1) #11
  %226 = load ptr, ptr %8, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.kurl_t, ptr %226, i32 0, i32 2
  store ptr %225, ptr %227, align 8, !tbaa !28
  %228 = load ptr, ptr %8, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.kurl_t, ptr %228, i32 0, i32 4
  %230 = load i32, ptr %229, align 8, !tbaa !16
  %231 = icmp sge i32 %230, 0
  br i1 %231, label %232, label %237

232:                                              ; preds = %220
  %233 = load ptr, ptr %8, align 8, !tbaa !5
  %234 = call i32 @fill_buffer(ptr noundef %233)
  %235 = icmp sle i32 %234, 0
  %236 = zext i1 %235 to i32
  store i32 %236, ptr %11, align 4, !tbaa !9
  br label %248

237:                                              ; preds = %220
  %238 = load ptr, ptr %8, align 8, !tbaa !5
  %239 = call i32 @prepare(ptr noundef %238, i32 noundef 0)
  %240 = icmp slt i32 %239, 0
  br i1 %240, label %245, label %241

241:                                              ; preds = %237
  %242 = load ptr, ptr %8, align 8, !tbaa !5
  %243 = call i32 @fill_buffer(ptr noundef %242)
  %244 = icmp sle i32 %243, 0
  br label %245

245:                                              ; preds = %241, %237
  %246 = phi i1 [ true, %237 ], [ %244, %241 ]
  %247 = zext i1 %246 to i32
  store i32 %247, ptr %11, align 4, !tbaa !9
  br label %248

248:                                              ; preds = %245, %232
  %249 = load i32, ptr %11, align 4, !tbaa !9
  %250 = icmp ne i32 %249, 0
  br i1 %250, label %251, label %254

251:                                              ; preds = %248
  %252 = load ptr, ptr %8, align 8, !tbaa !5
  %253 = call i32 @kurl_close(ptr noundef %252)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %256

254:                                              ; preds = %248
  %255 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %255, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %256

256:                                              ; preds = %254, %251, %166, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %257 = load ptr, ptr %3, align 8
  ret ptr %257
}

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

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #4

declare i32 @open(ptr noundef, i32 noundef, ...) #5

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #6

declare ptr @curl_multi_init() #5

declare ptr @curl_easy_init() #5

; Function Attrs: nounwind uwtable
declare dso_local void @s3_parse(ptr dead_on_unwind noalias writable sret(%struct.s3aux_t) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; 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) #7

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

declare ptr @curl_slist_append(ptr noundef, ptr noundef) #5

declare i32 @curl_easy_setopt(ptr noundef, i32 noundef, ...) #5

; Function Attrs: nounwind uwtable
declare hidden i64 @write_cb(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @fill_buffer(ptr noundef) #0

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind willreturn memory(none) "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 = { "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 = { nounwind allocsize(0,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 #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind willreturn memory(none) }
attributes #11 = { nounwind allocsize(0,1) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 32}
!17 = !{!"kurl_t", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !6, i64 56}
!18 = !{!"long", !7, i64 0}
!19 = !{!17, !6, i64 0}
!20 = !{!17, !6, i64 8}
!21 = !{!22, !6, i64 0}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!22, !6, i64 8}
!24 = !{!22, !6, i64 16}
!25 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5}
!26 = !{!17, !6, i64 56}
!27 = !{!17, !10, i64 36}
!28 = !{!17, !6, 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.s3aux_t = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @kurl_open(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.s3aux_t, align 8
  %4 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @.str) #9
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.critedge, label %5

5:                                                ; preds = %2
  %6 = load i8, ptr %4, align 1, !tbaa !5
  %.not80 = icmp eq i8 %6, 0
  br i1 %.not80, label %.critedge, label %.preheader

.preheader:                                       ; preds = %5
  %.not8197 = icmp eq ptr %4, %0
  br i1 %.not8197, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %7 = tail call ptr @__ctype_b_loc() #10
  %8 = load ptr, ptr %7, align 8, !tbaa !8
  br label %11

9:                                                ; preds = %11
  %10 = getelementptr inbounds i8, ptr %.07098, i64 1
  %.not81 = icmp eq ptr %10, %4
  br i1 %.not81, label %._crit_edge, label %11, !llvm.loop !10

11:                                               ; preds = %.lr.ph, %9
  %.07098 = phi ptr [ %0, %.lr.ph ], [ %10, %9 ]
  %12 = load i8, ptr %.07098, align 1, !tbaa !5
  %13 = sext i8 %12 to i64
  %14 = getelementptr inbounds i16, ptr %8, i64 %13
  %15 = load i16, ptr %14, align 2, !tbaa !12
  %16 = and i16 %15, 8
  %.not82 = icmp eq i16 %16, 0
  br i1 %.not82, label %.critedge, label %9

.critedge:                                        ; preds = %11, %5, %2
  %17 = tail call i32 (ptr, i32, ...) @open(ptr noundef %0, i32 noundef 0) #11
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %78, label %.thread

.thread:                                          ; preds = %.critedge
  %19 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 1, i64 noundef 64) #12
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  store i32 %17, ptr %20, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %19, i64 36
  store i32 32768, ptr %21, align 4, !tbaa !18
  %22 = tail call noalias dereferenceable_or_null(32768) ptr @calloc(i64 noundef 32768, i64 noundef 1) #12
  %23 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr %22, ptr %23, align 8, !tbaa !19
  br label %75

._crit_edge:                                      ; preds = %9, %.preheader
  %24 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 1, i64 noundef 64) #12
  %25 = getelementptr inbounds i8, ptr %24, i64 32
  store i32 -1, ptr %25, align 8, !tbaa !14
  %26 = tail call ptr @curl_multi_init() #11
  store ptr %26, ptr %24, align 8, !tbaa !20
  %27 = tail call ptr @curl_easy_init() #11
  %28 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %27, ptr %28, align 8, !tbaa !21
  %strlen = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.1)
  %strncmp = tail call i32 @strncmp(ptr %0, ptr nonnull @.str.1, i64 %strlen)
  %cmp = icmp eq i32 %strncmp, 0
  br i1 %cmp, label %29, label %51

29:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #11
  %.not84 = icmp eq ptr %1, null
  br i1 %.not84, label %.thread92, label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %1, align 8, !tbaa !22
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %34 = getelementptr inbounds i8, ptr %1, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !25
  br label %.thread92

.thread92:                                        ; preds = %29, %30
  %36 = phi ptr [ %33, %30 ], [ null, %29 ]
  %37 = phi ptr [ %31, %30 ], [ null, %29 ]
  %38 = phi ptr [ %35, %30 ], [ null, %29 ]
  call void @s3_parse(ptr dead_on_unwind nonnull writable sret(%struct.s3aux_t) align 8 %3, ptr noundef %0, ptr noundef %37, ptr noundef %36, ptr noundef %38)
  %.sroa.0.0.copyload = load ptr, ptr %3, align 8, !tbaa !8
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.sroa.6.0.copyload = load ptr, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !8
  %.sroa.9.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 16
  %.sroa.9.0.copyload = load ptr, ptr %.sroa.9.0..sroa_idx, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #11
  %39 = icmp ne ptr %.sroa.0.0.copyload, null
  %40 = icmp ne ptr %.sroa.6.0.copyload, null
  %or.cond.not88 = select i1 %39, i1 %40, i1 false
  %41 = icmp ne ptr %.sroa.9.0.copyload, null
  %or.cond5.not = select i1 %or.cond.not88, i1 %41, i1 false
  br i1 %or.cond5.not, label %.thread93, label %.sink.split

.thread93:                                        ; preds = %.thread92
  %42 = getelementptr inbounds i8, ptr %24, i64 56
  %43 = load ptr, ptr %42, align 8, !tbaa !26
  %44 = call ptr @curl_slist_append(ptr noundef %43, ptr noundef nonnull %.sroa.6.0.copyload) #11
  store ptr %44, ptr %42, align 8, !tbaa !26
  %45 = call ptr @curl_slist_append(ptr noundef %44, ptr noundef nonnull %.sroa.9.0.copyload) #11
  store ptr %45, ptr %42, align 8, !tbaa !26
  %46 = load ptr, ptr %28, align 8, !tbaa !21
  %47 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %46, i32 noundef 10002, ptr noundef nonnull %.sroa.0.0.copyload) #11
  %48 = load ptr, ptr %28, align 8, !tbaa !21
  %49 = load ptr, ptr %42, align 8, !tbaa !26
  %50 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %48, i32 noundef 10023, ptr noundef %49) #11
  call void @free(ptr noundef nonnull %.sroa.6.0.copyload) #11
  call void @free(ptr noundef nonnull %.sroa.9.0.copyload) #11
  call void @free(ptr noundef nonnull %.sroa.0.0.copyload) #11
  br label %53

51:                                               ; preds = %._crit_edge
  %52 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %27, i32 noundef 10002, ptr noundef %0) #11
  br label %53

53:                                               ; preds = %51, %.thread93
  %54 = load ptr, ptr %28, align 8, !tbaa !21
  %55 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %54, i32 noundef 10001, ptr noundef nonnull %24) #11
  %56 = load ptr, ptr %28, align 8, !tbaa !21
  %57 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %56, i32 noundef 41, i64 noundef 0) #11
  %58 = load ptr, ptr %28, align 8, !tbaa !21
  %59 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %58, i32 noundef 99, i64 noundef 1) #11
  %60 = load ptr, ptr %28, align 8, !tbaa !21
  %61 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %60, i32 noundef 20011, ptr noundef nonnull @write_cb) #11
  %62 = load ptr, ptr %28, align 8, !tbaa !21
  %63 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %62, i32 noundef 64, i64 noundef 0) #11
  %64 = load ptr, ptr %28, align 8, !tbaa !21
  %65 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %64, i32 noundef 81, i64 noundef 0) #11
  %66 = load ptr, ptr %28, align 8, !tbaa !21
  %67 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %66, i32 noundef 52, i64 noundef 1) #11
  %.pr = load i32, ptr %25, align 8, !tbaa !14
  %68 = icmp sgt i32 %.pr, -1
  %69 = getelementptr inbounds i8, ptr %24, i64 36
  store i32 32768, ptr %69, align 4, !tbaa !18
  %70 = call noalias dereferenceable_or_null(32768) ptr @calloc(i64 noundef 32768, i64 noundef 1) #12
  %71 = getelementptr inbounds i8, ptr %24, i64 16
  store ptr %70, ptr %71, align 8, !tbaa !19
  br i1 %68, label %75, label %72

72:                                               ; preds = %53
  %73 = call i32 @prepare(ptr noundef nonnull %24, i32 noundef 0)
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %.sink.split, label %75

75:                                               ; preds = %72, %53, %.thread
  %.sink = phi ptr [ %19, %.thread ], [ %24, %53 ], [ %24, %72 ]
  %76 = call i32 @fill_buffer(ptr noundef nonnull %.sink)
  %.073.in = icmp sgt i32 %76, 0
  br i1 %.073.in, label %78, label %.sink.split

.sink.split:                                      ; preds = %75, %72, %.thread92
  %.sink99 = phi ptr [ %24, %.thread92 ], [ %24, %72 ], [ %.sink, %75 ]
  %77 = call i32 @kurl_close(ptr noundef nonnull %.sink99)
  br label %78

78:                                               ; preds = %.sink.split, %75, %.critedge
  %.1 = phi ptr [ null, %.critedge ], [ %.sink, %75 ], [ null, %.sink.split ]
  ret ptr %.1
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #4

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #6

declare ptr @curl_multi_init() local_unnamed_addr #7

declare ptr @curl_easy_init() local_unnamed_addr #7

; Function Attrs: nounwind uwtable
declare dso_local void @s3_parse(ptr dead_on_unwind noalias writable sret(%struct.s3aux_t) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare ptr @curl_slist_append(ptr noundef, ptr noundef) local_unnamed_addr #7

declare i32 @curl_easy_setopt(ptr noundef, i32 noundef, ...) local_unnamed_addr #7

; Function Attrs: nounwind uwtable
declare hidden i64 @write_cb(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @fill_buffer(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @prepare(ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #8

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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nosync nounwind willreturn memory(none) "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 = { nofree "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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #7 = { "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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind willreturn memory(none) }
attributes #11 = { nounwind }
attributes #12 = { nounwind allocsize(0,1) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !6, i64 0}
!14 = !{!15, !17, i64 32}
!15 = !{!"kurl_t", !9, i64 0, !9, i64 8, !9, i64 16, !16, i64 24, !17, i64 32, !17, i64 36, !17, i64 40, !17, i64 44, !17, i64 48, !17, i64 52, !9, i64 56}
!16 = !{!"long", !6, i64 0}
!17 = !{!"int", !6, i64 0}
!18 = !{!15, !17, i64 36}
!19 = !{!15, !9, i64 16}
!20 = !{!15, !9, i64 0}
!21 = !{!15, !9, i64 8}
!22 = !{!23, !9, i64 0}
!23 = !{!"", !9, i64 0, !9, i64 8, !9, i64 16}
!24 = !{!23, !9, i64 8}
!25 = !{!23, !9, i64 16}
!26 = !{!15, !9, i64 56}


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