// File: /workspace/github_c_makefile_star2_O0/vasusharma7[P]Text-Editor/stdedit.c
// Function: add_line
int add_line(int line){
    int i = 0;
    point *temp = data.front;
    if(line < lines){
        enqueue_pos(&data,line);
    }
    else if( lines == line){
        enqueue(&data);
    }
    for(i = 0; i < line - 1; i++){
        temp = temp->tail;
    }
    char *str = (char *)calloc(2,1);
    str[0] = '\0';
    int x,y;
    char ch[2] = {'\0'};
    i = 0;
    ch[0] = ipops(&(temp->element));

    getyx(stdscr,y,x);
    
    while(ch[0] != '\n'){
       
        i++;
        strcat(str,ch);
         str = realloc(str,strlen(str) +2);
        ch[0] = ipops(&(temp->element));
    }
    ipushs(&(temp->element),'\n');
    if(strlen(str)){
        while(i--){
            ipushs(&(temp->tail->element),str[i]);
        }
    }
    if(line < lines)
        ipushs(&(temp->tail->element),'\n');
    return temp->tail->element.width;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
leaq 0xa2d7(%rip), %rax      # 0xd1e0
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %eax
leaq 0xa276(%rip), %rcx      # 0xd190
cmpl (%rcx), %eax
jge 0x2f2f
movl -0x4(%rbp), %esi
leaq 0xa2b8(%rip), %rdi      # 0xd1e0
callq 0x2940
jmp 0x2f4b
leaq 0xa25a(%rip), %rax      # 0xd190
movl (%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x2f49
leaq 0xa29c(%rip), %rdi      # 0xd1e0
callq 0x28c0
jmp 0x2f4b
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2f75
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x2f52
movl $0x2, %edi
movl $0x1, %esi
callq 0x2180
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
leaq -0x22(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2110
movl $0x0, -0x8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2660
movb %al, -0x22(%rbp)
xorl %eax, %eax
movq 0xa021(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x2fd6
movq 0xa015(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x2fe0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x28(%rbp)
jmp 0x2fe0
movl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
movq 0x9ff1(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x3007
movq 0x9fe5(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x3011
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x2c(%rbp)
jmp 0x3011
movl -0x2c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsbl -0x22(%rbp), %eax
cmpl $0xa, %eax
je 0x306d
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x22(%rbp), %rsi
callq 0x2270
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20b0
movq -0x38(%rbp), %rdi
movq %rax, %rsi
addq $0x2, %rsi
callq 0x2210
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x2660
movb %al, -0x22(%rbp)
jmp 0x3017
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0xa, %esi
callq 0x2460
movq -0x18(%rbp), %rdi
callq 0x20b0
cmpq $0x0, %rax
je 0x30c0
jmp 0x3090
movl -0x8(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x8(%rbp)
cmpl $0x0, %eax
je 0x30be
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rax
movslq -0x8(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x2460
jmp 0x3090
jmp 0x30c0
movl -0x4(%rbp), %eax
leaq 0xa0c6(%rip), %rcx      # 0xd190
cmpl (%rcx), %eax
jge 0x30e3
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
movl $0xa, %esi
callq 0x2460
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)