Help me to convert in delphi

hi guys pls help me

Help me to convert in delphi

#include <stdio.h> 
#include <stdlib.h> 
#include <memory.h> 

unsigned int    rng_vec[607]; 
unsigned int *    rng_tap = rng_vec; 
unsigned int *    rng_feed = 0; 


// 123456005883380 - 65863543 
// 21 43 65 00 85 38 83 f0 

  int v3; // r5@1 
  unsigned int v4; // r0@1 
  int v5; // r4@1 
  unsigned int v6; // r1@2 
  char *v7; // r2@2 
  unsigned int v8; // r0@3 
  int v9; // r4@3 
  unsigned int v10; // r1@4 
  signed int v11; // r0@5 
  signed int v12; // r0@5 
  int cnt; // r0@5 
  int v14; // r1@6 
  char v16[8]; // [sp+0h] [bp-20h]@1 
  char v17[8]; // [sp+8h] [bp-18h]@1 


  char Table_00[10] =       {    0,   6,   1,   8,   7,   5,   3,   2,    
9,   4}; 
  char Table_01[10] =       {    0,   2,   6,   6,   9,   5,   1,   4,    
3,   8}; 
  char Table_10[10] =       {    0,   4,   9,   2,   3,   5,   7,   8,    
1,   6}; 
  char Table_11[10] =       {    0,   8,   3,   4,   1,   5,   9,   6,    
7,   2}; 

  char Table_2[100] = {          
                  0x11, 0x5D, 0x5B, 0x5A, 0x58, 0x57, 5, 7, 9, 0x12, 
                  1, 0x45, 0x51, 0x50, 0x4E, 0x18, 0x16, 0x13, 0x1F, 
                  0x64, 2, 0x1E, 0x3C, 0x24, 0x23, 0x3F, 0x43, 0x2A, 
                  0x47, 0x63, 0xC, 0x1D, 0x44, 0x32, 0x35, 0x38, 0x2B, 
                  0x21, 0x48, 0x59, 0xF, 0x1C, 0x27, 0x37, 0x2C, 0x31, 
                  0x36, 0x3E, 0x49, 0x56, 0x55, 0x1B, 0x28, 0x2D, 0x3A, 
                  0x33, 0x30, 0x3D, 0x4A, 0x10, 0x5F, 0x4B, 0x25, 0x34, 
                  0x2F, 0x2E, 0x39, 0x40, 0x1A, 6, 0x61, 0x4C, 0x3B, 
                  0x41, 0x42, 0x26, 0x22, 0x29, 0x19, 4, 0x62, 0x46, 
                  0x14, 0x15, 0x17, 0x4D, 0x4F, 0x52, 0x20, 3, 0x53, 
                  8, 0xA, 0xB, 0xD, 0xE, 0x60, 0x5E, 0x5C, 0x54}; 

 char coda[8]; 
  
unsigned int isrand(unsigned int _seed) 
{ 
  unsigned int result; // r0@1 
  unsigned int seed; // r1@1 
  signed int i; // r4@3 

  rng_tap = rng_vec; 
  rng_feed = rng_vec+607-273; 
  seed = _seed % 0x7FFFFFFF; 
  result = _seed / 0x7FFFFFFF; 
  if ( !seed ) 
    seed = 89482311; 
  for ( i = -20; i < 607; i = (i + 1) ) 
  { 
    result = 3399 * (seed / 44488); 
    seed = 48271 * (seed % 44488) - 3399 * (seed / 44488); 
    if ( i >= 0 ) 
    { 
      result = 4 * i; 
      rng_vec* = seed; 
    } 
  } 
  return result; 
} 


unsigned int lrand() 
{ 
  int v0; // r0@5 
  unsigned int result; // r0@7 

  --rng_tap; 
  if ( rng_tap < rng_vec ) 
  { 
    if ( !rng_feed ) 
    { 
      isrand(1u); 
      --rng_tap; 
    } 
    rng_tap += 607; 
  } 
  //v0 = rng_feed - 4; 
  rng_feed--; // = v0; 
  if ( rng_feed < rng_vec ) 
     rng_feed +=607; //rng_feed +=2428; 
  result = (2 * (*rng_feed + *rng_tap)) >> 1; 
  *rng_feed = result; 
  return result; 
} 


