// File: /workspace/github_c_makefile_star2_O0/yahya-tamur[P]Visualising-Complex-Functions/gifenc.c
// Function: ge_new_gif
ge_GIF *ge_new_gif(
    const char *fname, uint16_t width, uint16_t height, uint8_t *palette, int depth, int loop) {
    ge_GIF *gif = calloc(1, sizeof(*gif) + 2 * width * height);
    if (!gif)
        goto no_gif;
    gif->w = width;
    gif->h = height;
    gif->depth = depth > 1 ? depth : 2;
    gif->frame = (uint8_t *) &gif[1];
    gif->back = &gif->frame[width * height];
    gif->fd = creat(fname, 0666);
    if (gif->fd == -1)
        goto no_fd;
    write(gif->fd, "GIF89a", 6);
    write_num(gif->fd, width);
    write_num(gif->fd, height);
    write(gif->fd, (uint8_t[]) { 0xF0 | (depth - 1), 0x00, 0x00 }, 3);
    write(gif->fd, palette, 3 << depth);
    if (loop >= 0 && loop <= 0xFFFF)
        put_loop(gif, (uint16_t) loop);
    return gif;
no_fd:
    free(gif);
no_gif:
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movw %dx, %ax
movw %si, %dx
movq %rdi, -0x10(%rbp)
movw %dx, -0x12(%rbp)
movw %ax, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movzwl -0x12(%rbp), %eax
shll %eax
movzwl -0x14(%rbp), %ecx
imull %ecx, %eax
movslq %eax, %rsi
addq $0x130, %rsi            # imm = 0x130
movl $0x1, %edi
callq 0x20e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x23e7
jmp 0x2560
movw -0x12(%rbp), %cx
movq -0x30(%rbp), %rax
movw %cx, (%rax)
movw -0x14(%rbp), %cx
movq -0x30(%rbp), %rax
movw %cx, 0x2(%rax)
cmpl $0x1, -0x24(%rbp)
jle 0x240c
movl -0x24(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x2416
movl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2416
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rcx
addq $0x130, %rcx            # imm = 0x130
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movzwl -0x12(%rbp), %eax
movzwl -0x14(%rbp), %edx
imull %edx, %eax
cltq
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x20f0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x2479
jmp 0x2557
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
leaq 0x3b7d(%rip), %rsi      # 0x6004
movl $0x6, %edx
callq 0x2070
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movzwl -0x12(%rbp), %eax
andl $0xff, %eax
movb %al, -0x32(%rbp)
movzwl -0x12(%rbp), %eax
sarl $0x8, %eax
movb %al, -0x31(%rbp)
leaq -0x32(%rbp), %rsi
movl $0x2, %edx
callq 0x2070
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movzwl -0x14(%rbp), %eax
andl $0xff, %eax
movb %al, -0x34(%rbp)
movzwl -0x14(%rbp), %eax
sarl $0x8, %eax
movb %al, -0x33(%rbp)
leaq -0x34(%rbp), %rsi
movl $0x2, %edx
callq 0x2070
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movl -0x24(%rbp), %eax
subl $0x1, %eax
orl $0xf0, %eax
movb %al, -0x37(%rbp)
movb $0x0, -0x36(%rbp)
movb $0x0, -0x35(%rbp)
leaq -0x37(%rbp), %rsi
movl $0x3, %edx
callq 0x2070
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %ecx
movl $0x3, %eax
shll %cl, %eax
movslq %eax, %rdx
callq 0x2070
cmpl $0x0, -0x28(%rbp)
jl 0x254d
cmpl $0xffff, -0x28(%rbp)    # imm = 0xFFFF
jg 0x254d
movq -0x30(%rbp), %rdi
movl -0x28(%rbp), %eax
movzwl %ax, %esi
callq 0x2580
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2568
movq -0x30(%rbp), %rdi
callq 0x21a0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)