All pastes #797517 Raw Edit

Stuff

public text v1 · immutable
#797517 ·published 2007-11-26 01:45 UTC
rendered paste body
        .file   "httpd.c"
        .section        .rodata
.LC0:
        .string "Usage: %s <port>\n"
.LC1:
        .string "!!! Could not create socket.\n"
        .align 4
.LC2:
        .string "!!! Could not bind to port %d.\n"
        .align 4
.LC3:
        .string "HTTP/1.1 200 OK\r\nContent-Length: 131063\r\nConnection: close\r\nContent-Type: image/jpeg\r\n\r\n"
.LC4:
        .string "image.jpg"
        .text
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $4168, %esp
        andl    $-16, %esp
        movl    $0, %eax
        addl    $15, %eax
        addl    $15, %eax
        shrl    $4, %eax
        sall    $4, %eax
        subl    %eax, %esp
        subl    $8, %esp
        movl    12(%ebp), %eax
        pushl   (%eax)
        pushl   $.LC0
        call    printf
        addl    $16, %esp
        movl    $80, -12(%ebp)
        cmpl    $1, 8(%ebp)
        jle     .L2
        movl    12(%ebp), %eax
        addl    $4, %eax
        subl    $12, %esp
        pushl   (%eax)
        call    atoi
        addl    $16, %esp
        movl    %eax, -12(%ebp)
.L2:
        subl    $4, %esp
        pushl   $0
        pushl   $1
        pushl   $2
        call    socket
        addl    $16, %esp
        movl    %eax, -16(%ebp)
        cmpl    $0, -16(%ebp)
        jns     .L3
        subl    $12, %esp
        pushl   $.LC1
        call    puts
        addl    $16, %esp
        subl    $12, %esp
        pushl   $1
        call    exit
.L3:
        movl    $1, -40(%ebp)
        subl    $12, %esp
        pushl   $4
        leal    -40(%ebp), %eax
        pushl   %eax
        pushl   $2
        pushl   $1
        pushl   -16(%ebp)
        call    setsockopt
        addl    $32, %esp
        movw    $2, -56(%ebp)
        movl    -12(%ebp), %eax
        movzwl  %ax, %eax
        subl    $12, %esp
        pushl   %eax
        call    htons
        addl    $16, %esp
        movw    %ax, -54(%ebp)
        movl    $0, -52(%ebp)
        subl    $4, %esp
        pushl   $16
        leal    -56(%ebp), %eax
        pushl   %eax
        pushl   -16(%ebp)
        call    bind
        addl    $16, %esp
        movl    %eax, -20(%ebp)
        cmpl    $0, -20(%ebp)
        jns     .L4
        subl    $8, %esp
        pushl   -12(%ebp)
        pushl   $.LC2
        call    printf
        addl    $16, %esp
        subl    $12, %esp
        pushl   $1
        call    exit
.L4:
        subl    $8, %esp
        pushl   $5
        pushl   -16(%ebp)
        call    listen
        addl    $16, %esp
.L5:
        movl    $16, -28(%ebp)
        subl    $4, %esp
        leal    -28(%ebp), %eax
        pushl   %eax
        leal    -72(%ebp), %eax
        pushl   %eax
        pushl   -16(%ebp)
        call    accept
        addl    $16, %esp
        movl    %eax, -24(%ebp)
        subl    $4, %esp
        pushl   $4096
        leal    -4168(%ebp), %eax
        pushl   %eax
        pushl   -24(%ebp)
        call    read
        addl    $16, %esp
        movl    %eax, -36(%ebp)
        subl    $8, %esp
        pushl   $.LC3
        leal    -4168(%ebp), %eax
        pushl   %eax
        call    strcpy
        addl    $16, %esp
        subl    $4, %esp
        pushl   $88
        leal    -4168(%ebp), %eax
        pushl   %eax
        pushl   -24(%ebp)
        call    write
        addl    $16, %esp
        subl    $8, %esp
        pushl   $0
        pushl   $.LC4
        call    open
        addl    $16, %esp
        movl    %eax, -32(%ebp)
.L7:
        subl    $4, %esp
        pushl   $4096
        leal    -4168(%ebp), %eax
        pushl   %eax
        pushl   -32(%ebp)
        call    read
        addl    $16, %esp
        movl    %eax, -36(%ebp)
        cmpl    $0, -36(%ebp)
        je      .L8
        subl    $4, %esp
        pushl   -36(%ebp)
        leal    -4168(%ebp), %eax
        pushl   %eax
        pushl   -24(%ebp)
        call    write
        addl    $16, %esp
        jmp     .L7
.L8:
        subl    $12, %esp
        pushl   -32(%ebp)
        call    close
        addl    $16, %esp
        subl    $12, %esp
        pushl   -24(%ebp)
        call    close
        addl    $16, %esp
        jmp     .L5
        .size   main, .-main
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4.5 20051201 (Red Hat 3.4.5-2)"