; LLVM IR from pranjalwalia/Competitive-programming :: Hackerrank/language/C (Post Transition)

; 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.town = type { ptr, ptr, i32 }
%struct.post_office = type { i32, i32, ptr, i32 }
%struct.package = type { ptr, i32 }

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_all_packages(ptr noundef byval(%struct.town) align 8) #0

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [6 x i8], align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca %struct.town, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = mul i64 24, %19
  %21 = call noalias ptr @malloc(i64 noundef %20) #5
  store ptr %21, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %200, %0
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %203

27:                                               ; preds = %22
  %28 = call noalias ptr @malloc(i64 noundef 6) #5
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.town, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.town, ptr %32, i32 0, i32 0
  store ptr %28, ptr %33, align 8, !tbaa !11
  %34 = load ptr, ptr %3, align 8, !tbaa !9
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %struct.town, ptr %34, i64 %36
  %38 = getelementptr inbounds %struct.town, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %39)
  %41 = load ptr, ptr %3, align 8, !tbaa !9
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %struct.town, ptr %41, i64 %43
  %45 = getelementptr inbounds %struct.town, ptr %44, i32 0, i32 2
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %45)
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %struct.town, ptr %47, i64 %49
  %51 = getelementptr inbounds %struct.town, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !13
  %53 = sext i32 %52 to i64
  %54 = mul i64 24, %53
  %55 = call noalias ptr @malloc(i64 noundef %54) #5
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.town, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.town, ptr %59, i32 0, i32 1
  store ptr %55, ptr %60, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %196, %27
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.town, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.town, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = icmp slt i32 %62, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %61
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %199

71:                                               ; preds = %61
  %72 = load ptr, ptr %3, align 8, !tbaa !9
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.town, ptr %72, i64 %74
  %76 = getelementptr inbounds %struct.town, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !14
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.post_office, ptr %77, i64 %79
  %81 = getelementptr inbounds %struct.post_office, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %3, align 8, !tbaa !9
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.town, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.town, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.post_office, ptr %87, i64 %89
  %91 = getelementptr inbounds %struct.post_office, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %3, align 8, !tbaa !9
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %struct.town, ptr %92, i64 %94
  %96 = getelementptr inbounds %struct.town, ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !14
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds %struct.post_office, ptr %97, i64 %99
  %101 = getelementptr inbounds %struct.post_office, ptr %100, i32 0, i32 1
  %102 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %81, ptr noundef %91, ptr noundef %101)
  %103 = load ptr, ptr %3, align 8, !tbaa !9
  %104 = load i32, ptr %4, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.town, ptr %103, i64 %105
  %107 = getelementptr inbounds %struct.town, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds %struct.post_office, ptr %108, i64 %110
  %112 = getelementptr inbounds %struct.post_office, ptr %111, i32 0, i32 3
  %113 = load i32, ptr %112, align 8, !tbaa !15
  %114 = sext i32 %113 to i64
  %115 = mul i64 16, %114
  %116 = call noalias ptr @malloc(i64 noundef %115) #5
  %117 = load ptr, ptr %3, align 8, !tbaa !9
  %118 = load i32, ptr %4, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.town, ptr %117, i64 %119
  %121 = getelementptr inbounds %struct.town, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !14
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds %struct.post_office, ptr %122, i64 %124
  %126 = getelementptr inbounds %struct.post_office, ptr %125, i32 0, i32 2
  store ptr %116, ptr %126, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %127

127:                                              ; preds = %192, %71
  %128 = load i32, ptr %7, align 4, !tbaa !5
  %129 = load ptr, ptr %3, align 8, !tbaa !9
  %130 = load i32, ptr %4, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds %struct.town, ptr %129, i64 %131
  %133 = getelementptr inbounds %struct.town, ptr %132, i32 0, i32 1
  %134 = load ptr, ptr %133, align 8, !tbaa !14
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds %struct.post_office, ptr %134, i64 %136
  %138 = getelementptr inbounds %struct.post_office, ptr %137, i32 0, i32 3
  %139 = load i32, ptr %138, align 8, !tbaa !15
  %140 = icmp slt i32 %128, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %127
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %195