int main(int argc, char* argv]) 
{ 
  int v15; 
  unsigned int imei=atoi(argv [1]); 
   
  
  // printf("%i",imei);   
//IMEI =   TAC + FAC +   SNR + LUHN 
//       XXXXXX + YY + ZZZZZZ + L 
 //v4 = SNR + MAGIC 


//SNR = XXXXXXX-YY-429081-L 
//MAGIC = 313944551; 

  //v4 = 441525 + 313944551; 
  v4 = imei + 313944551; 
  v5 = 0; 
  do 
  { 
    v6 = v4 % 0xA; 
    v4 /= 0xAu; 
    v15 = 5 - v5++; 
    v17[v15] = v6; 
  } 
  while ( v5 < 6 ); 
  v8 = (13 * v17[5] + 5 * v17[4] + 3 * v17[3] + 1553 * v17[2] + 23 *  
v17[1] + 177 * v17[0]) % 99999; 
  v9 = 7; 
  do 
  { 
    v10 = v8 % 0xA; 
    v8 /= 0xAu; 
    v17[v9] = v10; 
    v9 = (v9 + 255) & 0xFF; 
  } 
  while ( v9 > 5 ); 
  v16[0] = Table_00[v17[0]]; 
  v16[1] = Table_01[v17[1]]; 
  v16[2] = Table_10[v17[2]]; 
  v16[3] = Table_11[v17[6]]; 
  v11 = Table_2(10 * v17[3]) + v17[4]] - 1; 
  v16[4] = v11 / 10; 
  v16[5] = v11 % 10; 
  v12 = Table_2[99 - ((10 * v17[7]) + v17[5])] - 1; 
  v16[6] = v12 / 10; 
  v16[7] = v12 % 10; 
  cnt = 0; 
  v3 = 0; 
  do 
  { 
   v14 = (v16[cnt] << 4 * cnt) | v3; 
    cnt = (cnt + 1) & 0xFF; 
    v3 = v14; 
  } 
  while ( cnt < 8 ); 
  v14 = 0; 
  isrand(v3); 
  do 
    coda[v14++] = lrand() % 0xA + 48; 
  while ( v14 < 8 ); 

  
     printf("%s",coda);   

    return 0; 
}  

Welcome,

Despite its name, this forum primarily deals with the FIRST Robotics Competition, rather than delphi programming. You probably won’t have much luck getting help with delphi here.

Can’t tell if spam or not…could just be one of the bots that’ll add the links to it’s signature later…

This guy actually seems legit, it’s understandable that a person from the Philippines would have poor English (no offense), and wouldn’t know what Chief Delphi is actually for.

Well, unless he’s on team 3105, in which case he doesn’t have much excuse. Probably not though.

C 2 Delphi Converter 1.0 at tucows.com, is what I got with Google. (Googling “dephi” doesn’t pick up this website at all.) That’s probably all the help we can give you. We also don’t give answers to homework problems. In that light, jeidee, can you tell us what this code is doing and how you came on it? It might give us a clue how to help you. I do find the “MAGIC” variable interesting (though commented out).

If you google “delphi forum” or “delphi forums” we are ranked highly in the first page of results.

delphi
delphi programming
delphi programming help
delphi translate
c to delphi translate

is what I would search for to translate a C program to Delphi.

Or some good Delphi and C books (or on-line equivalent) and a piece of paper to figure out the code.

If I found a Delphi forum in a search, I would in all honesty read the linked thread, then search thru the forum to see if there is a similar question or at least find out if the forum is where I want to take the time to register to ask the question.

Finding a “Delphi” forum that has under it’s technical forums lists Motors, Electrical, Control System, and Pneumatics on either side of the Programming forum (not to mention a programming forum that has questions about robots, IP addresses, image processing, Arduinos, as well as a sticky title “If you come here asking for Delphi programming…” that I would read first before registering) would give me pause that maybe, just maybe, this place isn’t about the programming language Delphi.

But I was polite and did ask jeidee for more information about his/her question. I am curious what the code is intended to perform. I have my suspicions.

This thread has run through it’s usefulness. Closing.

why my thread is close?

this is the link

http://www.chiefdelphi.com/forums/showthread.php?t=118194&highlight=convert

no one can answer my question

sorry if i have bad words or anything that the rules i break?

This forum does not have anything to do with the Delphi programming language; this forum is dedicated to discussing the FIRST Robotics Competition.

So it is highly unlikely that anyone here will be able to help you with Delphi programming language questions. No rules were broken on your behalf, we just can’t help you answer your questions.

Please refer to the sticky thread here: