; LLVM IR from ESPboy-edu/ESPboy_tinyphysicsengine :: programs (hello2)

; 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.TPE_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }
%struct.TPE_Vec3 = type { i32, i32, i32 }
%struct.TPE_Body = type { ptr, i8, ptr, i8, i16, i16, i16, i8, i8 }
%struct.TPE_World = type { ptr, i16, ptr, ptr }
%struct.TPE_Connection = type { i8, i8, i16 }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_joint(ptr dead_on_unwind noalias writable sret(%struct.TPE_Joint) align 4, i64, i32, i32 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) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) #0

; 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 @TPE_bodyInit(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef, i8 noundef zeroext, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_worldInit(ptr noundef, ptr noundef, i16 noundef zeroext, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_bodyGetCenterOfMass(ptr noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @environmentDistance(i64, i32, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @clearScreen() #0

; Function Attrs: nounwind uwtable
declare dso_local void @setPixel(i32 noundef, i32 noundef, i8 noundef signext) #0

; Function Attrs: nounwind uwtable
declare dso_local void @printScreen() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [2 x %struct.TPE_Body], align 16
  %3 = alloca %struct.TPE_World, align 8
  %4 = alloca [32 x %struct.TPE_Joint], align 16
  %5 = alloca [64 x %struct.TPE_Connection], align 16
  %6 = alloca %struct.TPE_Joint, align 4
  %7 = alloca %struct.TPE_Vec3, align 4
  %8 = alloca { i64, i32 }, align 8
  %9 = alloca { i64, i32 }, align 4
  %10 = alloca %struct.TPE_Joint, align 4
  %11 = alloca %struct.TPE_Vec3, align 4
  %12 = alloca { i64, i32 }, align 8
  %13 = alloca { i64, i32 }, align 4
  %14 = alloca %struct.TPE_Vec3, align 4
  %15 = alloca { i64, i32 }, align 8
  %16 = alloca { i64, i32 }, align 4
  %17 = alloca %struct.TPE_Vec3, align 4
  %18 = alloca { i64, i32 }, align 8
  %19 = alloca { i64, i32 }, align 4
  %20 = alloca %struct.TPE_Vec3, align 4
  %21 = alloca { i64, i32 }, align 8
  %22 = alloca { i64, i32 }, align 4
  %23 = alloca %struct.TPE_Vec3, align 4
  %24 = alloca { i64, i32 }, align 8
  %25 = alloca { i64, i32 }, align 4
  %26 = alloca %struct.TPE_Vec3, align 4
  %27 = alloca { i64, i32 }, align 8
  %28 = alloca { i64, i32 }, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  %33 = alloca %struct.TPE_Vec3, align 4
  %34 = alloca %struct.TPE_Vec3, align 4
  %35 = alloca { i64, i32 }, align 8
  %36 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 640, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %5) #5
  %37 = getelementptr inbounds [32 x %struct.TPE_Joint], ptr %4, i64 0, i64 0
  call void @llvm.lifetime.start.p0(i64 20, ptr %6) #5
  %38 = call { i64, i32 } @TPE_vec3(i32 noundef 7680, i32 noundef 5120, i32 noundef 0)
  store { i64, i32 } %38, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 8 %8, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %7, i64 12, i1 false)
  %39 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %40 = load i64, ptr %39, align 4
  %41 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %42 = load i32, ptr %41, align 4
  call void @TPE_joint(ptr dead_on_unwind writable sret(%struct.TPE_Joint) align 4 %6, i64 %40, i32 %42, i32 noundef 512)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %37, ptr align 4 %6, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr %6) #5
  %43 = getelementptr inbounds [32 x %struct.TPE_Joint], ptr %4, i64 0, i64 1
  call void @llvm.lifetime.start.p0(i64 20, ptr %10) #5
  %44 = call { i64, i32 } @TPE_vec3(i32 noundef 9728, i32 noundef 5120, i32 noundef 0)
  store { i64, i32 } %44, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %11, i64 12, i1 false)
  %45 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  %46 = load i64, ptr %45, align 4
  %47 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  %48 = load i32, ptr %47, align 4
  call void @TPE_joint(ptr dead_on_unwind writable sret(%struct.TPE_Joint) align 4 %10, i64 %46, i32 %48, i32 noundef 512)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %43, ptr align 4 %10, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr %10) #5
  %49 = getelementptr inbounds [64 x %struct.TPE_Connection], ptr %5, i64 0, i64 0
  %50 = getelementptr inbounds %struct.TPE_Connection, ptr %49, i32 0, i32 0
  store i8 0, ptr %50, align 16, !tbaa !11
  %51 = getelementptr inbounds [64 x %struct.TPE_Connection], ptr %5, i64 0, i64 0
  %52 = getelementptr inbounds %struct.TPE_Connection, ptr %51, i32 0, i32 1
  store i8 1, ptr %52, align 1, !tbaa !14
  %53 = getelementptr inbounds [2 x %struct.TPE_Body], ptr %2, i64 0, i64 0
  %54 = getelementptr inbounds [32 x %struct.TPE_Joint], ptr %4, i64 0, i64 0
  %55 = getelementptr inbounds [64 x %struct.TPE_Connection], ptr %5, i64 0, i64 0
  call void @TPE_bodyInit(ptr noundef %53, ptr noundef %54, i8 noundef zeroext 2, ptr noundef %55, i8 noundef zeroext 1, i32 noundef 512)
  %56 = getelementptr inbounds [32 x %struct.TPE_Joint], ptr %4, i64 0, i64 0
  %57 = getelementptr inbounds %struct.TPE_Joint, ptr %56, i64 2
  %58 = getelementptr inbounds [64 x %struct.TPE_Connection], ptr %5, i64 0, i64 0
  %59 = getelementptr inbounds %struct.TPE_Connection, ptr %58, i64 1
  call void @TPE_makeBox(ptr noundef %57, ptr noundef %59, i32 noundef 1024, i32 noundef 1024, i32 noundef 1024, i32 noundef 512)
  %60 = getelementptr inbounds [2 x %struct.TPE_Body], ptr %2, i64 0, i64 1
  %61 = getelementptr inbounds [32 x %struct.TPE_Joint], ptr %4, i64 0, i64 0
  %62 = getelementptr inbounds %struct.TPE_Joint, ptr %61, i64 2
  %63 = getelementptr inbounds [64 x %struct.TPE_Connection], ptr %5, i64 0, i64 0
  %64 = getelementptr inbounds %struct.TPE_Connection, ptr %63, i64 1
  call void @TPE_bodyInit(ptr noundef %60, ptr noundef %62, i8 noundef zeroext 8, ptr noundef %64, i8 noundef zeroext 16, i32 noundef 512)
  %65 = getelementptr inbounds [2 x %struct.TPE_Body], ptr %2, i64 0, i64 1
  %66 = call { i64, i32 } @TPE_vec3(i32 noundef 5120, i32 noundef 5120, i32 noundef 0)
  store { i64, i32 } %66, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %15, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %14, i64 12, i1 false)
  %67 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %68 = load i64, ptr %67, align 4
  %69 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %70 = load i32, ptr %69, align 4
  call void @TPE_bodyMoveTo(ptr noundef %65, i64 %68, i32 %70)
  %71 = getelementptr inbounds [2 x %struct.TPE_Body], ptr %2, i64 0, i64 0
  call void @TPE_worldInit(ptr noundef %3, ptr noundef %71, i16 noundef zeroext 2, ptr noundef @environmentDistance)
  %72 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  %74 = getelementptr inbounds %struct.TPE_Body, ptr %73, i64 0
  %75 = call { i64, i32 } @TPE_vec3(i32 noundef -64, i32 noundef 170, i32 noundef 0)
  store { i64, i32 } %75, ptr %18, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 8 %18, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %17, i64 12, i1 false)
  %76 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 0
  %77 = load i64, ptr %76, align 4
  %78 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 1
  %79 = load i32, ptr %78, align 4
  call void @TPE_bodyAccelerate(ptr noundef %74, i64 %77, i32 %79)
  %80 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = getelementptr inbounds %struct.TPE_Body, ptr %81, i64 0
  %83 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef -20)
  store { i64, i32 } %83, ptr %21, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 8 %21, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %20, i64 12, i1 false)
  %84 = getelementptr inbounds { i64, i32 }, ptr %22, i32 0, i32 0
  %85 = load i64, ptr %84, align 4
  %86 = getelementptr inbounds { i64, i32 }, ptr %22, i32 0, i32 1
  %87 = load i32, ptr %86, align 4
  call void @TPE_bodySpin(ptr noundef %82, i64 %85, i32 %87)
  %88 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = getelementptr inbounds %struct.TPE_Body, ptr %89, i64 1
  %91 = call { i64, i32 } @TPE_vec3(i32 noundef -256, i32 noundef 50, i32 noundef 0)
  store { i64, i32 } %91, ptr %24, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 8 %24, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %23, i64 12, i1 false)
  %92 = getelementptr inbounds { i64, i32 }, ptr %25, i32 0, i32 0
  %93 = load i64, ptr %92, align 4
  %94 = getelementptr inbounds { i64, i32 }, ptr %25, i32 0, i32 1
  %95 = load i32, ptr %94, align 4
  call void @TPE_bodyAccelerate(ptr noundef %90, i64 %93, i32 %95)
  %96 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !15
  %98 = getelementptr inbounds %struct.TPE_Body, ptr %97, i64 1
  %99 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 22)
  store { i64, i32 } %99, ptr %27, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 8 %27, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %26, i64 12, i1 false)
  %100 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 0
  %101 = load i64, ptr %100, align 4
  %102 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 1
  %103 = load i32, ptr %102, align 4
  call void @TPE_bodySpin(ptr noundef %98, i64 %101, i32 %103)
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #5
  store i32 0, ptr %29, align 4, !tbaa !6
  br label %104

104:                                              ; preds = %200, %0
  %105 = load i32, ptr %29, align 4, !tbaa !6
  %106 = icmp sle i32 %105, 200
  br i1 %106, label %108, label %107

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

108:                                              ; preds = %104
  %109 = load i32, ptr %29, align 4, !tbaa !6
  %110 = srem i32 %109, 10
  %111 = icmp eq i32 %110, 0
  br i1 %111, label %112, label %182

112:                                              ; preds = %108
  call void @clearScreen()
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #5
  store i32 0, ptr %31, align 4, !tbaa !6
  br label %113

113:                                              ; preds = %174, %112
  %114 = load i32, ptr %31, align 4, !tbaa !6
  %115 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 1
  %116 = load i16, ptr %115, align 8, !tbaa !18
  %117 = zext i16 %116 to i32
  %118 = icmp slt i32 %114, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %113
  store i32 5, ptr %30, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #5
  br label %177

120:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #5
  store i32 0, ptr %32, align 4, !tbaa !6
  br label %121

121:                                              ; preds = %153, %120
  %122 = load i32, ptr %32, align 4, !tbaa !6
  %123 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !15
  %125 = load i32, ptr %31, align 4, !tbaa !6
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds %struct.TPE_Body, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.TPE_Body, ptr %127, i32 0, i32 1
  %129 = load i8, ptr %128, align 8, !tbaa !19
  %130 = zext i8 %129 to i32
  %131 = icmp slt i32 %122, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %121
  store i32 8, ptr %30, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #5
  br label %156

133:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 12, ptr %33) #5
  %134 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !15
  %136 = load i32, ptr %31, align 4, !tbaa !6
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds %struct.TPE_Body, ptr %135, i64 %137
  %139 = getelementptr inbounds %struct.TPE_Body, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !21
  %141 = load i32, ptr %32, align 4, !tbaa !6
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds %struct.TPE_Joint, ptr %140, i64 %142
  %144 = getelementptr inbounds %struct.TPE_Joint, ptr %143, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %33, ptr align 4 %144, i64 12, i1 false), !tbaa.struct !22
  %145 = getelementptr inbounds %struct.TPE_Vec3, ptr %33, i32 0, i32 0
  %146 = load i32, ptr %145, align 4, !tbaa !23
  %147 = mul nsw i32 %146, 32
  %148 = sdiv i32 %147, 10240
  %149 = getelementptr inbounds %struct.TPE_Vec3, ptr %33, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !25
  %151 = mul nsw i32 %150, 16
  %152 = sdiv i32 %151, 10240
  call void @setPixel(i32 noundef %148, i32 noundef %152, i8 noundef signext 46)
  call void @llvm.lifetime.end.p0(i64 12, ptr %33) #5
  br label %153

153:                                              ; preds = %133
  %154 = load i32, ptr %32, align 4, !tbaa !6
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %32, align 4, !tbaa !6
  br label %121, !llvm.loop !26

156:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 12, ptr %34) #5
  %157 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %158 = load ptr, ptr %157, align 8, !tbaa !15
  %159 = load i32, ptr %31, align 4, !tbaa !6
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %struct.TPE_Body, ptr %158, i64 %160
  %162 = call { i64, i32 } @TPE_bodyGetCenterOfMass(ptr noundef %161)
  store { i64, i32 } %162, ptr %35, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 8 %35, i64 12, i1 false)
  %163 = getelementptr inbounds %struct.TPE_Vec3, ptr %34, i32 0, i32 0
  %164 = load i32, ptr %163, align 4, !tbaa !23
  %165 = mul nsw i32 %164, 32
  %166 = sdiv i32 %165, 10240
  %167 = getelementptr inbounds %struct.TPE_Vec3, ptr %34, i32 0, i32 1
  %168 = load i32, ptr %167, align 4, !tbaa !25
  %169 = mul nsw i32 %168, 16
  %170 = sdiv i32 %169, 10240
  %171 = load i32, ptr %31, align 4, !tbaa !6
  %172 = add nsw i32 65, %171
  %173 = trunc i32 %172 to i8
  call void @setPixel(i32 noundef %166, i32 noundef %170, i8 noundef signext %173)
  call void @llvm.lifetime.end.p0(i64 12, ptr %34) #5
  br label %174

174:                                              ; preds = %156
  %175 = load i32, ptr %31, align 4, !tbaa !6
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %31, align 4, !tbaa !6
  br label %113, !llvm.loop !28

177:                                              ; preds = %119
  call void @printScreen()
  %178 = load i32, ptr %29, align 4, !tbaa !6
  %179 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %178, i32 noundef 200)
  %180 = call i32 @puts(ptr noundef @.str.1)
  %181 = call i32 @getchar()
  br label %182

182:                                              ; preds = %177, %108
  call void @TPE_worldStep(ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %36) #5
  store i32 0, ptr %36, align 4, !tbaa !6
  br label %183

183:                                              ; preds = %196, %182
  %184 = load i32, ptr %36, align 4, !tbaa !6
  %185 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 1
  %186 = load i16, ptr %185, align 8, !tbaa !18
  %187 = zext i16 %186 to i32
  %188 = icmp slt i32 %184, %187
  br i1 %188, label %190, label %189

189:                                              ; preds = %183
  store i32 11, ptr %30, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %36) #5
  br label %199

190:                                              ; preds = %183
  %191 = getelementptr inbounds %struct.TPE_World, ptr %3, i32 0, i32 0
  %192 = load ptr, ptr %191, align 8, !tbaa !15
  %193 = load i32, ptr %36, align 4, !tbaa !6
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds %struct.TPE_Body, ptr %192, i64 %194
  call void @TPE_bodyApplyGravity(ptr noundef %195, i32 noundef 5)
  br label %196

196:                                              ; preds = %190
  %197 = load i32, ptr %36, align 4, !tbaa !6
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %36, align 4, !tbaa !6
  br label %183, !llvm.loop !29

199:                                              ; preds = %189
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %29, align 4, !tbaa !6
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %29, align 4, !tbaa !6
  br label %104, !llvm.loop !30

203:                                              ; preds = %107
  store i32 0, ptr %1, align 4
  store i32 1, ptr %30, align 4
  call void @llvm.lifetime.end.p0(i64 256, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 640, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #5
  %204 = load i32, ptr %1, align 4
  ret i32 %204
}

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

