C++ Programming/Exercises/Functions

char *__fastcall AnoSDKIoctl_0(int a1, int a2) {

 char *v3; // r4
 char *v4; // r0
 char *v5; // r6
 int v6; // r4
 int v7; // r0
 int v8; // r6
 char *v9; // r0
 char *v10; // r5
 int v11; // r0
 char *v12; // r0
 int v13; // r0
 void *v14; // r0
 char v16[1024]; // [sp+8h] [bp-450h] BYREF
 int v17[20]; // [sp+408h] [bp-50h] BYREF
 v3 = 0;
 switch ( a1 )
 {
   case 45:
     v8 = ((int (__fastcall *)(int, int, _DWORD, _DWORD, _DWORD))AnoSDKIoctlOld_0)(45, a2, 0, 0, 0);
     memset(v16, 0, 16);
     v9 = (char *)malloc(6u);
     if ( !v9 )
       return v3;
     v10 = v9;
     sub_1099E4(v16, 16, "%d", v8);
     v11 = sub_10915E(v16);
     *(_DWORD *)(v10 + 2) = v11;
     if ( v11 )
     {
       v3 = v10;
       *(_WORD *)v10 = sub_1090B2(v16) + 1;
       return v3;
     }
     v14 = v10;
     goto LABEL_19;
   case 18:
     memset(v16, 0, sizeof(v16));
     v17[0] = 0;
     if ( ((int (__fastcall *)(int, int, char *, int, int *))AnoSDKIoctlOld_0)(18, a2, v16, 1024, v17) )
       return 0;
     v12 = (char *)malloc(6u);
     if ( !v12 )
       return 0;
     v3 = v12;
     v13 = sub_10915E(v16);
     *(_DWORD *)(v3 + 2) = v13;
     if ( v13 )
     {
       *(_WORD *)v3 = sub_1090B2(v16) + 1;
       return v3;
     }
     v14 = v3;

LABEL_19:

     free(v14);
     return 0;
   case 10:
     memset(v17, 0, 64);
     memset(v16, 0, 0xFFu);
     v4 = (char *)malloc(6u);
     v3 = 0;
     if ( v4 )
     {
       v5 = v4;
       *((_WORD *)v4 + 2) = 0;
       *(_DWORD *)v4 = 0;
       v6 = ((int (__fastcall *)(int, int, int *, int, _DWORD))AnoSDKIoctlOld_0)(10, a2, v17, 64, 0);
       sub_1099E4(v16, 255, "retval=%d", v6);
       if ( v6 == 1 )
       {
         sub_109140(v16, "|emulator_name=");
         sub_109140(v16, v17);
       }
       v7 = sub_10915E(v16);
       *(_DWORD *)(v5 + 2) = v7;
       if ( v7 )
       {
         *(_WORD *)v5 = sub_1090B2(v16) + 1;
         return v5;
       }
       v14 = v5;
       goto LABEL_19;
     }
     break;
 }
 return v3;

}