142:                                              ; preds = %127
  %143 = call noalias ptr @malloc(i64 noundef 6) #5
  %144 = load ptr, ptr %3, align 8, !tbaa !9
  %145 = load i32, ptr %4, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds %struct.town, ptr %144, i64 %146
  %148 = getelementptr inbounds %struct.town, ptr %147, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !14
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds %struct.post_office, ptr %149, i64 %151
  %153 = getelementptr inbounds %struct.post_office, ptr %152, i32 0, i32 2
  %154 = load ptr, ptr %153, align 8, !tbaa !17
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds %struct.package, ptr %154, i64 %156
  %158 = getelementptr inbounds %struct.package, ptr %157, i32 0, i32 0
  store ptr %143, ptr %158, align 8, !tbaa !18
  %159 = load ptr, ptr %3, align 8, !tbaa !9
  %160 = load i32, ptr %4, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds %struct.town, ptr %159, i64 %161
  %163 = getelementptr inbounds %struct.town, ptr %162, i32 0, i32 1
  %164 = load ptr, ptr %163, align 8, !tbaa !14
  %165 = load i32, ptr %6, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds %struct.post_office, ptr %164, i64 %166
  %168 = getelementptr inbounds %struct.post_office, ptr %167, i32 0, i32 2
  %169 = load ptr, ptr %168, align 8, !tbaa !17
  %170 = load i32, ptr %7, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds %struct.package, ptr %169, i64 %171
  %173 = getelementptr inbounds %struct.package, ptr %172, i32 0, i32 0
  %174 = load ptr, ptr %173, align 8, !tbaa !18
  %175 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %174)
  %176 = load ptr, ptr %3, align 8, !tbaa !9
  %177 = load i32, ptr %4, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds %struct.town, ptr %176, i64 %178
  %180 = getelementptr inbounds %struct.town, ptr %179, i32 0, i32 1
  %181 = load ptr, ptr %180, align 8, !tbaa !14
  %182 = load i32, ptr %6, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds %struct.post_office, ptr %181, i64 %183
  %185 = getelementptr inbounds %struct.post_office, ptr %184, i32 0, i32 2
  %186 = load ptr, ptr %185, align 8, !tbaa !17
  %187 = load i32, ptr %7, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds %struct.package, ptr %186, i64 %188
  %190 = getelementptr inbounds %struct.package, ptr %189, i32 0, i32 1
  %191 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %190)
  br label %192

192:                                              ; preds = %142
  %193 = load i32, ptr %7, align 4, !tbaa !5
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %7, align 4, !tbaa !5
  br label %127, !llvm.loop !20

195:                                              ; preds = %141
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %6, align 4, !tbaa !5
  br label %61, !llvm.loop !22

199:                                              ; preds = %70
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %4, align 4, !tbaa !5
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %4, align 4, !tbaa !5
  br label %22, !llvm.loop !23

203:                                              ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %204 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 6, ptr %9) #4
  br label %205

205:                                              ; preds = %245, %203
  %206 = load i32, ptr %8, align 4, !tbaa !5
  %207 = add nsw i32 %206, -1
  store i32 %207, ptr %8, align 4, !tbaa !5
  %208 = icmp ne i32 %206, 0
  br i1 %208, label %209, label %246

209:                                              ; preds = %205
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %210 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %10)
  %211 = load i32, ptr %10, align 4, !tbaa !5
  switch i32 %211, label %245 [
    i32 1, label %212
    i32 2, label %220
    i32 3, label %239
  ]

212:                                              ; preds = %209
  %213 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %214 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %213)
  %215 = load ptr, ptr %3, align 8, !tbaa !9
  %216 = load i32, ptr %2, align 4, !tbaa !5
  %217 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %218 = call ptr @find_town(ptr noundef %215, i32 noundef %216, ptr noundef %217)
  store ptr %218, ptr %11, align 8, !tbaa !9
  %219 = load ptr, ptr %11, align 8, !tbaa !9
  call void @print_all_packages(ptr noundef byval(%struct.town) align 8 %219)
  br label %245