declare i32 @puts(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare i32 @getchar() #4

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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 6, !10, i64 18, i64 1, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !8, i64 0}
!12 = !{!"", !8, i64 0, !8, i64 1, !13, i64 2}
!13 = !{!"short", !8, i64 0}
!14 = !{!12, !8, i64 1}
!15 = !{!16, !17, i64 0}
!16 = !{!"", !17, i64 0, !13, i64 8, !17, i64 16, !17, i64 24}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!16, !13, i64 8}
!19 = !{!20, !8, i64 8}
!20 = !{!"", !17, i64 0, !8, i64 8, !17, i64 16, !8, i64 24, !13, i64 26, !13, i64 28, !13, i64 30, !8, i64 32, !8, i64 33}
!21 = !{!20, !17, i64 0}
!22 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!23 = !{!24, !7, i64 0}
!24 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!25 = !{!24, !7, i64 4}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = distinct !{!29, !27}
!30 = distinct !{!30, !27}


; 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.TPE_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }
%struct.TPE_Vec3 = type { i32, i32, i32 }
%struct.TPE_Body = type { ptr, i8, ptr, i8, i16, i16, i16, i8, i8 }
%struct.TPE_World = type { ptr, i16, ptr, ptr }
%struct.TPE_Connection = type { i8, i8, i16 }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_joint(ptr dead_on_unwind noalias writable sret(%struct.TPE_Joint) align 4, i64, i32, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; 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 @TPE_bodyInit(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef, i8 noundef zeroext, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_worldInit(ptr noundef, ptr noundef, i16 noundef zeroext, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_bodyGetCenterOfMass(ptr noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @environmentDistance(i64, i32, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @clearScreen() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @setPixel(i32 noundef, i32 noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @printScreen() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [2 x %struct.TPE_Body], align 16
  %2 = alloca %struct.TPE_World, align 8
  %3 = alloca [32 x %struct.TPE_Joint], align 16
  %4 = alloca [64 x %struct.TPE_Connection], align 16
  %5 = alloca %struct.TPE_Joint, align 4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 640, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %4) #5
  %6 = tail call { i64, i32 } @TPE_vec3(i32 noundef 7680, i32 noundef 5120, i32 noundef 0)
  %.fca.0.extract69 = extractvalue { i64, i32 } %6, 0
  %.fca.1.extract70 = extractvalue { i64, i32 } %6, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %3, i64 %.fca.0.extract69, i32 %.fca.1.extract70, i32 noundef 512)
  %7 = getelementptr inbounds i8, ptr %3, i64 20
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #5
  %8 = call { i64, i32 } @TPE_vec3(i32 noundef 9728, i32 noundef 5120, i32 noundef 0)
  %.fca.0.extract61 = extractvalue { i64, i32 } %8, 0
  %.fca.1.extract62 = extractvalue { i64, i32 } %8, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %5, i64 %.fca.0.extract61, i32 %.fca.1.extract62, i32 noundef 512)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %7, ptr noundef nonnull align 4 dereferenceable(20) %5, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #5
  store i8 0, ptr %4, align 16, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 1, ptr %9, align 1, !tbaa !14
  call void @TPE_bodyInit(ptr noundef nonnull %1, ptr noundef nonnull %3, i8 noundef zeroext 2, ptr noundef nonnull %4, i8 noundef zeroext 1, i32 noundef 512)
  %10 = getelementptr inbounds i8, ptr %3, i64 40
  %11 = getelementptr inbounds i8, ptr %4, i64 4
  call void @TPE_makeBox(ptr noundef nonnull %10, ptr noundef nonnull %11, i32 noundef 1024, i32 noundef 1024, i32 noundef 1024, i32 noundef 512)
  %12 = getelementptr inbounds i8, ptr %1, i64 40
  call void @TPE_bodyInit(ptr noundef nonnull %12, ptr noundef nonnull %10, i8 noundef zeroext 8, ptr noundef nonnull %11, i8 noundef zeroext 16, i32 noundef 512)
  %13 = call { i64, i32 } @TPE_vec3(i32 noundef 5120, i32 noundef 5120, i32 noundef 0)
  %.fca.0.extract53 = extractvalue { i64, i32 } %13, 0
  %.fca.1.extract54 = extractvalue { i64, i32 } %13, 1
  call void @TPE_bodyMoveTo(ptr noundef nonnull %12, i64 %.fca.0.extract53, i32 %.fca.1.extract54)
  call void @TPE_worldInit(ptr noundef nonnull %2, ptr noundef nonnull %1, i16 noundef zeroext 2, ptr noundef nonnull @environmentDistance)
  %14 = load ptr, ptr %2, align 8, !tbaa !15
  %15 = call { i64, i32 } @TPE_vec3(i32 noundef -64, i32 noundef 170, i32 noundef 0)
  %.fca.0.extract45 = extractvalue { i64, i32 } %15, 0
  %.fca.1.extract46 = extractvalue { i64, i32 } %15, 1
  call void @TPE_bodyAccelerate(ptr noundef %14, i64 %.fca.0.extract45, i32 %.fca.1.extract46)
  %16 = load ptr, ptr %2, align 8, !tbaa !15
  %17 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef -20)
  %.fca.0.extract37 = extractvalue { i64, i32 } %17, 0
  %.fca.1.extract38 = extractvalue { i64, i32 } %17, 1
  call void @TPE_bodySpin(ptr noundef %16, i64 %.fca.0.extract37, i32 %.fca.1.extract38)
  %18 = load ptr, ptr %2, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %18, i64 40
  %20 = call { i64, i32 } @TPE_vec3(i32 noundef -256, i32 noundef 50, i32 noundef 0)
  %.fca.0.extract29 = extractvalue { i64, i32 } %20, 0
  %.fca.1.extract30 = extractvalue { i64, i32 } %20, 1
  call void @TPE_bodyAccelerate(ptr noundef nonnull %19, i64 %.fca.0.extract29, i32 %.fca.1.extract30)
  %21 = load ptr, ptr %2, align 8, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %21, i64 40
  %23 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 22)
  %.fca.0.extract21 = extractvalue { i64, i32 } %23, 0
  %.fca.1.extract22 = extractvalue { i64, i32 } %23, 1
  call void @TPE_bodySpin(ptr noundef nonnull %22, i64 %.fca.0.extract21, i32 %.fca.1.extract22)
  %24 = getelementptr inbounds i8, ptr %2, i64 8
  br label %26

25:                                               ; preds = %._crit_edge85
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 640, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #5
  ret i32 0

26:                                               ; preds = %0, %._crit_edge85
  %.07686 = phi i32 [ 0, %0 ], [ %60, %._crit_edge85 ]
  %.lhs.trunc = trunc nuw i32 %.07686 to i8
  %27 = urem i8 %.lhs.trunc, 10
  %28 = icmp eq i8 %27, 0
  br i1 %28, label %29, label %58

29:                                               ; preds = %26
  call void @clearScreen()
  %30 = load i16, ptr %24, align 8, !tbaa !18
  %.not = icmp eq i16 %30, 0
  br i1 %.not, label %._crit_edge81, label %.preheader

.preheader:                                       ; preds = %29, %._crit_edge
  %indvars.iv91 = phi i64 [ %indvars.iv.next92, %._crit_edge ], [ 0, %29 ]
  %31 = load ptr, ptr %2, align 8, !tbaa !15
  %32 = getelementptr inbounds %struct.TPE_Body, ptr %31, i64 %indvars.iv91
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = load i8, ptr %33, align 8, !tbaa !19
  %.not87 = icmp eq i8 %34, 0
  br i1 %.not87, label %._crit_edge, label %.lr.ph

._crit_edge81:                                    ; preds = %._crit_edge, %29
  call void @printScreen()
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.07686, i32 noundef 200)
  %36 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %37 = call i32 @getchar()
  br label %58

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.lcssa = phi ptr [ %32, %.preheader ], [ %53, %.lr.ph ]
  %38 = call { i64, i32 } @TPE_bodyGetCenterOfMass(ptr noundef nonnull %.lcssa)
  %.fca.0.extract = extractvalue { i64, i32 } %38, 0
  %.sroa.03.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  %39 = sdiv i32 %.sroa.03.0.extract.trunc, 320
  %sh.diff = lshr i64 %.fca.0.extract, 28
  %tr.sh.diff = trunc i64 %sh.diff to i32
  %40 = and i32 %tr.sh.diff, -16
  %41 = sdiv i32 %40, 10240
  %42 = trunc i64 %indvars.iv91 to i8
  %43 = add i8 %42, 65
  call void @setPixel(i32 noundef %39, i32 noundef %41, i8 noundef signext %43)
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %44 = load i16, ptr %24, align 8, !tbaa !18
  %45 = zext i16 %44 to i64
  %46 = icmp ult i64 %indvars.iv.next92, %45
  br i1 %46, label %.preheader, label %._crit_edge81, !llvm.loop !21

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %47 = phi ptr [ %53, %.lr.ph ], [ %32, %.preheader ]
  %48 = load ptr, ptr %47, align 8, !tbaa !23
  %49 = getelementptr inbounds %struct.TPE_Joint, ptr %48, i64 %indvars.iv
  %.sroa.04.0.copyload = load i32, ptr %49, align 4, !tbaa !6
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %49, i64 4
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !6
  %50 = sdiv i32 %.sroa.04.0.copyload, 320
  %51 = sdiv i32 %.sroa.4.0.copyload, 640
  call void @setPixel(i32 noundef %50, i32 noundef %51, i8 noundef signext 46)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %52 = load ptr, ptr %2, align 8, !tbaa !15
  %53 = getelementptr inbounds %struct.TPE_Body, ptr %52, i64 %indvars.iv91
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = load i8, ptr %54, align 8, !tbaa !19
  %56 = zext i8 %55 to i64
  %57 = icmp ult i64 %indvars.iv.next, %56
  br i1 %57, label %.lr.ph, label %._crit_edge, !llvm.loop !24

