70,021
社区成员




00401409 <_phase_6>:
401409: 55 push %ebp
40140a: 89 e5 mov %esp,%ebp
40140c: 83 ec 08 sub $0x8,%esp
40140f: 8b 45 08 mov 0x8(%ebp),%eax
401412: 89 04 24 mov %eax,(%esp)
401415: e8 56 08 00 00 call 401c70 <_atoi>
40141a: a3 ac 34 40 00 mov %eax,0x4034ac
40141f: c7 04 24 ac 34 40 00 movl $0x4034ac,(%esp)
401426: e8 8e ff ff ff call 4013b9 <_fun6>
40142b: ba 01 00 00 00 mov $0x1,%edx
401430: 8b 40 08 mov 0x8(%eax),%eax
401433: 42 inc %edx
401434: 83 fa 05 cmp $0x5,%edx
401437: 7e f7 jle 401430 <_phase_6+0x27>
401439: 8b 00 mov (%eax),%eax
40143b: 3b 05 ac 34 40 00 cmp 0x4034ac,%eax
401441: 74 05 je 401448 <_phase_6+0x3f>
401443: e8 8a 06 00 00 call 401ad2 <_explode_bomb>
401448: c9 leave
401449: c3 ret
翻译过来滴结构貌似应该这样:
typedef struct LIST_T
{
int a;
int b;
struct LIST_T* next;
}List;
004013b9 <_fun6>:
4013b9: 55 push %ebp
4013ba: 89 e5 mov %esp,%ebp
4013bc: 56 push %esi
4013bd: 53 push %ebx
4013be: 8b 75 08 mov 0x8(%ebp),%esi //parameter liste head listeSi
4013c1: 8b 5e 08 mov 0x8(%esi),%ebx //(listeSi.a is input value) List* listeBx = listeSi.next
4013c4: c7 46 08 00 00 00 00 movl $0x0,0x8(%esi) //listeSi.next = null
4013cb: 85 db test %ebx,%ebx //if( NULL == listeBx ) goto finish
4013cd: 74 34 je 401403 <_fun6+0x4a>
4013cf: 89 f2 mov %esi,%edx //List* listeDx = listeSi; (l5)
4013d1: 89 f1 mov %esi,%ecx //List* listeCx = ListeSi;
4013d3: 85 f6 test %esi,%esi //if( NULL == listeSi ) goto l1
4013d5: 74 15 je 4013ec <_fun6+0x33>
4013d7: 8b 06 mov (%esi),%eax //listeSi.a
4013d9: 3b 03 cmp (%ebx),%eax //if(listeSi.a <= listeBx.a ) goto l1
4013db: 7e 0f jle 4013ec <_fun6+0x33>
4013dd: 89 d1 mov %edx,%ecx //listeCx = listeDx; (l2)
4013df: 8b 52 08 mov 0x8(%edx),%edx //listeDx = listeDx.next
4013e2: 85 d2 test %edx,%edx //if(NULL == listeDx) goto l1
4013e4: 74 06 je 4013ec <_fun6+0x33>
4013e6: 8b 02 mov (%edx),%eax //if( listeDx.a > listeBx.a ) goto l2
4013e8: 3b 03 cmp (%ebx),%eax
4013ea: 7f f1 jg 4013dd <_fun6+0x24>
4013ec: 39 d1 cmp %edx,%ecx //if (listeCx > listeDx) goto l3 (l1)
4013ee: 74 05 je 4013f5 <_fun6+0x3c>
4013f0: 89 59 08 mov %ebx,0x8(%ecx) //listeCx.next = listeBx;
4013f3: eb 02 jmp 4013f7 <_fun6+0x3e> //goto l4
4013f5: 89 de mov %ebx,%esi //listeSi = listeBx; (l3)
4013f7: 8b 4b 08 mov 0x8(%ebx),%ecx //listeCx = listeBx.next; (l4)
4013fa: 89 53 08 mov %edx,0x8(%ebx) //listeBx.next = listeDx;
4013fd: 89 cb mov %ecx,%ebx //listeBx = listeCx;
4013ff: 85 c9 test %ecx,%ecx //if(NULL != listeCx) goto l5
401401: 75 cc jne 4013cf <_fun6+0x16>
401403: 89 f0 mov %esi,%eax //(finish)
401405: 5b pop %ebx
401406: 5e pop %esi
401407: 5d pop %ebp
401408: c3 ret
#include <stdio.h>
typedef struct Unknown_t
{
int value; //+0
int b; //+4
struct Unknown_t *next; //+8
}Unknown_t;
Unknown_t *fun6(Unknown_t *p )
{
Unknown_t *sorted_list,*before,*after,*left_list;
//In the beginning, only one element in sorted list and all others in left_list
sorted_list=p;
left_list=p->next;
p->next=NULL;
while(left_list!=NULL){
before=after=sorted_list;
//Try to find insert position of head element of 'left_list' in list 'sorted_list'
//It is insert between 'before' and 'after' after the loop
while(after!=NULL&&sorted_list->value > after->value){
before=after;
after=after->next;
}
if(before!=after){//Find, not insert before header of 'sorted_list'
before->next = left_list; //Insert head of 'left_list' into 'sorted_list' between 'before' and 'after'
}else{//Not find, head of 'left_list' is smaller than all element in list 'sorted_list'
sorted_list=left_list;//
}
before=left_list->next;
//Move head from 'left_list'
left_list->next=after;
left_list=before;
}
return sorted_list;
}
4013ec: 39 d1 cmp %edx,%ecx //if (listeCx > listeDx) goto l3 (l1)
4013ee: 74 05 je 4013f5 <_fun6+0x3c>
401403: 89 f0 mov %esi,%eax //(finish)
004013b9 <_fun6>:
4013b9: 55 push %ebp
4013ba: 89 e5 mov %esp,%ebp
4013bc: 56 push %esi
4013bd: 53 push %ebx
4013be: 8b 75 08 mov 0x8(%ebp),%esi ; [ebp+8] -> esi
4013c1: 8b 5e 08 mov 0x8(%esi),%ebx ; [esi+8] -> ebx
4013c4: c7 46 08 00 00 00 00 movl $0x0,0x8(%esi) ; 0 -> [esi+8]
4013cb: 85 db test %ebx,%ebx ; if( ebx == 0 )
4013cd: 74 34 je 401403 <_fun6+0x4a>; goto 401403
4013cf: 89 f2 mov %esi,%edx ; esi -> edx
4013d1: 89 f1 mov %esi,%ecx ; esi -> ecx
4013d3: 85 f6 test %esi,%esi ; if( esi == 0 )
4013d5: 74 15 je 4013ec <_fun6+0x33>; goto 4013ec
4013d7: 8b 06 mov (%esi),%eax ; [esi]->eax
4013d9: 3b 03 cmp (%ebx),%eax ; if( [ebx]<=eax )
4013db: 7e 0f jle 4013ec <_fun6+0x33> ; goto 4013ec
4013dd: 89 d1 mov %edx,%ecx ; edx->ecx
4013df: 8b 52 08 mov 0x8(%edx),%edx ; [edx+8]->edx
4013e2: 85 d2 test %edx,%edx ; if( edx==0 )
4013e4: 74 06 je 4013ec <_fun6+0x33> ; goto 4013ec
4013e6: 8b 02 mov (%edx),%eax ; [edx]->eax
4013e8: 3b 03 cmp (%ebx),%eax ; if( [ebx]>eax )
4013ea: 7f f1 jg 4013dd <_fun6+0x24> ; goto 4013dd
4013ec: 39 d1 cmp %edx,%ecx ; if( edx==ecx )
4013ee: 74 05 je 4013f5 <_fun6+0x3c> ; goto 4013f5
4013f0: 89 59 08 mov %ebx,0x8(%ecx) ; ebx->[ecx+8]
4013f3: eb 02 jmp 4013f7 <_fun6+0x3e> ; goto 4013f7
4013f5: 89 de mov %ebx,%esi ; ebx->esi
4013f7: 8b 4b 08 mov 0x8(%ebx),%ecx ; [ebx+8]->ecx
4013fa: 89 53 08 mov %edx,0x8(%ebx) ; edx->[ebx+8]
4013fd: 89 cb mov %ecx,%ebx ; ecx->ebx
4013ff: 85 c9 test %ecx,%ecx ; if( ecx!=0)
401401: 75 cc jne 4013cf <_fun6+0x16> ; goto 4013cf
401403: 89 f0 mov %esi,%eax ; esi->eax
401405: 5b pop %ebx
401406: 5e pop %esi
401407: 5d pop %ebp
401408: c3 ret
#include <stdio.h>
typedef struct Unknown_t
{
int a; //+0
int b; //+4
struct Unknown_t *next; //+8
}Unknown_t;
Unknown_t *fun6(Unknown_t *p )
{
Unknown_t *p1,*p2,*p3,*next;
p1=p;
next=p->next;
p1->next=NULL;
if( next==NULL )
{
return p1;
}
ADDR4013cf:
p2=p1;
p3=p1;
if( p1==NULL )
{
goto ADDR4013ec;
}else if( next->a<=p1->a )
{
goto ADDR4013ec;
}else
{
ADDR4013dd:
p3=p2;
p2=p2->next;
if( p2==NULL )
{
goto ADDR4013ec;
}else if( next->a > p2->a )
{
goto ADDR4013dd;
}
goto ADDR4013ec;
}
ADDR4013ec:
if( p2==p3 )
{
goto ADDR4013f5;
}
p3->next=next;
goto ADDR4013f7;
ADDR4013f5:
p1=next;
ADDR4013f7:
p3=next->next;
next->next=p2;
next=p3;
if( p3!=0 )
{
goto ADDR4013cf;
}else
{
return p1;
}
}