; LLVM IR from KhawajaAbaid/machine-learning-in-c :: gan (discriminator_backprop)

; 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.outputs_with_logits = type { ptr, ptr }
%struct.mlp = type { ptr, i64 }
%struct.metrics = type { double, double }
%struct.layer = type { ptr, ptr, i64, i64 }
%struct.grad_and_metrics = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @discriminator_backprop(ptr noundef %0, ptr noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %20 = call noalias ptr @malloc(i64 noundef 16) #7
  store ptr %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call ptr @copy_mlp(ptr noundef %21)
  store ptr %22, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call ptr @discriminator_forward_pass_with_logits(ptr noundef %23, ptr noundef %24)
  store ptr %25, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.outputs_with_logits, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  store ptr %28, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.outputs_with_logits, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  store ptr %31, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %32) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mlp, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = sub i64 %35, 1
  store i64 %36, ptr %12, align 8, !tbaa !17
  %37 = load double, ptr %6, align 8, !tbaa !9
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load i64, ptr %12, align 8, !tbaa !17
  %40 = add i64 %39, 1
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds double, ptr %42, i64 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = call double @binary_crossentropy_loss(double noundef %37, double noundef %44)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.metrics, ptr %46, i32 0, i32 0
  store double %45, ptr %47, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mlp, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !14
  %51 = mul i64 %50, 8
  %52 = call noalias ptr @malloc(i64 noundef %51) #7
  store ptr %52, ptr %13, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = load i64, ptr %12, align 8, !tbaa !17
  %55 = add i64 %54, 1
  %56 = getelementptr inbounds ptr, ptr %53, i64 %55
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = call ptr @vector_subtraction(ptr noundef %57, ptr noundef %6, i64 noundef 1)
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i64, ptr %12, align 8, !tbaa !17
  %61 = getelementptr inbounds ptr, ptr %59, i64 %60
  store ptr %58, ptr %61, align 8, !tbaa !5
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = load i64, ptr %12, align 8, !tbaa !17
  %64 = getelementptr inbounds ptr, ptr %62, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load i64, ptr %12, align 8, !tbaa !17
  %68 = getelementptr inbounds ptr, ptr %66, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mlp, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !20
  %73 = load i64, ptr %12, align 8, !tbaa !17
  %74 = getelementptr inbounds ptr, ptr %72, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.layer, ptr %75, i32 0, i32 3
  %77 = load i64, ptr %76, align 8, !tbaa !21
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mlp, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !20
  %81 = load i64, ptr %12, align 8, !tbaa !17
  %82 = getelementptr inbounds ptr, ptr %80, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.layer, ptr %83, i32 0, i32 2
  %85 = load i64, ptr %84, align 8, !tbaa !23
  %86 = call ptr @vector_outer_product(ptr noundef %65, ptr noundef %69, i64 noundef %77, i64 noundef %85)
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.mlp, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !20
  %90 = load i64, ptr %12, align 8, !tbaa !17
  %91 = getelementptr inbounds ptr, ptr %89, i64 %90
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.layer, ptr %92, i32 0, i32 0
  store ptr %86, ptr %93, align 8, !tbaa !24
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  %95 = load i64, ptr %12, align 8, !tbaa !17
  %96 = getelementptr inbounds ptr, ptr %94, i64 %95
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.mlp, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !20
  %101 = load i64, ptr %12, align 8, !tbaa !17
  %102 = getelementptr inbounds ptr, ptr %100, i64 %101
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.layer, ptr %103, i32 0, i32 1
  store ptr %97, ptr %104, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.mlp, ptr %105, i32 0, i32 1
  %107 = load i64, ptr %106, align 8, !tbaa !14
  %108 = sub i64 %107, 2
  %109 = trunc i64 %108 to i32
  store i32 %109, ptr %17, align 4, !tbaa !26
  br label %110

110:                                              ; preds = %267, %3
  %111 = load i32, ptr %17, align 4, !tbaa !26
  %112 = icmp sge i32 %111, 0
  br i1 %112, label %114, label %113

113:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %270

114:                                              ; preds = %110
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.mlp, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  %118 = load i32, ptr %17, align 4, !tbaa !26
  %119 = add nsw i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds ptr, ptr %117, i64 %120
  %122 = load ptr, ptr %121, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.layer, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !24
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.mlp, ptr %125, i32 0, i32 0
  %127 = load ptr, ptr %126, align 8, !tbaa !20
  %128 = load i32, ptr %17, align 4, !tbaa !26
  %129 = add nsw i32 %128, 1
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds ptr, ptr %127, i64 %130
  %132 = load ptr, ptr %131, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.layer, ptr %132, i32 0, i32 3
  %134 = load i64, ptr %133, align 8, !tbaa !21
  %135 = load ptr, ptr %4, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.mlp, ptr %135, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8, !tbaa !20
  %138 = load i32, ptr %17, align 4, !tbaa !26
  %139 = add nsw i32 %138, 1
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds ptr, ptr %137, i64 %140
  %142 = load ptr, ptr %141, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.layer, ptr %142, i32 0, i32 2
  %144 = load i64, ptr %143, align 8, !tbaa !23
  %145 = call ptr @matrix_transpose(ptr noundef %124, i64 noundef %134, i64 noundef %144)
  store ptr %145, ptr %14, align 8, !tbaa !5
  %146 = load ptr, ptr %14, align 8, !tbaa !5
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  %148 = load i32, ptr %17, align 4, !tbaa !26
  %149 = add nsw i32 %148, 1
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds ptr, ptr %147, i64 %150
  %152 = load ptr, ptr %151, align 8, !tbaa !5
  %153 = load ptr, ptr %4, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.mlp, ptr %153, i32 0, i32 0
  %155 = load ptr, ptr %154, align 8, !tbaa !20
  %156 = load i32, ptr %17, align 4, !tbaa !26
  %157 = add nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds ptr, ptr %155, i64 %158
  %160 = load ptr, ptr %159, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.layer, ptr %160, i32 0, i32 2
  %162 = load i64, ptr %161, align 8, !tbaa !23
  %163 = load ptr, ptr %4, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.mlp, ptr %163, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !20
  %166 = load i32, ptr %17, align 4, !tbaa !26
  %167 = add nsw i32 %166, 1
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds ptr, ptr %165, i64 %168
  %170 = load ptr, ptr %169, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.layer, ptr %170, i32 0, i32 3
  %172 = load i64, ptr %171, align 8, !tbaa !21
  %173 = call ptr @matrix_vector_dot_product(ptr noundef %146, ptr noundef %152, i64 noundef %162, i64 noundef %172)
  store ptr %173, ptr %15, align 8, !tbaa !5
  %174 = load ptr, ptr %14, align 8, !tbaa !5
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.mlp, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !20
  %178 = load i32, ptr %17, align 4, !tbaa !26
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds ptr, ptr %177, i64 %179
  %181 = load ptr, ptr %180, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.layer, ptr %181, i32 0, i32 3
  %183 = load i64, ptr %182, align 8, !tbaa !21
  call void @free_2d_matrix(ptr noundef %174, i64 noundef %183)
  %184 = load ptr, ptr %9, align 8, !tbaa !5
  %185 = load i32, ptr %17, align 4, !tbaa !26
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds ptr, ptr %184, i64 %186
  %188 = load ptr, ptr %187, align 8, !tbaa !5
  %189 = load ptr, ptr %4, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.mlp, ptr %189, i32 0, i32 0
  %191 = load ptr, ptr %190, align 8, !tbaa !20
  %192 = load i32, ptr %17, align 4, !tbaa !26
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds ptr, ptr %191, i64 %193
  %195 = load ptr, ptr %194, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.layer, ptr %195, i32 0, i32 3
  %197 = load i64, ptr %196, align 8, !tbaa !21
  %198 = call ptr @leaky_relu_prime(ptr noundef %188, double noundef 2.000000e-01, i64 noundef %197)
  store ptr %198, ptr %16, align 8, !tbaa !5
  %199 = load ptr, ptr %16, align 8, !tbaa !5
  %200 = load ptr, ptr %15, align 8, !tbaa !5
  %201 = load ptr, ptr %4, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.mlp, ptr %201, i32 0, i32 0
  %203 = load ptr, ptr %202, align 8, !tbaa !20
  %204 = load i32, ptr %17, align 4, !tbaa !26
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds ptr, ptr %203, i64 %205
  %207 = load ptr, ptr %206, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.layer, ptr %207, i32 0, i32 3
  %209 = load i64, ptr %208, align 8, !tbaa !21
  %210 = call ptr @vector_elementwise_product(ptr noundef %199, ptr noundef %200, i64 noundef %209)
  %211 = load ptr, ptr %13, align 8, !tbaa !5
  %212 = load i32, ptr %17, align 4, !tbaa !26
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds ptr, ptr %211, i64 %213
  store ptr %210, ptr %214, align 8, !tbaa !5
  %215 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %215) #6
  %216 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %216) #6
  %217 = load ptr, ptr %13, align 8, !tbaa !5
  %218 = load i32, ptr %17, align 4, !tbaa !26
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds ptr, ptr %217, i64 %219
  %221 = load ptr, ptr %220, align 8, !tbaa !5
  %222 = load ptr, ptr %10, align 8, !tbaa !5
  %223 = load i32, ptr %17, align 4, !tbaa !26
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds ptr, ptr %222, i64 %224
  %226 = load ptr, ptr %225, align 8, !tbaa !5
  %227 = load ptr, ptr %4, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.mlp, ptr %227, i32 0, i32 0
  %229 = load ptr, ptr %228, align 8, !tbaa !20
  %230 = load i32, ptr %17, align 4, !tbaa !26
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds ptr, ptr %229, i64 %231
  %233 = load ptr, ptr %232, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.layer, ptr %233, i32 0, i32 3
  %235 = load i64, ptr %234, align 8, !tbaa !21
  %236 = load ptr, ptr %4, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.mlp, ptr %236, i32 0, i32 0
  %238 = load ptr, ptr %237, align 8, !tbaa !20
  %239 = load i32, ptr %17, align 4, !tbaa !26
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds ptr, ptr %238, i64 %240
  %242 = load ptr, ptr %241, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.layer, ptr %242, i32 0, i32 2
  %244 = load i64, ptr %243, align 8, !tbaa !23
  %245 = call ptr @vector_outer_product(ptr noundef %221, ptr noundef %226, i64 noundef %235, i64 noundef %244)
  %246 = load ptr, ptr %8, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.mlp, ptr %246, i32 0, i32 0
  %248 = load ptr, ptr %247, align 8, !tbaa !20
  %249 = load i32, ptr %17, align 4, !tbaa !26
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds ptr, ptr %248, i64 %250
  %252 = load ptr, ptr %251, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.layer, ptr %252, i32 0, i32 0
  store ptr %245, ptr %253, align 8, !tbaa !24
  %254 = load ptr, ptr %13, align 8, !tbaa !5
  %255 = load i32, ptr %17, align 4, !tbaa !26
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds ptr, ptr %254, i64 %256
  %258 = load ptr, ptr %257, align 8, !tbaa !5
  %259 = load ptr, ptr %8, align 8, !tbaa !5
  %260 = getelementptr inbounds %struct.mlp, ptr %259, i32 0, i32 0
  %261 = load ptr, ptr %260, align 8, !tbaa !20
  %262 = load i32, ptr %17, align 4, !tbaa !26
  %263 = sext i32 %262 to i64
  %264 = getelementptr inbounds ptr, ptr %261, i64 %263
  %265 = load ptr, ptr %264, align 8, !tbaa !5
  %266 = getelementptr inbounds %struct.layer, ptr %265, i32 0, i32 1
  store ptr %258, ptr %266, align 8, !tbaa !25
  br label %267

267:                                              ; preds = %114
  %268 = load i32, ptr %17, align 4, !tbaa !26
  %269 = add nsw i32 %268, -1
  store i32 %269, ptr %17, align 4, !tbaa !26
  br label %110, !llvm.loop !28

270:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %271 = call noalias ptr @malloc(i64 noundef 16) #7
  store ptr %271, ptr %18, align 8, !tbaa !5
  %272 = load ptr, ptr %8, align 8, !tbaa !5
  %273 = load ptr, ptr %18, align 8, !tbaa !5
  %274 = getelementptr inbounds %struct.grad_and_metrics, ptr %273, i32 0, i32 0
  store ptr %272, ptr %274, align 8, !tbaa !13
  %275 = load ptr, ptr %10, align 8, !tbaa !5
  %276 = load i64, ptr %12, align 8, !tbaa !17
  %277 = add i64 %276, 1
  %278 = getelementptr inbounds ptr, ptr %275, i64 %277
  %279 = load ptr, ptr %278, align 8, !tbaa !5
  %280 = getelementptr inbounds double, ptr %279, i64 0
  %281 = load double, ptr %280, align 8, !tbaa !9
  %282 = fcmp oge double %281, 5.000000e-01
  %283 = zext i1 %282 to i32
  %284 = sitofp i32 %283 to double
  %285 = load ptr, ptr %7, align 8, !tbaa !5
  %286 = getelementptr inbounds %struct.metrics, ptr %285, i32 0, i32 1
  store double %284, ptr %286, align 8, !tbaa !30
  %287 = load ptr, ptr %7, align 8, !tbaa !5
  %288 = load ptr, ptr %18, align 8, !tbaa !5
  %289 = getelementptr inbounds %struct.grad_and_metrics, ptr %288, i32 0, i32 1
  store ptr %287, ptr %289, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  store i64 0, ptr %19, align 8, !tbaa !17
  br label %290