58:                                               ; preds = %._crit_edge81, %26
  call void @TPE_worldStep(ptr noundef nonnull %2)
  %59 = load i16, ptr %24, align 8, !tbaa !18
  %.not88 = icmp eq i16 %59, 0
  br i1 %.not88, label %._crit_edge85, label %.lr.ph84

._crit_edge85:                                    ; preds = %.lr.ph84, %58
  %60 = add nuw nsw i32 %.07686, 1
  %exitcond.not = icmp eq i32 %60, 201
  br i1 %exitcond.not, label %25, label %26, !llvm.loop !25

.lr.ph84:                                         ; preds = %58, %.lr.ph84
  %indvars.iv94 = phi i64 [ %indvars.iv.next95, %.lr.ph84 ], [ 0, %58 ]
  %61 = load ptr, ptr %2, align 8, !tbaa !15
  %62 = getelementptr inbounds %struct.TPE_Body, ptr %61, i64 %indvars.iv94
  call void @TPE_bodyApplyGravity(ptr noundef %62, i32 noundef 5)
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %63 = load i16, ptr %24, align 8, !tbaa !18
  %64 = zext i16 %63 to i64
  %65 = icmp ult i64 %indvars.iv.next95, %64
  br i1 %65, label %.lr.ph84, label %._crit_edge85, !llvm.loop !26
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #4

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

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 6, !10, i64 18, i64 1, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !8, i64 0}
!12 = !{!"", !8, i64 0, !8, i64 1, !13, i64 2}
!13 = !{!"short", !8, i64 0}
!14 = !{!12, !8, i64 1}
!15 = !{!16, !17, i64 0}
!16 = !{!"", !17, i64 0, !13, i64 8, !17, i64 16, !17, i64 24}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!16, !13, i64 8}
!19 = !{!20, !8, i64 8}
!20 = !{!"", !17, i64 0, !8, i64 8, !17, i64 16, !8, i64 24, !13, i64 26, !13, i64 28, !13, i64 30, !8, i64 32, !8, i64 33}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!20, !17, i64 0}
!24 = distinct !{!24, !22}
!25 = distinct !{!25, !22}
!26 = distinct !{!26, !22}


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