signed int __fastcall Camera::handleFreeCam(Camera *this)
{
  // [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]

  v2 = &this->field_74;
  v3 = &this->pos1;
  v4 = &this->pos2;
  v5 = this->gctx;
  v6 = Camera::getCameraHeight(this);
  sub_1BF070((int *)&result._.position.z, v3, v2, v7);
  v38 = *(_QWORD *)&result._.position.z;
  v8 = 0x38E3;
  if ( result._.angle > 0x38E3 || (v8 = 0xC71Du, result._.angle < (signed int)0xFFFFC71D) )
    WORD2(v38) = v8;
  v9 = v38;
  if ( (signed int)v38 <= 0x43960000 )
  {
    if ( (signed int)v38 <= 0x43020000 )
      v9 = 0x43020000;
    LODWORD(v38) = v9;
  }
  else
  {
    LODWORD(v38) = 0x43960000;
  }
  if ( !this->x.field_72 )
  {
    v10 = (__int16 *)sCameraStates[this->x.state].modes[this->x.mode].field_4;
    this->field_0 = *v10;
    this->field_2 = v10[2];
    this->field_4 = (float)v10[4] * 0.01;
    this->field_8 = 0;
    this->field_C = 0.0;
    this->field_10 = 0.2;
    this->field_16 = 0;
    this->field_14 = 0;
    this->x.field_72 = 1;
  }
  v11 = (char *)&unk_6226E0 + 2 * (unsigned __int8)s_common_data.scene_info.field_15;
  v12 = (signed int)v5->pad_state.c_stick.x_raw_last * *v11;
  v13 = (signed int)v5->pad_state.c_stick.y_raw_last * v11[1];
  v14 = sub_191198((signed __int16)(this->field_0 * v12), this->field_14, 1);
  this->field_14 = v14;
  HIWORD(v38) += v14;
  v15 = sub_191198((signed __int16)(this->field_2 * v13), this->field_16, 1);
  this->field_16 = v15;
  v16 = (signed __int16)(v15 + WORD2(v38));
  WORD2(v38) = v16;
  v17 = (this->x.field_170 & 8) == 0;
  if ( this->x.field_170 & 8 )
    v17 = this->actor2 == 0;
  if ( v17 )
  {
    v25 = (player_actor *)this->targetActor;
    v26 = &v25->_s1;
    v27 = v25->_s1.flags;
    if ( v27 & 0x202000 )
    {
      v28 = 14563.0;
      v29 = -10922.0;
      if ( v27 & 0x2000 && !(this->field_8 & 0x2000) )
        this->field_C = v25->_.position.y + 20.0;
    }
    else
    {
      v28 = 6371.0;
      v29 = -5461.0;
    }
    if ( (float)SWORD2(v38) <= v28 )
    {
      if ( v29 < (float)SWORD2(v38) )
        v29 = (float)SWORD2(v38);
      v30 = (signed int)v29;
      WORD2(v38) = v30;
    }
    else
    {
      v30 = (signed int)v28;
      WORD2(v38) = (signed int)v28;
    }
    this->field_8 = v25->_s1.flags;
    sub_2294A8(WORD2(v38));
    v31 = (float)(*(float *)&v30 * 170.0) + 130.0;
    if ( v31 < v6 )
      v31 = v6;
    LODWORD(v38) = sub_5183A8(v31, this->field_F0, 0.8, 0.0);
    if ( v26->flags & 0x2000 )
      Camera::x_5(this, (int)&v38, &this->field_C, 1);
    else
      Camera::x_10(this, (int)&v38, 0);
  }
  else
  {
    v18 = 0x18E3;
    if ( SWORD2(v38) > 0x18E3 || (v18 = 0xEAABu, v16 < (signed int)0xFFFFEAAB) )
      WORD2(v38) = v18;
    CameraActorInfo::fromActor(&result, &this->actor2->_);
    this->actor2Info = result;
    this->actor2Info.field_12 = result.field_12;
    v19 = this->targetActorPos.x;
    v20 = (float)(this->actor2Info._.position.x - v19) * 0.5;
    v21 = (float)(this->actor2Info._.position.z - this->targetActorPos.z) * 0.5;
    v22 = (float)(this->actor2Info._.position.y - this->targetActorPos.y) * 0.5;
    v44 = v19 + v20;
    v45 = this->targetActorPos.y + v22;
    v46 = this->targetActorPos.z + v21;
    v23 = this->x.field_114;
    sub_26ED40(&v44, v3);
    sub_2294A8(WORD2(v38));
    v24 = (float)(sqrtf((float)((float)(v20 * v20) + (float)(v22 * v22)) + (float)(v21 * v21)) + 160.0)
        + (float)(160.0 * 170.0);
    if ( SLODWORD(v24) < 0x43020000 )
      v24 = 130.0;
    LODWORD(v38) = sub_5183A8(v24, this->field_F0, 0.8, 0.0);
  }
  sub_1B049C(&a1, v3, (int)&v38);
  *v2 = a1;
  v39 = v2->x;
  v40 = v2->y;
  v41 = v2->z;
  v32 = sub_2BE010(this, v3, &v39, 0);
  v33 = this->field_10 * 0.5;
  if ( v32 )
    v34 = (int *)&v39;
  else
    v34 = (int *)v2;
  sub_26ED40(v34, v4);
  this->field_10 = this->field_10 + (float)((float)(0.5 - this->field_10) * 0.2);
  LODWORD(this->field_F0) = v38;
  this->field_D4 = 0.8;
  this->x.field_16E = sub_191198(0, this->x.field_16E, 5);
  v35 = this->x.field_114;
  v36 = this->field_4;
  if ( SLODWORD(this->x.field_114) >= 0x3DF5C28F )
  {
    if ( v36 > v35 )
      v36 = v35 * 1.1;
  }
  else
  {
    v36 = 0.12;
  }
  this->x.field_114 = v36;
  dword_667854 = 0;
  return 1;
}