290:                                              ; preds = %307, %270
  %291 = load i64, ptr %19, align 8, !tbaa !17
  %292 = load ptr, ptr %4, align 8, !tbaa !5
  %293 = getelementptr inbounds %struct.mlp, ptr %292, i32 0, i32 1
  %294 = load i64, ptr %293, align 8, !tbaa !14
  %295 = icmp ult i64 %291, %294
  br i1 %295, label %297, label %296

296:                                              ; preds = %290
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %310

297:                                              ; preds = %290
  %298 = load ptr, ptr %9, align 8, !tbaa !5
  %299 = load i64, ptr %19, align 8, !tbaa !17
  %300 = getelementptr inbounds ptr, ptr %298, i64 %299
  %301 = load ptr, ptr %300, align 8, !tbaa !5
  call void @free(ptr noundef %301) #6
  %302 = load ptr, ptr %10, align 8, !tbaa !5
  %303 = load i64, ptr %19, align 8, !tbaa !17
  %304 = add i64 %303, 1
  %305 = getelementptr inbounds ptr, ptr %302, i64 %304
  %306 = load ptr, ptr %305, align 8, !tbaa !5
  call void @free(ptr noundef %306) #6
  br label %307

307:                                              ; preds = %297
  %308 = load i64, ptr %19, align 8, !tbaa !17
  %309 = add i64 %308, 1
  store i64 %309, ptr %19, align 8, !tbaa !17
  br label %290, !llvm.loop !31

310:                                              ; preds = %296
  %311 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %311) #6
  %312 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %312) #6
  %313 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %313) #6
  %314 = load ptr, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret ptr %314
}

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

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

