// File: /workspace/github_c_makefile_star2_O0/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_default_config
uint8_t ssd1306_oled_default_config(uint8_t oled_lines, uint8_t oled_columns)
{
    if (oled_lines != SSD1306_128_64_LINES && oled_lines != SSD1306_128_32_LINES && SSD1306_64_48_LINES)
        oled_lines = SSD1306_128_64_LINES;
        
    if (oled_columns != SSD1306_128_64_COLUMNS && oled_lines != SSD1306_128_32_COLUMNS && SSD1306_64_48_COLUMNS)
        oled_columns = SSD1306_128_64_COLUMNS;
        
    max_lines = oled_lines;
    max_columns = oled_columns;
    global_x = 0;
    global_y = 0;
    
    if (ssd1306_oled_save_resolution(max_columns, max_lines) != 0)
        return 1;
    
    uint16_t i = 0;
    data_buf[i++] = SSD1306_COMM_CONTROL_BYTE;  //command control byte
    data_buf[i++] = SSD1306_COMM_DISPLAY_OFF;   //display off
    data_buf[i++] = SSD1306_COMM_DISP_NORM;     //Set Normal Display (default)
    data_buf[i++] = SSD1306_COMM_CLK_SET;       //SETDISPLAYCLOCKDIV
    data_buf[i++] = 0x80;                       // the suggested ratio 0x80
    data_buf[i++] = SSD1306_COMM_MULTIPLEX;     //SSD1306_SETMULTIPLEX
    data_buf[i++] = oled_lines - 1;             // height is 32 or 64 (always -1)
    data_buf[i++] = SSD1306_COMM_VERT_OFFSET;   //SETDISPLAYOFFSET
    data_buf[i++] = 0;                          //no offset
    data_buf[i++] = SSD1306_COMM_START_LINE;    //SETSTARTLINE
    data_buf[i++] = SSD1306_COMM_CHARGE_PUMP;   //CHARGEPUMP
    data_buf[i++] = 0x14;                       //turn on charge pump
    data_buf[i++] = SSD1306_COMM_MEMORY_MODE;   //MEMORYMODE
    data_buf[i++] = SSD1306_PAGE_MODE;          // page mode
    data_buf[i++] = SSD1306_COMM_HORIZ_NORM;    //SEGREMAP  Mirror screen horizontally (A0)
    data_buf[i++] = SSD1306_COMM_SCAN_NORM;     //COMSCANDEC Rotate screen vertically (C0)
    data_buf[i++] = SSD1306_COMM_COM_PIN;       //HARDWARE PIN 
    if (oled_lines == 32)
        data_buf[i++] = 0x02;                       // for 32 lines
    else
        data_buf[i++] = 0x12;                       // for 64 lines or 48 lines
    data_buf[i++] = SSD1306_COMM_CONTRAST;      //SETCONTRAST
    data_buf[i++] = 0x7f;                       // default contract value
    data_buf[i++] = SSD1306_COMM_PRECHARGE;     //SETPRECHARGE
    data_buf[i++] = 0xf1;                       // default precharge value
    data_buf[i++] = SSD1306_COMM_DESELECT_LV;   //SETVCOMDETECT                
    data_buf[i++] = 0x40;                       // default deselect value
    data_buf[i++] = SSD1306_COMM_RESUME_RAM;    //DISPLAYALLON_RESUME
    data_buf[i++] = SSD1306_COMM_DISP_NORM;     //NORMALDISPLAY
    data_buf[i++] = SSD1306_COMM_DISPLAY_ON;    //DISPLAY ON             
    data_buf[i++] = SSD1306_COMM_DISABLE_SCROLL;//Stop scroll
    
    return _i2c_write(data_buf, i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %sil, %al
movb %dil, %cl
movb %cl, -0x2(%rbp)
movb %al, -0x3(%rbp)
movzbl -0x2(%rbp), %eax
cmpl $0x40, %eax
je 0x40287a
movzbl -0x2(%rbp), %eax
cmpl $0x20, %eax
je 0x40287a
movb $0x40, -0x2(%rbp)
movzbl -0x3(%rbp), %eax
cmpl $0x80, %eax
je 0x402894
movzbl -0x2(%rbp), %eax
cmpl $0x80, %eax
je 0x402894
movb $-0x80, -0x3(%rbp)
movb -0x2(%rbp), %al
movb %al, 0xeff35(%rip)      # 0x4f27d2
movb -0x3(%rbp), %al
movb %al, 0xeff2a(%rip)      # 0x4f27d0
movb $0x0, 0xeff24(%rip)     # 0x4f27d1
movb $0x0, 0xeff1f(%rip)     # 0x4f27d3
movb 0xeff16(%rip), %al      # 0x4f27d0
movzbl %al, %edi
movzbl 0xeff0e(%rip), %esi     # 0x4f27d2
callq 0x402ca0
movzbl %al, %eax
cmpl $0x0, %eax
je 0x4028da
movb $0x1, -0x1(%rbp)
jmp 0x402c89
movw $0x0, -0x6(%rbp)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefad5(%rip), %rax     # 0x4f23d0
movb $0x0, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefab6(%rip), %rax     # 0x4f23d0
movb $-0x52, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefa97(%rip), %rax     # 0x4f23d0
movb $-0x5a, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefa78(%rip), %rax     # 0x4f23d0
movb $-0x2b, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefa59(%rip), %rax     # 0x4f23d0
movb $-0x80, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefa3a(%rip), %rax     # 0x4f23d0
movb $-0x58, (%rax,%rcx)
movzbl -0x2(%rbp), %eax
subl $0x1, %eax
movb %al, %dl
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xefa12(%rip), %rax     # 0x4f23d0
movb %dl, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef9f4(%rip), %rax     # 0x4f23d0
movb $-0x2d, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef9d5(%rip), %rax     # 0x4f23d0
movb $0x0, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef9b6(%rip), %rax     # 0x4f23d0
movb $0x40, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef997(%rip), %rax     # 0x4f23d0
movb $-0x73, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef978(%rip), %rax     # 0x4f23d0
movb $0x14, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef959(%rip), %rax     # 0x4f23d0
movb $0x20, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef93a(%rip), %rax     # 0x4f23d0
movb $0x2, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef91b(%rip), %rax     # 0x4f23d0
movb $-0x60, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef8fc(%rip), %rax     # 0x4f23d0
movb $-0x40, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef8dd(%rip), %rax     # 0x4f23d0
movb $-0x26, (%rax,%rcx)
movzbl -0x2(%rbp), %eax
cmpl $0x20, %eax
jne 0x402b21
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef8b5(%rip), %rax     # 0x4f23d0
movb $0x2, (%rax,%rcx)
jmp 0x402b40
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef894(%rip), %rax     # 0x4f23d0
movb $0x12, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef875(%rip), %rax     # 0x4f23d0
movb $-0x7f, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef856(%rip), %rax     # 0x4f23d0
movb $0x7f, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef837(%rip), %rax     # 0x4f23d0
movb $-0x27, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef818(%rip), %rax     # 0x4f23d0
movb $-0xf, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef7f9(%rip), %rax     # 0x4f23d0
movb $-0x25, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef7da(%rip), %rax     # 0x4f23d0
movb $0x40, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef7bb(%rip), %rax     # 0x4f23d0
movb $-0x5c, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef79c(%rip), %rax     # 0x4f23d0
movb $-0x5a, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef77d(%rip), %rax     # 0x4f23d0
movb $-0x51, (%rax,%rcx)
movw -0x6(%rbp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, -0x6(%rbp)
movzwl %ax, %eax
movl %eax, %ecx
leaq 0xef75e(%rip), %rax     # 0x4f23d0
movb $0x2e, (%rax,%rcx)
leaq 0xef753(%rip), %rdi     # 0x4f23d0
movswl -0x6(%rbp), %esi
callq 0x403280
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)