// File: /workspace/github_c_makefile_star2_O0/yueyoum[P]termgif/record.c
// Function: main
int main(int argc, char *argv[])
{
    Display *d = XOpenDisplay(NULL);
    if (d==NULL) {
        fprintf(stderr, "can not connect x server!\n");
        exit(2);
    }
    Window active;
    int revert;
    XWindowAttributes attr;

    XGetInputFocus(d, &active, &revert);
    /* active = current_window(d); */
    active = target_window(d);
    XGetWindowAttributes(d, active, &attr);

    int width = attr.width;
    int height = attr.height;
    printf("%d, %d, %d, %d\n", attr.x, attr.y, width, height);


    struct timeval delay;
    delay.tv_sec = 0;
    int i;
    char name[12] = {'\0'};
    XImage *image = XGetImage(d, active, 0, 0, width, height, AllPlanes, ZPixmap);
    init_wjpeg(image->width, image->height);

    for(i = 0; i<20; i++)
    {
        sprintf(name, "test_%02d.jpg", i);
        printf("%s\n", name);
        fflush(stdout);
        image = XGetImage(d, active, 0, 0, width, height, AllPlanes, ZPixmap);
        write_jpeg(image, name);
        delay.tv_usec = 500 * 1000;
        select(0, NULL, NULL, NULL, &delay);
    }

    destroy_wjpeg();
    XCloseDisplay(d);
    return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x20c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x231f
movq 0x6ecdc(%rip), %rax     # 0x70fe0
movq (%rax), %rdi
leaq 0x2ecf6(%rip), %rsi     # 0x31004
movb $0x0, %al
callq 0x20d0
movl $0x2, %edi
callq 0x2160
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x21b0
movq -0x18(%rbp), %rdi
callq 0x27b0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x2130
movl -0xa8(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb0(%rbp), %esi
movl -0xac(%rbp), %edx
movl -0xb4(%rbp), %ecx
movl -0xb8(%rbp), %r8d
leaq 0x2ec96(%rip), %rdi     # 0x3101f
movb $0x0, %al
callq 0x2090
movq $0x0, -0xc8(%rbp)
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20b0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0xb4(%rbp), %r8d
movl -0xb8(%rbp), %r9d
xorl %ecx, %ecx
movl %ecx, %edx
movq $-0x1, (%rsp)
movl $0x2, 0x8(%rsp)
callq 0x21a0
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movl (%rax), %edi
movq -0xe0(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x24f0
movl $0x0, -0xcc(%rbp)
cmpl $0x14, -0xcc(%rbp)
jge 0x24d2
leaq -0xd8(%rbp), %rdi
movl -0xcc(%rbp), %edx
leaq 0x2ec08(%rip), %rsi     # 0x3102f
movb $0x0, %al
callq 0x2150
leaq -0xd8(%rbp), %rsi
leaq 0x2ec01(%rip), %rdi     # 0x3103d
movb $0x0, %al
callq 0x2090
movq 0x6eaf6(%rip), %rax     # 0x70f40
movq (%rax), %rdi
callq 0x2110
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0xb4(%rbp), %r8d
movl -0xb8(%rbp), %r9d
xorl %ecx, %ecx
movl %ecx, %edx
movq $-0x1, (%rsp)
movl $0x2, 0x8(%rsp)
callq 0x21a0
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x2560
movq $0x7a120, -0xc0(%rbp) # imm = 0x7A120
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xc8(%rbp), %r8
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x20f0
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x2406
movb $0x0, %al
callq 0x2540
movq -0x18(%rbp), %rdi
callq 0x2190
xorl %eax, %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)