declare ptr @copy_mlp(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @discriminator_forward_pass_with_logits(ptr noundef, ptr noundef) #4

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @binary_crossentropy_loss(double noundef, double noundef) #4

declare ptr @vector_subtraction(ptr noundef, ptr noundef, i64 noundef) #3

declare ptr @vector_outer_product(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #3

declare ptr @matrix_transpose(ptr noundef, i64 noundef, i64 noundef) #3

declare ptr @matrix_vector_dot_product(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @free_2d_matrix(ptr noundef, i64 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @leaky_relu_prime(ptr noundef, double noundef, i64 noundef) #4

declare ptr @vector_elementwise_product(ptr noundef, ptr noundef, i64 noundef) #3

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

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 = { 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 #3 = { "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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !16, i64 8}
!15 = !{!"", !6, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!19, !10, i64 0}
!19 = !{!"metrics", !10, i64 0, !10, i64 8}
!20 = !{!15, !6, i64 0}
!21 = !{!22, !16, i64 24}
!22 = !{!"", !6, i64 0, !6, i64 8, !16, i64 16, !16, i64 24}
!23 = !{!22, !16, i64 16}
!24 = !{!22, !6, i64 0}
!25 = !{!22, !6, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"int", !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!19, !10, i64 8}
!31 = distinct !{!31, !29}


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

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @discriminator_backprop(ptr noundef %0, ptr noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = alloca double, align 8
  store double %2, ptr %4, align 8, !tbaa !5
  %5 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #5
  %6 = tail call ptr @copy_mlp(ptr noundef %0) #6
  %7 = tail call ptr @discriminator_forward_pass_with_logits(ptr noundef %0, ptr noundef %1)
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %7, align 8, !tbaa !12
  tail call void @free(ptr noundef %7) #6
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !13
  %13 = add i64 %12, -1
  %14 = getelementptr inbounds ptr, ptr %9, i64 %12
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call double @binary_crossentropy_loss(double noundef %2, double noundef %16)
  store double %17, ptr %5, align 8, !tbaa !17
  %18 = load i64, ptr %11, align 8, !tbaa !13
  %19 = shl i64 %18, 3
  %20 = tail call noalias ptr @malloc(i64 noundef %19) #5
  %21 = load ptr, ptr %14, align 8, !tbaa !16
  %22 = call ptr @vector_subtraction(ptr noundef %21, ptr noundef nonnull %4, i64 noundef 1) #6
  %23 = getelementptr inbounds ptr, ptr %20, i64 %13
  store ptr %22, ptr %23, align 8, !tbaa !16
  %24 = getelementptr inbounds ptr, ptr %9, i64 %13
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %0, align 8, !tbaa !19
  %27 = getelementptr inbounds ptr, ptr %26, i64 %13
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %28, i64 24
  %30 = load i64, ptr %29, align 8, !tbaa !20
  %31 = getelementptr inbounds i8, ptr %28, i64 16
  %32 = load i64, ptr %31, align 8, !tbaa !22
  %33 = call ptr @vector_outer_product(ptr noundef %22, ptr noundef %25, i64 noundef %30, i64 noundef %32) #6
  %34 = load ptr, ptr %6, align 8, !tbaa !19
  %35 = getelementptr inbounds ptr, ptr %34, i64 %13
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  store ptr %33, ptr %36, align 8, !tbaa !23
  %37 = load ptr, ptr %35, align 8, !tbaa !16
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  store ptr %22, ptr %38, align 8, !tbaa !24
  %39 = load i64, ptr %11, align 8, !tbaa !13
  %40 = trunc i64 %39 to i32
  %41 = add i32 %40, -2
  %42 = icmp sgt i32 %41, -1
  br i1 %42, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %43 = zext nneg i32 %41 to i64
  br label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %11, align 8, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %44 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %39, %3 ]
  %45 = call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #5
  store ptr %6, ptr %45, align 8, !tbaa !12
  %46 = load ptr, ptr %14, align 8, !tbaa !16
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = fcmp oge double %47, 5.000000e-01
  %49 = uitofp i1 %48 to double
  %50 = getelementptr inbounds i8, ptr %5, i64 8
  store double %49, ptr %50, align 8, !tbaa !25
  %51 = getelementptr inbounds i8, ptr %45, i64 8
  store ptr %5, ptr %51, align 8, !tbaa !9
  %.not = icmp eq i64 %44, 0
  br i1 %.not, label %._crit_edge96, label %.lr.ph95

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %43, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %52 = load ptr, ptr %0, align 8, !tbaa !19
  %53 = add nuw nsw i64 %indvars.iv, 1
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = getelementptr inbounds i8, ptr %55, i64 24
  %58 = load i64, ptr %57, align 8, !tbaa !20
  %59 = getelementptr inbounds i8, ptr %55, i64 16
  %60 = load i64, ptr %59, align 8, !tbaa !22
  %61 = call ptr @matrix_transpose(ptr noundef %56, i64 noundef %58, i64 noundef %60) #6
  %62 = getelementptr inbounds ptr, ptr %20, i64 %53
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load ptr, ptr %0, align 8, !tbaa !19
  %65 = getelementptr inbounds ptr, ptr %64, i64 %53
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = getelementptr inbounds i8, ptr %66, i64 16
  %68 = load i64, ptr %67, align 8, !tbaa !22
  %69 = getelementptr inbounds i8, ptr %66, i64 24
  %70 = load i64, ptr %69, align 8, !tbaa !20
  %71 = call ptr @matrix_vector_dot_product(ptr noundef %61, ptr noundef %63, i64 noundef %68, i64 noundef %70) #6
  %72 = load ptr, ptr %0, align 8, !tbaa !19
  %73 = getelementptr inbounds ptr, ptr %72, i64 %indvars.iv
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = getelementptr inbounds i8, ptr %74, i64 24
  %76 = load i64, ptr %75, align 8, !tbaa !20
  call void @free_2d_matrix(ptr noundef %61, i64 noundef %76)
  %77 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  %79 = load ptr, ptr %0, align 8, !tbaa !19
  %80 = getelementptr inbounds ptr, ptr %79, i64 %indvars.iv
  %81 = load ptr, ptr %80, align 8, !tbaa !16
  %82 = getelementptr inbounds i8, ptr %81, i64 24
  %83 = load i64, ptr %82, align 8, !tbaa !20
  %84 = call ptr @leaky_relu_prime(ptr noundef %78, double noundef 2.000000e-01, i64 noundef %83)
  %85 = load ptr, ptr %0, align 8, !tbaa !19
  %86 = getelementptr inbounds ptr, ptr %85, i64 %indvars.iv
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = getelementptr inbounds i8, ptr %87, i64 24
  %89 = load i64, ptr %88, align 8, !tbaa !20
  %90 = call ptr @vector_elementwise_product(ptr noundef %84, ptr noundef %71, i64 noundef %89) #6
  %91 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  store ptr %90, ptr %91, align 8, !tbaa !16
  call void @free(ptr noundef %71) #6
  call void @free(ptr noundef %84) #6
  %92 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %94 = load ptr, ptr %0, align 8, !tbaa !19
  %95 = getelementptr inbounds ptr, ptr %94, i64 %indvars.iv
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = getelementptr inbounds i8, ptr %96, i64 24
  %98 = load i64, ptr %97, align 8, !tbaa !20
  %99 = getelementptr inbounds i8, ptr %96, i64 16
  %100 = load i64, ptr %99, align 8, !tbaa !22
  %101 = call ptr @vector_outer_product(ptr noundef %90, ptr noundef %93, i64 noundef %98, i64 noundef %100) #6
  %102 = load ptr, ptr %6, align 8, !tbaa !19
  %103 = getelementptr inbounds ptr, ptr %102, i64 %indvars.iv
  %104 = load ptr, ptr %103, align 8, !tbaa !16
  store ptr %101, ptr %104, align 8, !tbaa !23
  %105 = load ptr, ptr %103, align 8, !tbaa !16
  %106 = getelementptr inbounds i8, ptr %105, i64 8
  store ptr %90, ptr %106, align 8, !tbaa !24
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not98 = icmp eq i64 %indvars.iv, 0
  br i1 %.not98, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !26

._crit_edge96:                                    ; preds = %.lr.ph95, %._crit_edge
  call void @free(ptr noundef %10) #6
  call void @free(ptr noundef nonnull %9) #6
  call void @free(ptr noundef %20) #6
  ret ptr %45

.lr.ph95:                                         ; preds = %._crit_edge, %.lr.ph95
  %.093 = phi i64 [ %109, %.lr.ph95 ], [ 0, %._crit_edge ]
  %107 = getelementptr inbounds ptr, ptr %10, i64 %.093
  %108 = load ptr, ptr %107, align 8, !tbaa !16
  call void @free(ptr noundef %108) #6
  %109 = add nuw i64 %.093, 1
  %110 = getelementptr inbounds ptr, ptr %9, i64 %109
  %111 = load ptr, ptr %110, align 8, !tbaa !16
  call void @free(ptr noundef %111) #6
  %112 = load i64, ptr %11, align 8, !tbaa !13
  %113 = icmp ult i64 %109, %112
  br i1 %113, label %.lr.ph95, label %._crit_edge96, !llvm.loop !28
}

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

declare ptr @copy_mlp(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @discriminator_forward_pass_with_logits(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @binary_crossentropy_loss(double noundef, double noundef) local_unnamed_addr #3

declare ptr @vector_subtraction(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare ptr @vector_outer_product(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare ptr @matrix_transpose(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare ptr @matrix_vector_dot_product(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @leaky_relu_prime(ptr noundef, double noundef, i64 noundef) local_unnamed_addr #3

declare ptr @vector_elementwise_product(ptr noundef, ptr noundef, i64 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 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 #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 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 = { 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 #5 = { nounwind allocsize(0) }
attributes #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"", !11, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"metrics", !6, i64 0, !6, i64 8}
!19 = !{!14, !11, i64 0}
!20 = !{!21, !15, i64 24}
!21 = !{!"", !11, i64 0, !11, i64 8, !15, i64 16, !15, i64 24}
!22 = !{!21, !15, i64 16}
!23 = !{!21, !11, i64 0}
!24 = !{!21, !11, i64 8}
!25 = !{!18, !6, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


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