220:                                              ; preds = %209
  %221 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %222 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %221)
  %223 = load ptr, ptr %3, align 8, !tbaa !9
  %224 = load i32, ptr %2, align 4, !tbaa !5
  %225 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %226 = call ptr @find_town(ptr noundef %223, i32 noundef %224, ptr noundef %225)
  store ptr %226, ptr %12, align 8, !tbaa !9
  %227 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %13)
  %228 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %229 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %228)
  %230 = load ptr, ptr %3, align 8, !tbaa !9
  %231 = load i32, ptr %2, align 4, !tbaa !5
  %232 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %233 = call ptr @find_town(ptr noundef %230, i32 noundef %231, ptr noundef %232)
  store ptr %233, ptr %14, align 8, !tbaa !9
  %234 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %15)
  %235 = load ptr, ptr %12, align 8, !tbaa !9
  %236 = load i32, ptr %13, align 4, !tbaa !5
  %237 = load ptr, ptr %14, align 8, !tbaa !9
  %238 = load i32, ptr %15, align 4, !tbaa !5
  call void @send_all_acceptable_packages(ptr noundef %235, i32 noundef %236, ptr noundef %237, i32 noundef %238)
  br label %245

239:                                              ; preds = %209
  %240 = load ptr, ptr %3, align 8, !tbaa !9
  %241 = load i32, ptr %2, align 4, !tbaa !5
  call void @town_with_most_packages(ptr dead_on_unwind writable sret(%struct.town) align 8 %16, ptr noundef %240, i32 noundef %241)
  %242 = getelementptr inbounds %struct.town, ptr %16, i32 0, i32 0
  %243 = load ptr, ptr %242, align 8, !tbaa !11
  %244 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %243)
  br label %245

245:                                              ; preds = %239, %220, %212, %209
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %205, !llvm.loop !24

246:                                              ; preds = %205
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 6, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %247 = load i32, ptr %1, align 4
  ret i32 %247
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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 = { "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 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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 = !{!12, !10, i64 0}
!12 = !{!"town", !10, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !10, i64 8}
!15 = !{!16, !6, i64 16}
!16 = !{!"post_office", !6, i64 0, !6, i64 4, !10, i64 8, !6, i64 16}
!17 = !{!16, !10, i64 8}
!18 = !{!19, !10, i64 0}
!19 = !{!"package", !10, i64 0, !6, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}
!24 = distinct !{!24, !21}


; 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.town = type { ptr, ptr, i32 }
%struct.post_office = type { i32, i32, ptr, i32 }
%struct.package = type { ptr, i32 }

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_all_packages(ptr noundef byval(%struct.town) align 8) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [6 x i8], align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.town, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = mul nsw i64 %10, 24
  %12 = call noalias ptr @malloc(i64 noundef %11) #5
  %13 = icmp sgt i32 %9, 0
  br i1 %13, label %.lr.ph64, label %._crit_edge65

._crit_edge65:                                    ; preds = %._crit_edge61, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %3) #4
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr %2, align 4, !tbaa !5
  %.not66 = icmp eq i32 %15, 0
  br i1 %.not66, label %._crit_edge69, label %.lr.ph68

.lr.ph64:                                         ; preds = %0, %._crit_edge61
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %._crit_edge61 ], [ 0, %0 ]
  %17 = call noalias dereferenceable_or_null(6) ptr @malloc(i64 noundef 6) #5
  %18 = getelementptr inbounds %struct.town, ptr %12, i64 %indvars.iv74
  store ptr %17, ptr %18, align 8, !tbaa !9
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef %17)
  %20 = getelementptr inbounds i8, ptr %18, i64 16
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %20)
  %22 = load i32, ptr %20, align 8, !tbaa !12
  %23 = sext i32 %22 to i64
  %24 = mul nsw i64 %23, 24
  %25 = call noalias ptr @malloc(i64 noundef %24) #5
  %26 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %25, ptr %26, align 8, !tbaa !13
  %27 = icmp sgt i32 %22, 0
  br i1 %27, label %.lr.ph60, label %._crit_edge61

._crit_edge61:                                    ; preds = %._crit_edge, %.lr.ph64
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next75, %29
  br i1 %30, label %.lr.ph64, label %._crit_edge65, !llvm.loop !14

.lr.ph60:                                         ; preds = %.lr.ph64, %._crit_edge
  %31 = phi ptr [ %44, %._crit_edge ], [ %25, %.lr.ph64 ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %._crit_edge ], [ 0, %.lr.ph64 ]
  %32 = getelementptr inbounds %struct.post_office, ptr %31, i64 %indvars.iv71
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = getelementptr inbounds i8, ptr %32, i64 4
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %33, ptr noundef %32, ptr noundef nonnull %34)
  %36 = load ptr, ptr %26, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.post_office, ptr %36, i64 %indvars.iv71, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !16
  %39 = sext i32 %38 to i64
  %40 = shl nsw i64 %39, 4
  %41 = call noalias ptr @malloc(i64 noundef %40) #5
  %42 = getelementptr inbounds %struct.post_office, ptr %36, i64 %indvars.iv71, i32 2
  store ptr %41, ptr %42, align 8, !tbaa !18
  %43 = icmp sgt i32 %38, 0
  br i1 %43, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph60
  %44 = phi ptr [ %36, %.lr.ph60 ], [ %59, %.lr.ph ]
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %45 = load i32, ptr %20, align 8, !tbaa !12
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next72, %46
  br i1 %47, label %.lr.ph60, label %._crit_edge61, !llvm.loop !19

.lr.ph:                                           ; preds = %.lr.ph60, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph60 ]
  %48 = phi ptr [ %59, %.lr.ph ], [ %36, %.lr.ph60 ]
  %49 = call noalias dereferenceable_or_null(6) ptr @malloc(i64 noundef 6) #5
  %50 = getelementptr inbounds %struct.post_office, ptr %48, i64 %indvars.iv71, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = getelementptr inbounds %struct.package, ptr %51, i64 %indvars.iv
  store ptr %49, ptr %52, align 8, !tbaa !20
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef %49)
  %54 = load ptr, ptr %26, align 8, !tbaa !13
  %55 = getelementptr inbounds %struct.post_office, ptr %54, i64 %indvars.iv71, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %57 = getelementptr inbounds %struct.package, ptr %56, i64 %indvars.iv, i32 1
  %58 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %57)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %59 = load ptr, ptr %26, align 8, !tbaa !13
  %60 = getelementptr inbounds %struct.post_office, ptr %59, i64 %indvars.iv71, i32 3
  %61 = load i32, ptr %60, align 8, !tbaa !16
  %62 = sext i32 %61 to i64
  %63 = icmp slt i64 %indvars.iv.next, %62
  br i1 %63, label %.lr.ph, label %._crit_edge, !llvm.loop !22

.lr.ph68:                                         ; preds = %._crit_edge65, %85
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %4)
  %65 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %65, label %85 [
    i32 1, label %66
    i32 2, label %70
    i32 3, label %81
  ]

66:                                               ; preds = %.lr.ph68
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %3)
  %68 = load i32, ptr %1, align 4, !tbaa !5
  %69 = call ptr @find_town(ptr noundef %12, i32 noundef %68, ptr noundef nonnull %3)
  call void @print_all_packages(ptr noundef byval(%struct.town) align 8 %69)
  br label %85

70:                                               ; preds = %.lr.ph68
  %71 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %3)
  %72 = load i32, ptr %1, align 4, !tbaa !5
  %73 = call ptr @find_town(ptr noundef %12, i32 noundef %72, ptr noundef nonnull %3)
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %5)
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %3)
  %76 = load i32, ptr %1, align 4, !tbaa !5
  %77 = call ptr @find_town(ptr noundef %12, i32 noundef %76, ptr noundef nonnull %3)
  %78 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %6)
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !5
  call void @send_all_acceptable_packages(ptr noundef %73, i32 noundef %79, ptr noundef %77, i32 noundef %80)
  br label %85

81:                                               ; preds = %.lr.ph68
  %82 = load i32, ptr %1, align 4, !tbaa !5
  call void @town_with_most_packages(ptr dead_on_unwind nonnull writable sret(%struct.town) align 8 %7, ptr noundef %12, i32 noundef %82)
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %83)
  br label %85

85:                                               ; preds = %81, %70, %66, %.lr.ph68
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %86, 0
  br i1 %.not, label %._crit_edge69, label %.lr.ph68, !llvm.loop !23

._crit_edge69:                                    ; preds = %85, %._crit_edge65
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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, !11, i64 0}
!10 = !{!"town", !11, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !11, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !6, i64 16}
!17 = !{!"post_office", !6, i64 0, !6, i64 4, !11, i64 8, !6, i64 16}
!18 = !{!17, !11, i64 8}
!19 = distinct !{!19, !15}
!20 = !{!21, !11, i64 0}
!21 = !{!"package", !11, i64 0, !6, i64 8}
!22 = distinct !{!22, !15}
!23 = distinct !{!23, !15}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass