
blank_project_1.elf:     file format elf32-littlenios2

Disassembly of section .entry:

00000000 <__reset>:
     */
#if NIOS2_ICACHE_SIZE > 0x8000
    movhi r2, %hi(NIOS2_ICACHE_SIZE)
#else 
    movui r2, NIOS2_ICACHE_SIZE
   0:	00840014 	movui	r2,4096
#endif

0:
    initi r2
   4:	1001483a 	initi	r2
    addi r2, r2, -NIOS2_ICACHE_LINE_SIZE
   8:	10bff804 	addi	r2,r2,-32
    bgt r2, zero, 0b
   c:	00bffd16 	blt	zero,r2,4 <__alt_mem_onchip_memory_0+0x4>
1:

    /*
     * The following block of debug information tells the simulator not to
     * run the loop above, but to perform its actions using faster internal
     * code.
     */
    .pushsection .debug_alt_sim_info
    .int 1, 1, 0b, 1b
    .popsection
#endif /* NIOS2_ICACHE_SIZE > 0 */
    /* 
     * Having initialised the cache, call the entry point for the .text
     * section.
     */
#endif /* ALT_SIM_OPTIMIZE */

    movhi r1, %hiadj(_start)
  10:	00400034 	movhi	at,0
    addi r1, r1, %lo(_start)
  14:	08407204 	addi	at,at,456

    jmp r1
  18:	0800683a 	jmp	at
  1c:	00000000 	call	0 <__alt_mem_onchip_memory_0>
Disassembly of section .exceptions:

00000020 <alt_exception>:
         * caller saved registers on the stack (See the Nios2 ABI
         * documentation for details).
         */

        addi  sp, sp, -76
  20:	deffed04 	addi	sp,sp,-76

#ifdef ALT_STACK_CHECK

        bltu  sp, et, .Lstack_overflow

#endif

#endif

        stw   ra,  0(sp)
  24:	dfc00015 	stw	ra,0(sp)

        /*
         * Leave a gap in the stack frame at 4(sp) for the muldiv handler to
         * store zero into.
         */

        stw   r1,   8(sp)
  28:	d8400215 	stw	at,8(sp)
        stw   r2,  12(sp)
  2c:	d8800315 	stw	r2,12(sp)
        stw   r3,  16(sp)
  30:	d8c00415 	stw	r3,16(sp)
        stw   r4,  20(sp)
  34:	d9000515 	stw	r4,20(sp)
        stw   r5,  24(sp)
  38:	d9400615 	stw	r5,24(sp)
        stw   r6,  28(sp)
  3c:	d9800715 	stw	r6,28(sp)
        stw   r7,  32(sp)
  40:	d9c00815 	stw	r7,32(sp)

        rdctl r5, estatus
  44:	000b307a 	rdctl	r5,estatus

        stw   r8,  36(sp)
  48:	da000915 	stw	r8,36(sp)
        stw   r9,  40(sp)
  4c:	da400a15 	stw	r9,40(sp)
        stw   r10, 44(sp)
  50:	da800b15 	stw	r10,44(sp)
        stw   r11, 48(sp)
  54:	dac00c15 	stw	r11,48(sp)
        stw   r12, 52(sp)
  58:	db000d15 	stw	r12,52(sp)
        stw   r13, 56(sp)
  5c:	db400e15 	stw	r13,56(sp)
        stw   r14, 60(sp)
  60:	db800f15 	stw	r14,60(sp)
        stw   r15, 64(sp)
  64:	dbc01015 	stw	r15,64(sp)

        stw   r5,  68(sp)
  68:	d9401115 	stw	r5,68(sp)
        addi  r15, ea, -4 /* re-issue the interrupted instruction */
  6c:	ebffff04 	addi	r15,ea,-4
        stw   r15,  72(sp)
  70:	dbc01215 	stw	r15,72(sp)
        /*
         * Test to see if the exception was a software exception or caused 
         * by an external interrupt, and vector accordingly.
         */
        rdctl r4, ipending
  74:	0009313a 	rdctl	r4,ipending
        andi  r2, r5, 1
  78:	2880004c 	andi	r2,r5,1
        beq   r2, zero, .Lnot_irq
  7c:	10000326 	beq	r2,zero,8c <alt_exception+0x6c>
        beq   r4, zero, .Lnot_irq
  80:	20000226 	beq	r4,zero,8c <alt_exception+0x6c>
#endif /* ALT_CI_EXCEPTION_VECTOR_N */

        .section .exceptions.irqhandler, "xa"
        /*
         * Now that all necessary registers have been preserved, call 
         * alt_irq_handler() to process the interrupts.
         */

        call alt_irq_handler
  84:	00000ec0 	call	ec <alt_irq_handler>

        .section .exceptions.irqreturn, "xa"

        br    .Lexception_exit
  88:	00000306 	br	98 <alt_exception+0x78>

        /*
         * The interrupt testing code goes here.  If an interrupt is active
         * then it stores ea-4 into 72(sp), handles the interrupt and jumps to
         * .exceptions.exit.  If there is no interrupt then it continues
         */

        .section .exceptions.notirq, "xa"

        stw   ea,  72(sp) /* Return after the instruction which caused the exception */
  8c:	df401215 	stw	ea,72(sp)
        ldw   r2, -4(ea)
  90:	e8bfff17 	ldw	r2,-4(ea)

        /*
         * The other exception handling code goes here.
         */

        .section .exceptions.unknown

        /*
        *  If you get here then one of the following could have happened:
        *
        *  - Your program could have been compiled for a full-featured Nios II
        *    core, but it is running on a smaller core, and instruction emulation
        *    has been disabled by defining ALT_NO_INSTRUCTION_EMULATION.
        *
        *    You can work around the problem by re-enabling instruction emulation,
        *    or you can figure out why your program is being compiled for a system
        *    other than the one that it is running on.
        *
        *  - Your program has executed a trap instruction, but has not implemented
        *    a handler for this instruction.
        *
        *  - Your program has executed an illegal instruction (one which is not
        *    defined in the instruction set).
        *
        *  - Your hardware is broken and is generating spurious interrupts (a
        *    peripheral which deasserts its interrupt output before its interrupt
        *    handler has been executed will cause spurious interrupts).
        *
        */

#ifdef NIOS2_HAS_DEBUG_STUB

        /*
        *  Either tell the user now (if there is a debugger attached) or go into
        *  the debug monitor which will loop until a debugger is attached.
        */
        break
  94:	003da03a 	break	0

#else

        /*
        *  If there is no debug stub then a BREAK will probably cause a reboot.
        *  An infinate loop will probably be more useful.
        */
0:
        br   0b

#endif

        .section .exceptions.exit, "xa"

        /* 
         * Restore the saved registers, so that all general purpose registers 
         * have been restored to their state at the time the interrupt occured.
         */

        ldw   r5,  68(sp)
  98:	d9401117 	ldw	r5,68(sp)
        ldw   ea,  72(sp)
  9c:	df401217 	ldw	ea,72(sp)
        ldw   ra,   0(sp)
  a0:	dfc00017 	ldw	ra,0(sp)

        wrctl estatus, r5
  a4:	2801707a 	wrctl	estatus,r5

        ldw   r1,   8(sp)
  a8:	d8400217 	ldw	at,8(sp)
        ldw   r2,  12(sp)
  ac:	d8800317 	ldw	r2,12(sp)
        ldw   r3,  16(sp)
  b0:	d8c00417 	ldw	r3,16(sp)
        ldw   r4,  20(sp)
  b4:	d9000517 	ldw	r4,20(sp)
        ldw   r5,  24(sp)
  b8:	d9400617 	ldw	r5,24(sp)
        ldw   r6,  28(sp)
  bc:	d9800717 	ldw	r6,28(sp)
        ldw   r7,  32(sp)
  c0:	d9c00817 	ldw	r7,32(sp)

#ifdef ALT_EXCEPTION_STACK
#ifdef ALT_STACK_CHECK
        ldw   et, %gprel(alt_exception_old_stack_limit)(gp)
#endif
#endif

        ldw   r8,  36(sp)
  c4:	da000917 	ldw	r8,36(sp)
        ldw   r9,  40(sp)
  c8:	da400a17 	ldw	r9,40(sp)
        ldw   r10, 44(sp)
  cc:	da800b17 	ldw	r10,44(sp)
        ldw   r11, 48(sp)
  d0:	dac00c17 	ldw	r11,48(sp)
        ldw   r12, 52(sp)
  d4:	db000d17 	ldw	r12,52(sp)
        ldw   r13, 56(sp)
  d8:	db400e17 	ldw	r13,56(sp)
        ldw   r14, 60(sp)
  dc:	db800f17 	ldw	r14,60(sp)
        ldw   r15, 64(sp)
  e0:	dbc01017 	ldw	r15,64(sp)

#ifdef ALT_EXCEPTION_STACK

#ifdef ALT_STACK_CHECK
        stw   et, %gprel(alt_stack_limit_value)(gp)
        stw   zero, %gprel(alt_exception_old_stack_limit)(gp)
#endif

        ldw   sp,  76(sp)

#else
        addi  sp, sp, 76
  e4:	dec01304 	addi	sp,sp,76

#endif

        /*
         * Return to the interrupted instruction.
         */

        eret
  e8:	e800083a 	eret

000000ec <alt_irq_handler>:
 */

void alt_irq_handler (void) __attribute__ ((section (".exceptions")));
void alt_irq_handler (void)
{
  ec:	defff904 	addi	sp,sp,-28
  f0:	dfc00615 	stw	ra,24(sp)
  f4:	df000515 	stw	fp,20(sp)
  f8:	d839883a 	mov	fp,sp
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_pending (void)
{
  alt_u32 active;

  NIOS2_READ_IPENDING (active);
  fc:	0005313a 	rdctl	r2,ipending
 100:	e0800415 	stw	r2,16(fp)
 104:	e0800417 	ldw	r2,16(fp)
 108:	e0800315 	stw	r2,12(fp)
 10c:	e0800317 	ldw	r2,12(fp)
 110:	e0800015 	stw	r2,0(fp)
#ifdef ALT_CI_EXCEPTION_VECTOR
  alt_32 offset;
  char*  alt_irq_base = (char*)alt_irq;
#else
  alt_u32 active;
  alt_u32 mask;
  alt_u32 i;
#endif /* ALT_CI_EXCEPTION_VECTOR */
  
  /*
   * Notify the operating system that we are at interrupt level.
   */ 
  
  ALT_OS_INT_ENTER();

#ifdef ALT_CI_EXCEPTION_VECTOR
  /*
   * Call the exception vector custom instruction using the 
   * ALT_CI_EXCEPTION_VECTOR macro.
   * It returns the offset into the vector table of the lowest-valued pending
   * interrupt (corresponds to highest priority) or a negative value if none.
   * The custom instruction assumes that each table entry is eight bytes.
   */
  while ((offset = ALT_CI_EXCEPTION_VECTOR) >= 0) {
    struct ALT_IRQ_HANDLER* handler_entry = 
      (struct ALT_IRQ_HANDLER*)(alt_irq_base + offset);

    handler_entry->handler(handler_entry->context, offset >> 3);
  }
#else
  /* 
   * Obtain from the interrupt controller a bit list of pending interrupts,
   * and then process the highest priority interrupt. This process loops, 
   * loading the active interrupt list on each pass until alt_irq_pending() 
   * return zero.
   * 
   * The maximum interrupt latency for the highest priority interrupt is
   * reduced by finding out which interrupts are pending as late as possible.
   * Consider the case where the high priority interupt is asserted during
   * the interrupt entry sequence for a lower priority interrupt to see why
   * this is the case.
   */

  active = alt_irq_pending ();

  do
  {
    i = 0;
 114:	e0000215 	stw	zero,8(fp)
    mask = 1;
 118:	00800044 	movi	r2,1
 11c:	e0800115 	stw	r2,4(fp)

    /*
     * Test each bit in turn looking for an active interrupt. Once one is 
     * found, the interrupt handler asigned by a call to alt_irq_register() is
     * called to clear the interrupt condition.
     */

    do
    {
      if (active & mask)
 120:	e0c00017 	ldw	r3,0(fp)
 124:	e0800117 	ldw	r2,4(fp)
 128:	1884703a 	and	r2,r3,r2
 12c:	1005003a 	cmpeq	r2,r2,zero
 130:	1000101e 	bne	r2,zero,174 <alt_irq_handler+0x88>
      { 
        alt_irq[i].handler(alt_irq[i].context, i); 
 134:	00c00034 	movhi	r3,0
 138:	18d10604 	addi	r3,r3,17432
 13c:	e0800217 	ldw	r2,8(fp)
 140:	10800224 	muli	r2,r2,8
 144:	10c9883a 	add	r4,r2,r3
 148:	00c00034 	movhi	r3,0
 14c:	18d10604 	addi	r3,r3,17432
 150:	e0800217 	ldw	r2,8(fp)
 154:	10800224 	muli	r2,r2,8
 158:	10c5883a 	add	r2,r2,r3
 15c:	10800104 	addi	r2,r2,4
 160:	20c00017 	ldw	r3,0(r4)
 164:	11000017 	ldw	r4,0(r2)
 168:	e1400217 	ldw	r5,8(fp)
 16c:	183ee83a 	callr	r3
        break;
 170:	00000706 	br	190 <alt_irq_handler+0xa4>
      }
      mask <<= 1;
 174:	e0800117 	ldw	r2,4(fp)
 178:	1085883a 	add	r2,r2,r2
 17c:	e0800115 	stw	r2,4(fp)
      i++;
 180:	e0800217 	ldw	r2,8(fp)
 184:	10800044 	addi	r2,r2,1
 188:	e0800215 	stw	r2,8(fp)

    } while (1);
 18c:	003fe406 	br	120 <alt_irq_handler+0x34>
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_pending (void)
{
  alt_u32 active;

  NIOS2_READ_IPENDING (active);
 190:	0005313a 	rdctl	r2,ipending
 194:	e0800315 	stw	r2,12(fp)
 198:	e0800317 	ldw	r2,12(fp)
 19c:	e0800415 	stw	r2,16(fp)
 1a0:	e0800417 	ldw	r2,16(fp)
 1a4:	e0800015 	stw	r2,0(fp)

    active = alt_irq_pending ();
    
  } while (active);
 1a8:	e0800017 	ldw	r2,0(fp)
 1ac:	1005003a 	cmpeq	r2,r2,zero
 1b0:	1000011e 	bne	r2,zero,1b8 <alt_irq_handler+0xcc>
 1b4:	003fd706 	br	114 <alt_irq_handler+0x28>
#endif /* ALT_CI_EXCEPTION_VECTOR */

  /*
   * Notify the operating system that interrupt processing is complete.
   */ 

  ALT_OS_INT_EXIT();
}
 1b8:	dfc00617 	ldw	ra,24(sp)
 1bc:	df000517 	ldw	fp,20(sp)
 1c0:	dec00704 	addi	sp,sp,28
 1c4:	f800283a 	ret
Disassembly of section .text:

000001c8 <_start>:

    .size __reset, . - __reset

#endif

    /*
     * Start of the .text section, and also the code entry point when
     * the code is executed by a loader rather than directly from reset.
     */

    .section .text
    .align 2
    .globl _start
    .type _start, @function

_start:
/*
*   If ALT_SIM_OPTIMIZE is defined this code WILL NOT RUN ON HARDWARE
*   This defined removes the initialisation of the instruction
*   and data caches at run time. It is assumed that this is done by the 
*   simulation model 
*/
#ifndef ALT_SIM_OPTIMIZE
    /*
     * After initializing the instruction cache, we must initialize the data
     * cache.
     */

#if NIOS2_DCACHE_SIZE > 0

    /* 
     * The assumption here is that the data cache size is always
     * a power of two.
     */
#if NIOS2_DCACHE_SIZE > 0x8000
    movhi r2, %hi(NIOS2_DCACHE_SIZE)
#else
    movui r2, NIOS2_DCACHE_SIZE
     1c8:	00820014 	movui	r2,2048
#endif

0:
    initd 0(r2)
     1cc:	10000033 	initd	0(r2)
    addi r2, r2, -NIOS2_DCACHE_LINE_SIZE
     1d0:	10bfff04 	addi	r2,r2,-4
    bgt r2, zero, 0b
     1d4:	00bffd16 	blt	zero,r2,1cc <_start+0x4>
1:

    /*
     * The following block of debug information tells the simulator not to
     * run the loop above, but to perform its actions using faster internal
     * code.
     */
    .pushsection .debug_alt_sim_info
    .int 2, 1, 0b, 1b
    .popsection

#endif /* NIOS2_DCACHE_SIZE > 0 */
#endif /* ALT_SIM_OPTIMIZE */

    /* 
     * Now that the caches have been cleaned, set up the stack pointer. 
     * The value provided by the linker is assumed to be correctly aligned. 
     */

    movhi sp, %hiadj(__alt_stack_pointer)
     1d8:	06c00074 	movhi	sp,1
    addi sp, sp, %lo(__alt_stack_pointer)
     1dc:	dee00004 	addi	sp,sp,-32768

    /* set up the global pointer. */

    movhi gp, %hiadj(_gp)
     1e0:	06800074 	movhi	gp,1
    addi gp, gp, %lo(_gp)
     1e4:	d6b0ee04 	addi	gp,gp,-15432

#ifndef ALT_SIM_OPTIMIZE

    /*
     * Clear bss.
     *
     * This uses the symbols: __bss_start and __bss_end, which are defined 
     * by the linker script. They mark the begining and the end of the bss 
     * region. The linker script guarantees that these values are word 
     * aligned. 
     */

    movhi r2, %hiadj(__bss_start)
     1e8:	00800034 	movhi	r2,0
    addi r2, r2, %lo(__bss_start)
     1ec:	10910404 	addi	r2,r2,17424

    movhi r3, %hiadj(__bss_end)
     1f0:	00c00034 	movhi	r3,0
    addi r3, r3, %lo(__bss_end)
     1f4:	18d18904 	addi	r3,r3,17956

    beq r2, r3, 1f 
     1f8:	10c00326 	beq	r2,r3,208 <_start+0x40>

0:
    stw zero, (r2)
     1fc:	10000015 	stw	zero,0(r2)
    addi r2, r2, 4
     200:	10800104 	addi	r2,r2,4
    bltu r2, r3, 0b
     204:	10fffd36 	bltu	r2,r3,1fc <_start+0x34>

1:

    /*
     * The following block of debug information tells the simulator not to
     * run the loop above, but to perform its actions using faster internal
     * code.
     */
    .pushsection .debug_alt_sim_info
    .int 3, 1, 0b, 1b
    .popsection

#endif /* ALT_SIM_OPTIMIZE */

    /* 
     * When running from flash. Load the data sections to RAM, if there
     * are any sections to load.
	 *
	 * If the user has selected stack checking then we need to set up a safe
	 * value in the stack limit register so that the relocation functions
	 * don't think the stack has overflowed (the contents of the rwdata
	 * section aren't defined until alt_load has been called).
     */

#ifdef ALT_NO_BOOTLOADER
#if ALT_LOAD_SECTIONS

#ifdef ALT_STACK_CHECK

    mov   et, zero

#endif

    call alt_load

#endif /* ALT_LOAD_SECTIONS */
#endif /* ALT_NO_BOOTLOADER */ 

#ifdef ALT_STACK_CHECK

    /*
     * Set up the stack limit (if required).  The linker has set up the
     * copy of the variable which is in memory.
     */

    ldw   et, %gprel(alt_stack_limit_value)(gp)

#endif

    /* call the C entry point.  */

    call alt_main
     208:	00002800 	call	280 <alt_main>

0000020c <main>:
int main()
{
     20c:	defffa04 	addi	sp,sp,-24
     210:	df000515 	stw	fp,20(sp)
     214:	d839883a 	mov	fp,sp
  register int a, b, c;
  int d, e, f;
  a = 70000;
     218:	00c00074 	movhi	r3,1
     21c:	18c45c04 	addi	r3,r3,4464
  b = 69995;
     220:	00800074 	movhi	r2,1
     224:	10845ac4 	addi	r2,r2,4459
  c = a - b;
     228:	1887c83a 	sub	r3,r3,r2
     22c:	e0c00315 	stw	r3,12(fp)
  d = 14;
     230:	00800384 	movi	r2,14
     234:	e0800015 	stw	r2,0(fp)
  e = 11;
     238:	008002c4 	movi	r2,11
     23c:	e0800115 	stw	r2,4(fp)
  f = d + e;
     240:	e0c00017 	ldw	r3,0(fp)
     244:	e0800117 	ldw	r2,4(fp)
     248:	1885883a 	add	r2,r3,r2
     24c:	e0800215 	stw	r2,8(fp)
  return (f>c? c: f);
     250:	e0800217 	ldw	r2,8(fp)
     254:	e0c00317 	ldw	r3,12(fp)
     258:	1880030e 	bge	r3,r2,268 <main+0x5c>
     25c:	e0800317 	ldw	r2,12(fp)
     260:	e0800415 	stw	r2,16(fp)
     264:	00000206 	br	270 <main+0x64>
     268:	e0c00217 	ldw	r3,8(fp)
     26c:	e0c00415 	stw	r3,16(fp)
     270:	e0800417 	ldw	r2,16(fp)
}
     274:	df000517 	ldw	fp,20(sp)
     278:	dec00604 	addi	sp,sp,24
     27c:	f800283a 	ret

00000280 <alt_main>:
 * the users application, i.e. main().
 */

void alt_main (void)
{
     280:	defffd04 	addi	sp,sp,-12
     284:	dfc00215 	stw	ra,8(sp)
     288:	df000115 	stw	fp,4(sp)
     28c:	d839883a 	mov	fp,sp
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_init (const void* base)
{
     290:	e0000015 	stw	zero,0(fp)
  NIOS2_WRITE_IENABLE (0);
     294:	000170fa 	wrctl	ienable,zero
  NIOS2_WRITE_STATUS (NIOS2_STATUS_PIE_MSK);
     298:	00800044 	movi	r2,1
     29c:	1001703a 	wrctl	status,r2
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     2a0:	e0000015 	stw	zero,0(fp)
  /* Initialise the interrupt controller. */

  alt_irq_init (ALT_IRQ_BASE);

  /* Initialise the operating system */

  ALT_OS_INIT();

  /* 
   * Initialise the semaphore used to control access to the file descriptor 
   * list.
   */ 

  ALT_SEM_CREATE (&alt_fd_list_lock, 1);

  /* Initialise the device drivers/software components. */

  alt_sys_init ();
     2a4:	00002ec0 	call	2ec <alt_sys_init>

  /* 
   * Redirect stdout etc. to the apropriate devices now that the devices have 
   * been initialised. This is only done if the user has requested that the 
   * channels been directed away from /dev/null - which is how the channels 
   * are configured by default. Making the call to alt_io_redirect conditional
   * allows this function to be excluded from optomised executables when it 
   * is unecessary.
   */ 

  if (strcmp (ALT_STDOUT, "/dev/null") ||
      strcmp (ALT_STDIN, "/dev/null") ||
      strcmp (ALT_STDERR, "/dev/null"))
  {
    alt_io_redirect (ALT_STDOUT, ALT_STDIN, ALT_STDERR);
     2a8:	01000034 	movhi	r4,0
     2ac:	210a7304 	addi	r4,r4,10700
     2b0:	01400034 	movhi	r5,0
     2b4:	294a7304 	addi	r5,r5,10700
     2b8:	01800034 	movhi	r6,0
     2bc:	318a7304 	addi	r6,r6,10700
     2c0:	00011100 	call	1110 <alt_io_redirect>
  }

  /* Call the C++ constructors */

  _do_ctors ();
     2c4:	0000fa00 	call	fa0 <_do_ctors>

  /* 
   * Set the C++ destructors to be called at system shutdown. This is only done
   * if a clean exit has been requested (i.e. the exit() function has not been 
   * redefined as _exit()). This is in the interest of reducing code footprint,
   * in that the atexit() overhead is removed when it's not needed. 
   */

#ifndef ALT_NO_CLEAN_EXIT
  atexit (_do_dtors);
     2c8:	01000034 	movhi	r4,0
     2cc:	2103fe04 	addi	r4,r4,4088
     2d0:	00019a00 	call	19a0 <atexit>
#endif

  /* 
   * Finally, call main(). The return code is then passed to a subsequent
   * call to exit().
   */
   
  exit (main (alt_argc, alt_argv, alt_envp));
     2d4:	d1200017 	ldw	r4,-32768(gp)
     2d8:	d1600117 	ldw	r5,-32764(gp)
     2dc:	d1a00217 	ldw	r6,-32760(gp)
     2e0:	000020c0 	call	20c <main>
     2e4:	1009883a 	mov	r4,r2
     2e8:	0001a3c0 	call	1a3c <exit>

000002ec <alt_sys_init>:
     2ec:	defffe04 	addi	sp,sp,-8
     2f0:	dfc00115 	stw	ra,4(sp)
     2f4:	df000015 	stw	fp,0(sp)
     2f8:	d839883a 	mov	fp,sp
     2fc:	01220014 	movui	r4,34816
     300:	01400044 	movi	r5,1
     304:	0180fa04 	movi	r6,1000
     308:	0000cb80 	call	cb8 <alt_avalon_timer_sc_init>
     30c:	01000034 	movhi	r4,0
     310:	210a8104 	addi	r4,r4,10756
     314:	01620814 	movui	r5,34848
     318:	000d883a 	mov	r6,zero
     31c:	0000b900 	call	b90 <alt_avalon_jtag_uart_init>
     320:	dfc00117 	ldw	ra,4(sp)
     324:	df000017 	ldw	fp,0(sp)
     328:	dec00204 	addi	sp,sp,8
     32c:	f800283a 	ret

00000330 <alt_avalon_jtag_uart_read>:
 *
 */

int alt_avalon_jtag_uart_read(alt_fd* fd, char * buffer, int space)
{
     330:	defff204 	addi	sp,sp,-56
     334:	dfc00d15 	stw	ra,52(sp)
     338:	df000c15 	stw	fp,48(sp)
     33c:	d839883a 	mov	fp,sp
     340:	e1000015 	stw	r4,0(fp)
     344:	e1400115 	stw	r5,4(fp)
     348:	e1800215 	stw	r6,8(fp)
  alt_avalon_jtag_uart_dev* dev = (alt_avalon_jtag_uart_dev*) fd->dev; 
     34c:	e0800017 	ldw	r2,0(fp)
     350:	10800017 	ldw	r2,0(r2)
     354:	e0800315 	stw	r2,12(fp)
  char * ptr = buffer;
     358:	e0800117 	ldw	r2,4(fp)
     35c:	e0800415 	stw	r2,16(fp)
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     360:	e0000715 	stw	zero,28(fp)

  alt_irq_context context;
  unsigned int n;

  /*
   * When running in a multi threaded environment, obtain the "read_lock"
   * semaphore. This ensures that reading from the device is thread-safe.
   */
  ALT_SEM_PEND (dev->read_lock, 0);

  while (space > 0)
     364:	e0800217 	ldw	r2,8(fp)
     368:	10800050 	cmplti	r2,r2,1
     36c:	10004d1e 	bne	r2,zero,4a4 <alt_avalon_jtag_uart_read+0x174>
  {
    unsigned int in, out;

    /* Read as much data as possible */
    do
    {
      in  = dev->rx_in;
     370:	e0800317 	ldw	r2,12(fp)
     374:	10801417 	ldw	r2,80(r2)
     378:	e0800815 	stw	r2,32(fp)
      out = dev->rx_out;
     37c:	e0800317 	ldw	r2,12(fp)
     380:	10801517 	ldw	r2,84(r2)
     384:	e0800915 	stw	r2,36(fp)

      if (in >= out)
     388:	e0c00817 	ldw	r3,32(fp)
     38c:	e0800917 	ldw	r2,36(fp)
     390:	18800536 	bltu	r3,r2,3a8 <alt_avalon_jtag_uart_read+0x78>
        n = in - out;
     394:	e0800817 	ldw	r2,32(fp)
     398:	e0c00917 	ldw	r3,36(fp)
     39c:	10c5c83a 	sub	r2,r2,r3
     3a0:	e0800615 	stw	r2,24(fp)
     3a4:	00000406 	br	3b8 <alt_avalon_jtag_uart_read+0x88>
      else
        n = ALT_AVALON_JTAG_UART_BUF_LEN - out;
     3a8:	00820004 	movi	r2,2048
     3ac:	e0c00917 	ldw	r3,36(fp)
     3b0:	10c5c83a 	sub	r2,r2,r3
     3b4:	e0800615 	stw	r2,24(fp)

      if (n == 0)
     3b8:	e0800617 	ldw	r2,24(fp)
     3bc:	1004c03a 	cmpne	r2,r2,zero
     3c0:	1000011e 	bne	r2,zero,3c8 <alt_avalon_jtag_uart_read+0x98>
        break; /* No more data available */
     3c4:	00001e06 	br	440 <alt_avalon_jtag_uart_read+0x110>

      if (n > space)
     3c8:	e0c00217 	ldw	r3,8(fp)
     3cc:	e0800617 	ldw	r2,24(fp)
     3d0:	1880022e 	bgeu	r3,r2,3dc <alt_avalon_jtag_uart_read+0xac>
        n = space;
     3d4:	e0800217 	ldw	r2,8(fp)
     3d8:	e0800615 	stw	r2,24(fp)

      memcpy(ptr, dev->rx_buf + out, n);
     3dc:	e0c00317 	ldw	r3,12(fp)
     3e0:	e0800917 	ldw	r2,36(fp)
     3e4:	1885883a 	add	r2,r3,r2
     3e8:	11401804 	addi	r5,r2,96
     3ec:	e1000417 	ldw	r4,16(fp)
     3f0:	e1800617 	ldw	r6,24(fp)
     3f4:	00022700 	call	2270 <memcpy>
      ptr   += n;
     3f8:	e0c00417 	ldw	r3,16(fp)
     3fc:	e0800617 	ldw	r2,24(fp)
     400:	1885883a 	add	r2,r3,r2
     404:	e0800415 	stw	r2,16(fp)
      space -= n;
     408:	e0c00217 	ldw	r3,8(fp)
     40c:	e0800617 	ldw	r2,24(fp)
     410:	1885c83a 	sub	r2,r3,r2
     414:	e0800215 	stw	r2,8(fp)

      dev->rx_out = (out + n) % ALT_AVALON_JTAG_UART_BUF_LEN;
     418:	e1000317 	ldw	r4,12(fp)
     41c:	e0c00917 	ldw	r3,36(fp)
     420:	e0800617 	ldw	r2,24(fp)
     424:	1885883a 	add	r2,r3,r2
     428:	1081ffcc 	andi	r2,r2,2047
     42c:	20801515 	stw	r2,84(r4)
    }
     430:	e0800217 	ldw	r2,8(fp)
     434:	10800050 	cmplti	r2,r2,1
     438:	1000011e 	bne	r2,zero,440 <alt_avalon_jtag_uart_read+0x110>
     43c:	003fcc06 	br	370 <alt_avalon_jtag_uart_read+0x40>
    while (space > 0);

    /* If we read any data then return it */
    if (ptr != buffer)
     440:	e0c00417 	ldw	r3,16(fp)
     444:	e0800117 	ldw	r2,4(fp)
     448:	18800126 	beq	r3,r2,450 <alt_avalon_jtag_uart_read+0x120>
      break;
     44c:	00001506 	br	4a4 <alt_avalon_jtag_uart_read+0x174>

    /* If in non-blocking mode then return error */
    if (fd->fd_flags & O_NONBLOCK)
     450:	e0800017 	ldw	r2,0(fp)
     454:	10800217 	ldw	r2,8(r2)
     458:	1004d3ba 	srli	r2,r2,14
     45c:	1080004c 	andi	r2,r2,1
     460:	1005003a 	cmpeq	r2,r2,zero
     464:	1000011e 	bne	r2,zero,46c <alt_avalon_jtag_uart_read+0x13c>
      break;
     468:	00000e06 	br	4a4 <alt_avalon_jtag_uart_read+0x174>

    /* TODO: in the multi-threaded context this should be waiting on an event */
    /* Spin until more data arrives or until host disconnects */
    while (in == dev->rx_in && dev->host_inactive < dev->timeout)
     46c:	e0800317 	ldw	r2,12(fp)
     470:	10c01417 	ldw	r3,80(r2)
     474:	e0800817 	ldw	r2,32(fp)
     478:	1880061e 	bne	r3,r2,494 <alt_avalon_jtag_uart_read+0x164>
     47c:	e0800317 	ldw	r2,12(fp)
     480:	e0c00317 	ldw	r3,12(fp)
     484:	11001317 	ldw	r4,76(r2)
     488:	18800b17 	ldw	r2,44(r3)
     48c:	2080012e 	bgeu	r4,r2,494 <alt_avalon_jtag_uart_read+0x164>
     490:	003ff606 	br	46c <alt_avalon_jtag_uart_read+0x13c>
      ; 
    
    if (in == dev->rx_in)
     494:	e0800317 	ldw	r2,12(fp)
     498:	10c01417 	ldw	r3,80(r2)
     49c:	e0800817 	ldw	r2,32(fp)
     4a0:	18bfb01e 	bne	r3,r2,364 <alt_avalon_jtag_uart_read+0x34>
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     4a4:	e0000915 	stw	zero,36(fp)
      break;
  }

  /*
   * Now that access to the circular buffer is complete, release the read
   * semaphore so that other threads can access the buffer.
   */

  ALT_SEM_POST (dev->read_lock);

  if (ptr != buffer)
     4a8:	e0c00417 	ldw	r3,16(fp)
     4ac:	e0800117 	ldw	r2,4(fp)
     4b0:	18801726 	beq	r3,r2,510 <alt_avalon_jtag_uart_read+0x1e0>
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
     4b4:	0005303a 	rdctl	r2,status
     4b8:	e0800a15 	stw	r2,40(fp)
  NIOS2_WRITE_STATUS (0);
     4bc:	0001703a 	wrctl	status,zero
     4c0:	e0800a17 	ldw	r2,40(fp)
     4c4:	e0800815 	stw	r2,32(fp)
     4c8:	e0800817 	ldw	r2,32(fp)
     4cc:	e0800515 	stw	r2,20(fp)
  {
    /* If we read any data then there is space in the buffer so enable interrupts */
    context = alt_irq_disable_all();
    dev->irq_enable |= ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK;
     4d0:	e0c00317 	ldw	r3,12(fp)
     4d4:	e0800317 	ldw	r2,12(fp)
     4d8:	10801217 	ldw	r2,72(r2)
     4dc:	10800054 	ori	r2,r2,1
     4e0:	18801215 	stw	r2,72(r3)
    IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(dev->base, dev->irq_enable);
     4e4:	e0800317 	ldw	r2,12(fp)
     4e8:	10800a17 	ldw	r2,40(r2)
     4ec:	10800104 	addi	r2,r2,4
     4f0:	1007883a 	mov	r3,r2
     4f4:	e0800317 	ldw	r2,12(fp)
     4f8:	10801217 	ldw	r2,72(r2)
     4fc:	18800035 	stwio	r2,0(r3)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_enable_all (alt_irq_context context)
{
     500:	e0800517 	ldw	r2,20(fp)
     504:	e0800a15 	stw	r2,40(fp)
  NIOS2_WRITE_STATUS (context);
     508:	e0800a17 	ldw	r2,40(fp)
     50c:	1001703a 	wrctl	status,r2
    alt_irq_enable_all(context);
  }

  if (ptr != buffer)
     510:	e0c00417 	ldw	r3,16(fp)
     514:	e0800117 	ldw	r2,4(fp)
     518:	18800526 	beq	r3,r2,530 <alt_avalon_jtag_uart_read+0x200>
    return ptr - buffer;
     51c:	e0800417 	ldw	r2,16(fp)
     520:	e0c00117 	ldw	r3,4(fp)
     524:	10c5c83a 	sub	r2,r2,r3
     528:	e0800b15 	stw	r2,44(fp)
     52c:	00000b06 	br	55c <alt_avalon_jtag_uart_read+0x22c>
  else if (fd->fd_flags & O_NONBLOCK)
     530:	e0800017 	ldw	r2,0(fp)
     534:	10800217 	ldw	r2,8(r2)
     538:	1004d3ba 	srli	r2,r2,14
     53c:	1080004c 	andi	r2,r2,1
     540:	1005003a 	cmpeq	r2,r2,zero
     544:	1000031e 	bne	r2,zero,554 <alt_avalon_jtag_uart_read+0x224>
    return -EWOULDBLOCK;
     548:	00bffd44 	movi	r2,-11
     54c:	e0800b15 	stw	r2,44(fp)
     550:	00000206 	br	55c <alt_avalon_jtag_uart_read+0x22c>
  else
    return -EIO;
     554:	00bffec4 	movi	r2,-5
     558:	e0800b15 	stw	r2,44(fp)
}
     55c:	e0800b17 	ldw	r2,44(fp)
     560:	dfc00d17 	ldw	ra,52(sp)
     564:	df000c17 	ldw	fp,48(sp)
     568:	dec00e04 	addi	sp,sp,56
     56c:	f800283a 	ret

00000570 <alt_avalon_jtag_uart_write>:

/*
 *
 */

int alt_avalon_jtag_uart_write(alt_fd* fd, const char * ptr, int count)
{
     570:	defff104 	addi	sp,sp,-60
     574:	dfc00e15 	stw	ra,56(sp)
     578:	df000d15 	stw	fp,52(sp)
     57c:	d839883a 	mov	fp,sp
     580:	e1000015 	stw	r4,0(fp)
     584:	e1400115 	stw	r5,4(fp)
     588:	e1800215 	stw	r6,8(fp)
  /* Remove warning at optimisation level 03 by seting out to 0 */
  unsigned int in, out=0;
     58c:	e0000415 	stw	zero,16(fp)
  unsigned int n;
  alt_irq_context context;

  alt_avalon_jtag_uart_dev* dev = (alt_avalon_jtag_uart_dev*) fd->dev;
     590:	e0800017 	ldw	r2,0(fp)
     594:	10800017 	ldw	r2,0(r2)
     598:	e0800715 	stw	r2,28(fp)
  const char * start = ptr;
     59c:	e0800117 	ldw	r2,4(fp)
     5a0:	e0800815 	stw	r2,32(fp)
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     5a4:	e0000915 	stw	zero,36(fp)

  /*
   * When running in a multi threaded environment, obtain the "write_lock"
   * semaphore. This ensures that writing to the device is thread-safe.
   */
  ALT_SEM_PEND (dev->write_lock, 0);

  do
  {
    /* Copy as much as we can into the transmit buffer */
    while (count > 0)
     5a8:	e0800217 	ldw	r2,8(fp)
     5ac:	10800050 	cmplti	r2,r2,1
     5b0:	10003a1e 	bne	r2,zero,69c <alt_avalon_jtag_uart_write+0x12c>
    {
      /* We need a stable value of the out pointer to calculate the space available */
      in  = dev->tx_in;
     5b4:	e0800717 	ldw	r2,28(fp)
     5b8:	10801617 	ldw	r2,88(r2)
     5bc:	e0800315 	stw	r2,12(fp)
      out = dev->tx_out;
     5c0:	e0800717 	ldw	r2,28(fp)
     5c4:	10801717 	ldw	r2,92(r2)
     5c8:	e0800415 	stw	r2,16(fp)

      if (in < out)
     5cc:	e0c00317 	ldw	r3,12(fp)
     5d0:	e0800417 	ldw	r2,16(fp)
     5d4:	1880062e 	bgeu	r3,r2,5f0 <alt_avalon_jtag_uart_write+0x80>
        n = out - 1 - in;
     5d8:	e0c00417 	ldw	r3,16(fp)
     5dc:	e0800317 	ldw	r2,12(fp)
     5e0:	1885c83a 	sub	r2,r3,r2
     5e4:	10bfffc4 	addi	r2,r2,-1
     5e8:	e0800515 	stw	r2,20(fp)
     5ec:	00000c06 	br	620 <alt_avalon_jtag_uart_write+0xb0>
      else if (out > 0)
     5f0:	e0800417 	ldw	r2,16(fp)
     5f4:	1005003a 	cmpeq	r2,r2,zero
     5f8:	1000051e 	bne	r2,zero,610 <alt_avalon_jtag_uart_write+0xa0>
        n = ALT_AVALON_JTAG_UART_BUF_LEN - in;
     5fc:	00820004 	movi	r2,2048
     600:	e0c00317 	ldw	r3,12(fp)
     604:	10c5c83a 	sub	r2,r2,r3
     608:	e0800515 	stw	r2,20(fp)
     60c:	00000406 	br	620 <alt_avalon_jtag_uart_write+0xb0>
      else
        n = ALT_AVALON_JTAG_UART_BUF_LEN - 1 - in;
     610:	0081ffc4 	movi	r2,2047
     614:	e0c00317 	ldw	r3,12(fp)
     618:	10c5c83a 	sub	r2,r2,r3
     61c:	e0800515 	stw	r2,20(fp)

      if (n == 0)
     620:	e0800517 	ldw	r2,20(fp)
     624:	1004c03a 	cmpne	r2,r2,zero
     628:	1000011e 	bne	r2,zero,630 <alt_avalon_jtag_uart_write+0xc0>
        break;
     62c:	00001b06 	br	69c <alt_avalon_jtag_uart_write+0x12c>

      if (n > count)
     630:	e0c00217 	ldw	r3,8(fp)
     634:	e0800517 	ldw	r2,20(fp)
     638:	1880022e 	bgeu	r3,r2,644 <alt_avalon_jtag_uart_write+0xd4>
        n = count;
     63c:	e0800217 	ldw	r2,8(fp)
     640:	e0800515 	stw	r2,20(fp)

      memcpy(dev->tx_buf + in, ptr, n);
     644:	e0c00717 	ldw	r3,28(fp)
     648:	e0800317 	ldw	r2,12(fp)
     64c:	1885883a 	add	r2,r3,r2
     650:	11021804 	addi	r4,r2,2144
     654:	e1400117 	ldw	r5,4(fp)
     658:	e1800517 	ldw	r6,20(fp)
     65c:	00022700 	call	2270 <memcpy>
      ptr   += n;
     660:	e0c00117 	ldw	r3,4(fp)
     664:	e0800517 	ldw	r2,20(fp)
     668:	1885883a 	add	r2,r3,r2
     66c:	e0800115 	stw	r2,4(fp)
      count -= n;
     670:	e0c00217 	ldw	r3,8(fp)
     674:	e0800517 	ldw	r2,20(fp)
     678:	1885c83a 	sub	r2,r3,r2
     67c:	e0800215 	stw	r2,8(fp)

      dev->tx_in = (in + n) % ALT_AVALON_JTAG_UART_BUF_LEN;
     680:	e1000717 	ldw	r4,28(fp)
     684:	e0c00317 	ldw	r3,12(fp)
     688:	e0800517 	ldw	r2,20(fp)
     68c:	1885883a 	add	r2,r3,r2
     690:	1081ffcc 	andi	r2,r2,2047
     694:	20801615 	stw	r2,88(r4)
     698:	003fc306 	br	5a8 <alt_avalon_jtag_uart_write+0x38>
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
     69c:	0005303a 	rdctl	r2,status
     6a0:	e0800b15 	stw	r2,44(fp)
  NIOS2_WRITE_STATUS (0);
     6a4:	0001703a 	wrctl	status,zero
     6a8:	e0800b17 	ldw	r2,44(fp)
     6ac:	e0800a15 	stw	r2,40(fp)
     6b0:	e0800a17 	ldw	r2,40(fp)
     6b4:	e0800615 	stw	r2,24(fp)
    }

    /*
     * TODO: if interrupts are disabled then we could transmit here, we only need to enable
     * interrupts if there is no space left in the FIFO
     */

    /* For now kick the interrupt routine every time to make it transmit the data */
    context = alt_irq_disable_all();
    dev->irq_enable |= ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK;
     6b8:	e0c00717 	ldw	r3,28(fp)
     6bc:	e0800717 	ldw	r2,28(fp)
     6c0:	10801217 	ldw	r2,72(r2)
     6c4:	10800094 	ori	r2,r2,2
     6c8:	18801215 	stw	r2,72(r3)
    IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(dev->base, dev->irq_enable);
     6cc:	e0800717 	ldw	r2,28(fp)
     6d0:	10800a17 	ldw	r2,40(r2)
     6d4:	10800104 	addi	r2,r2,4
     6d8:	1007883a 	mov	r3,r2
     6dc:	e0800717 	ldw	r2,28(fp)
     6e0:	10801217 	ldw	r2,72(r2)
     6e4:	18800035 	stwio	r2,0(r3)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_enable_all (alt_irq_context context)
{
     6e8:	e0800617 	ldw	r2,24(fp)
     6ec:	e0800b15 	stw	r2,44(fp)
  NIOS2_WRITE_STATUS (context);
     6f0:	e0800b17 	ldw	r2,44(fp)
     6f4:	1001703a 	wrctl	status,r2
    alt_irq_enable_all(context);

    /* If there is any data left then either return now or block until some has been sent */
    /* TODO: test whether there is anything there while doing this and delay for at most 2s. */
    if (count > 0)
     6f8:	e0800217 	ldw	r2,8(fp)
     6fc:	10800050 	cmplti	r2,r2,1
     700:	1000161e 	bne	r2,zero,75c <alt_avalon_jtag_uart_write+0x1ec>
    {
      if (fd->fd_flags & O_NONBLOCK)
     704:	e0800017 	ldw	r2,0(fp)
     708:	10800217 	ldw	r2,8(r2)
     70c:	1004d3ba 	srli	r2,r2,14
     710:	1080004c 	andi	r2,r2,1
     714:	1005003a 	cmpeq	r2,r2,zero
     718:	1000011e 	bne	r2,zero,720 <alt_avalon_jtag_uart_write+0x1b0>
        break;
     71c:	00001306 	br	76c <alt_avalon_jtag_uart_write+0x1fc>

      /* TODO: in the multi-threaded context this should be waiting on an event */

      /* Wait for data to be removed from buffer.  Once the interrupt routine
      ** has removed some data then we will be able to insert some more. */
      while (out == dev->tx_out && dev->host_inactive < dev->timeout)
     720:	e0800717 	ldw	r2,28(fp)
     724:	10c01717 	ldw	r3,92(r2)
     728:	e0800417 	ldw	r2,16(fp)
     72c:	1880061e 	bne	r3,r2,748 <alt_avalon_jtag_uart_write+0x1d8>
     730:	e0800717 	ldw	r2,28(fp)
     734:	e0c00717 	ldw	r3,28(fp)
     738:	11001317 	ldw	r4,76(r2)
     73c:	18800b17 	ldw	r2,44(r3)
     740:	2080012e 	bgeu	r4,r2,748 <alt_avalon_jtag_uart_write+0x1d8>
     744:	003ff606 	br	720 <alt_avalon_jtag_uart_write+0x1b0>
        ;

      if (out == dev->tx_out)
     748:	e0800717 	ldw	r2,28(fp)
     74c:	10c01717 	ldw	r3,92(r2)
     750:	e0800417 	ldw	r2,16(fp)
     754:	1880011e 	bne	r3,r2,75c <alt_avalon_jtag_uart_write+0x1ec>
        break;
     758:	00000406 	br	76c <alt_avalon_jtag_uart_write+0x1fc>
    }
  }
     75c:	e0800217 	ldw	r2,8(fp)
     760:	10800050 	cmplti	r2,r2,1
     764:	1000011e 	bne	r2,zero,76c <alt_avalon_jtag_uart_write+0x1fc>
     768:	003f8f06 	br	5a8 <alt_avalon_jtag_uart_write+0x38>
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     76c:	e0000b15 	stw	zero,44(fp)
  while (count > 0);

  /*
   * Now that access to the circular buffer is complete, release the write
   * semaphore so that other threads can access the buffer.
   */
  ALT_SEM_POST (dev->write_lock);

  if (ptr != start)
     770:	e0c00117 	ldw	r3,4(fp)
     774:	e0800817 	ldw	r2,32(fp)
     778:	18800526 	beq	r3,r2,790 <alt_avalon_jtag_uart_write+0x220>
    return ptr - start;
     77c:	e0800117 	ldw	r2,4(fp)
     780:	e0c00817 	ldw	r3,32(fp)
     784:	10c5c83a 	sub	r2,r2,r3
     788:	e0800c15 	stw	r2,48(fp)
     78c:	00000b06 	br	7bc <alt_avalon_jtag_uart_write+0x24c>
  else if (fd->fd_flags & O_NONBLOCK)
     790:	e0800017 	ldw	r2,0(fp)
     794:	10800217 	ldw	r2,8(r2)
     798:	1004d3ba 	srli	r2,r2,14
     79c:	1080004c 	andi	r2,r2,1
     7a0:	1005003a 	cmpeq	r2,r2,zero
     7a4:	1000031e 	bne	r2,zero,7b4 <alt_avalon_jtag_uart_write+0x244>
    return -EWOULDBLOCK;
     7a8:	00bffd44 	movi	r2,-11
     7ac:	e0800c15 	stw	r2,48(fp)
     7b0:	00000206 	br	7bc <alt_avalon_jtag_uart_write+0x24c>
  else
    return -EIO; /* Host not connected */
     7b4:	00bffec4 	movi	r2,-5
     7b8:	e0800c15 	stw	r2,48(fp)
}
     7bc:	e0800c17 	ldw	r2,48(fp)
     7c0:	dfc00e17 	ldw	ra,56(sp)
     7c4:	df000d17 	ldw	fp,52(sp)
     7c8:	dec00f04 	addi	sp,sp,60
     7cc:	f800283a 	ret

000007d0 <alt_avalon_jtag_uart_irq>:

/*
 * Interrupt routine
 */ 

static void alt_avalon_jtag_uart_irq(void* context, alt_u32 id)
{
     7d0:	defff804 	addi	sp,sp,-32
     7d4:	df000715 	stw	fp,28(sp)
     7d8:	d839883a 	mov	fp,sp
     7dc:	e1000015 	stw	r4,0(fp)
     7e0:	e1400115 	stw	r5,4(fp)
  alt_avalon_jtag_uart_dev* dev = (alt_avalon_jtag_uart_dev*) context;
     7e4:	e0800017 	ldw	r2,0(fp)
     7e8:	e0800215 	stw	r2,8(fp)
  unsigned int base = dev->base;
     7ec:	e0800217 	ldw	r2,8(fp)
     7f0:	10800a17 	ldw	r2,40(r2)
     7f4:	e0800315 	stw	r2,12(fp)

  /* TODO: turn on events where appropriate */

  for ( ; ; )
  {
    unsigned int control = IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base);
     7f8:	e0800317 	ldw	r2,12(fp)
     7fc:	10800104 	addi	r2,r2,4
     800:	10800037 	ldwio	r2,0(r2)
     804:	e0800415 	stw	r2,16(fp)

    /* Return once nothing more to do */
    if ((control & (ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK | ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK)) == 0)
     808:	e0800417 	ldw	r2,16(fp)
     80c:	1080c00c 	andi	r2,r2,768
     810:	1004c03a 	cmpne	r2,r2,zero
     814:	1000011e 	bne	r2,zero,81c <alt_avalon_jtag_uart_irq+0x4c>
      break;
     818:	00006e06 	br	9d4 <alt_avalon_jtag_uart_irq+0x204>

    if (control & ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK)
     81c:	e0800417 	ldw	r2,16(fp)
     820:	1004d23a 	srli	r2,r2,8
     824:	1080004c 	andi	r2,r2,1
     828:	1005003a 	cmpeq	r2,r2,zero
     82c:	1000351e 	bne	r2,zero,904 <alt_avalon_jtag_uart_irq+0x134>
    {
      /* process a read irq.  Start by assuming that there is data in the
       * receive FIFO (otherwise why would we have been interrupted?)
       */
      unsigned int data = 1 << ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_OFST;
     830:	00800074 	movhi	r2,1
     834:	10800004 	addi	r2,r2,0
     838:	e0800515 	stw	r2,20(fp)

      for ( ; ; )
      {
        /* Check whether there is space in the buffer.  If not then we must not
         * read any characters from the buffer as they will be lost.
         */
        unsigned int next = (dev->rx_in + 1) % ALT_AVALON_JTAG_UART_BUF_LEN;
     83c:	e0800217 	ldw	r2,8(fp)
     840:	10801417 	ldw	r2,80(r2)
     844:	10800044 	addi	r2,r2,1
     848:	1081ffcc 	andi	r2,r2,2047
     84c:	e0800615 	stw	r2,24(fp)
        if (next == dev->rx_out)
     850:	e0800217 	ldw	r2,8(fp)
     854:	10c01517 	ldw	r3,84(r2)
     858:	e0800617 	ldw	r2,24(fp)
     85c:	1880011e 	bne	r3,r2,864 <alt_avalon_jtag_uart_irq+0x94>
          break;
     860:	00001806 	br	8c4 <alt_avalon_jtag_uart_irq+0xf4>

        /* Try to remove a character from the FIFO and find out whether there
         * are any more characters remaining.
         */
        data = IORD_ALTERA_AVALON_JTAG_UART_DATA(base);
     864:	e0800317 	ldw	r2,12(fp)
     868:	10800037 	ldwio	r2,0(r2)
     86c:	e0800515 	stw	r2,20(fp)
        
        if ((data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK) == 0)
     870:	e0800517 	ldw	r2,20(fp)
     874:	1004d3fa 	srli	r2,r2,15
     878:	1080005c 	xori	r2,r2,1
     87c:	1080004c 	andi	r2,r2,1
     880:	1005003a 	cmpeq	r2,r2,zero
     884:	1000011e 	bne	r2,zero,88c <alt_avalon_jtag_uart_irq+0xbc>
          break;
     888:	00000e06 	br	8c4 <alt_avalon_jtag_uart_irq+0xf4>

        dev->rx_buf[dev->rx_in] = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK) >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
     88c:	e0c00217 	ldw	r3,8(fp)
     890:	e0800217 	ldw	r2,8(fp)
     894:	10801417 	ldw	r2,80(r2)
     898:	1885883a 	add	r2,r3,r2
     89c:	10c01804 	addi	r3,r2,96
     8a0:	e0800517 	ldw	r2,20(fp)
     8a4:	18800005 	stb	r2,0(r3)
        dev->rx_in = (dev->rx_in + 1) % ALT_AVALON_JTAG_UART_BUF_LEN;
     8a8:	e0c00217 	ldw	r3,8(fp)
     8ac:	e0800217 	ldw	r2,8(fp)
     8b0:	10801417 	ldw	r2,80(r2)
     8b4:	10800044 	addi	r2,r2,1
     8b8:	1081ffcc 	andi	r2,r2,2047
     8bc:	18801415 	stw	r2,80(r3)
     8c0:	003fde06 	br	83c <alt_avalon_jtag_uart_irq+0x6c>
      }

      if (data & ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_MSK)
     8c4:	e0800517 	ldw	r2,20(fp)
     8c8:	10bfffec 	andhi	r2,r2,65535
     8cc:	1005003a 	cmpeq	r2,r2,zero
     8d0:	10000c1e 	bne	r2,zero,904 <alt_avalon_jtag_uart_irq+0x134>
      {
        /* If there is still data available here then the buffer is full 
         * so turn off receive interrupts until some space becomes available.
         */
        dev->irq_enable &= ~ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK;
     8d4:	e1000217 	ldw	r4,8(fp)
     8d8:	e0800217 	ldw	r2,8(fp)
     8dc:	10c01217 	ldw	r3,72(r2)
     8e0:	00bfff84 	movi	r2,-2
     8e4:	1884703a 	and	r2,r3,r2
     8e8:	20801215 	stw	r2,72(r4)
        IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, dev->irq_enable);
     8ec:	e0800317 	ldw	r2,12(fp)
     8f0:	10800104 	addi	r2,r2,4
     8f4:	1007883a 	mov	r3,r2
     8f8:	e0800217 	ldw	r2,8(fp)
     8fc:	10801217 	ldw	r2,72(r2)
     900:	18800035 	stwio	r2,0(r3)
      }
    }

    if (control & ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK)
     904:	e0800417 	ldw	r2,16(fp)
     908:	1004d27a 	srli	r2,r2,9
     90c:	1080004c 	andi	r2,r2,1
     910:	1005003a 	cmpeq	r2,r2,zero
     914:	103fb81e 	bne	r2,zero,7f8 <alt_avalon_jtag_uart_irq+0x28>
    {
      /* process a write irq */
      unsigned int space = (control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) >> ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST;
     918:	e0800417 	ldw	r2,16(fp)
     91c:	10bfffec 	andhi	r2,r2,65535
     920:	1004d43a 	srli	r2,r2,16
     924:	e0800615 	stw	r2,24(fp)

      while (space > 0 && dev->tx_out != dev->tx_in)
     928:	e0800617 	ldw	r2,24(fp)
     92c:	1005003a 	cmpeq	r2,r2,zero
     930:	1000171e 	bne	r2,zero,990 <alt_avalon_jtag_uart_irq+0x1c0>
     934:	e0800217 	ldw	r2,8(fp)
     938:	e0c00217 	ldw	r3,8(fp)
     93c:	11001717 	ldw	r4,92(r2)
     940:	18801617 	ldw	r2,88(r3)
     944:	20801226 	beq	r4,r2,990 <alt_avalon_jtag_uart_irq+0x1c0>
      {
        IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, dev->tx_buf[dev->tx_out]);
     948:	e1000317 	ldw	r4,12(fp)
     94c:	e0c00217 	ldw	r3,8(fp)
     950:	e0800217 	ldw	r2,8(fp)
     954:	10801717 	ldw	r2,92(r2)
     958:	1885883a 	add	r2,r3,r2
     95c:	10821804 	addi	r2,r2,2144
     960:	10800007 	ldb	r2,0(r2)
     964:	20800035 	stwio	r2,0(r4)

        dev->tx_out = (dev->tx_out + 1) % ALT_AVALON_JTAG_UART_BUF_LEN;
     968:	e0c00217 	ldw	r3,8(fp)
     96c:	e0800217 	ldw	r2,8(fp)
     970:	10801717 	ldw	r2,92(r2)
     974:	10800044 	addi	r2,r2,1
     978:	1081ffcc 	andi	r2,r2,2047
     97c:	18801715 	stw	r2,92(r3)
        space--;
     980:	e0800617 	ldw	r2,24(fp)
     984:	10bfffc4 	addi	r2,r2,-1
     988:	e0800615 	stw	r2,24(fp)
     98c:	003fe606 	br	928 <alt_avalon_jtag_uart_irq+0x158>
      }

      if (space > 0)
     990:	e0800617 	ldw	r2,24(fp)
     994:	1005003a 	cmpeq	r2,r2,zero
     998:	103f971e 	bne	r2,zero,7f8 <alt_avalon_jtag_uart_irq+0x28>
      {
        /* If we don't have any more data available then turn off the TX interrupt */

        dev->irq_enable &= ~ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK;
     99c:	e1000217 	ldw	r4,8(fp)
     9a0:	e0800217 	ldw	r2,8(fp)
     9a4:	10c01217 	ldw	r3,72(r2)
     9a8:	00bfff44 	movi	r2,-3
     9ac:	1884703a 	and	r2,r3,r2
     9b0:	20801215 	stw	r2,72(r4)
        IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(dev->base, dev->irq_enable);
     9b4:	e0800217 	ldw	r2,8(fp)
     9b8:	10800a17 	ldw	r2,40(r2)
     9bc:	10800104 	addi	r2,r2,4
     9c0:	1007883a 	mov	r3,r2
     9c4:	e0800217 	ldw	r2,8(fp)
     9c8:	10801217 	ldw	r2,72(r2)
     9cc:	18800035 	stwio	r2,0(r3)
     9d0:	003f8906 	br	7f8 <alt_avalon_jtag_uart_irq+0x28>
      }
    }
  }
}
     9d4:	df000717 	ldw	fp,28(sp)
     9d8:	dec00804 	addi	sp,sp,32
     9dc:	f800283a 	ret

000009e0 <alt_avalon_jtag_uart_ioctl>:

/*
 *
 */

int alt_avalon_jtag_uart_ioctl (alt_fd* fd, int req, void* arg)
{
     9e0:	defff604 	addi	sp,sp,-40
     9e4:	df000915 	stw	fp,36(sp)
     9e8:	d839883a 	mov	fp,sp
     9ec:	e1000015 	stw	r4,0(fp)
     9f0:	e1400115 	stw	r5,4(fp)
     9f4:	e1800215 	stw	r6,8(fp)
  alt_avalon_jtag_uart_dev* dev = (alt_avalon_jtag_uart_dev*) fd->dev;
     9f8:	e0800017 	ldw	r2,0(fp)
     9fc:	10800017 	ldw	r2,0(r2)
     a00:	e0800315 	stw	r2,12(fp)
  int rc = -ENOTTY;
     a04:	00bff9c4 	movi	r2,-25
     a08:	e0800415 	stw	r2,16(fp)

  switch (req)
     a0c:	e0800117 	ldw	r2,4(fp)
     a10:	e0800815 	stw	r2,32(fp)
     a14:	e0c00817 	ldw	r3,32(fp)
     a18:	189a8060 	cmpeqi	r2,r3,27137
     a1c:	1000041e 	bne	r2,zero,a30 <alt_avalon_jtag_uart_ioctl+0x50>
     a20:	e0c00817 	ldw	r3,32(fp)
     a24:	189a80a0 	cmpeqi	r2,r3,27138
     a28:	10001d1e 	bne	r2,zero,aa0 <alt_avalon_jtag_uart_ioctl+0xc0>
     a2c:	00002906 	br	ad4 <alt_avalon_jtag_uart_ioctl+0xf4>
  {
  case TIOCSTIMEOUT:
    /* Set the time to wait until assuming host is not connected */
    if (dev->timeout != INT_MAX)
     a30:	e0800317 	ldw	r2,12(fp)
     a34:	10c00b17 	ldw	r3,44(r2)
     a38:	00a00034 	movhi	r2,32768
     a3c:	10bfffc4 	addi	r2,r2,-1
     a40:	18802426 	beq	r3,r2,ad4 <alt_avalon_jtag_uart_ioctl+0xf4>
    {
      int timeout = *((int *)arg);
     a44:	e0800217 	ldw	r2,8(fp)
     a48:	10800017 	ldw	r2,0(r2)
     a4c:	e0800515 	stw	r2,20(fp)
      dev->timeout = (timeout >= 2 && timeout < INT_MAX) ? timeout : INT_MAX - 1;
     a50:	e0800317 	ldw	r2,12(fp)
     a54:	e0800615 	stw	r2,24(fp)
     a58:	e0800517 	ldw	r2,20(fp)
     a5c:	10800090 	cmplti	r2,r2,2
     a60:	1000071e 	bne	r2,zero,a80 <alt_avalon_jtag_uart_ioctl+0xa0>
     a64:	e0c00517 	ldw	r3,20(fp)
     a68:	00a00034 	movhi	r2,32768
     a6c:	10bfffc4 	addi	r2,r2,-1
     a70:	18800326 	beq	r3,r2,a80 <alt_avalon_jtag_uart_ioctl+0xa0>
     a74:	e0c00517 	ldw	r3,20(fp)
     a78:	e0c00715 	stw	r3,28(fp)
     a7c:	00000306 	br	a8c <alt_avalon_jtag_uart_ioctl+0xac>
     a80:	00a00034 	movhi	r2,32768
     a84:	10bfff84 	addi	r2,r2,-2
     a88:	e0800715 	stw	r2,28(fp)
     a8c:	e0c00717 	ldw	r3,28(fp)
     a90:	e0800617 	ldw	r2,24(fp)
     a94:	10c00b15 	stw	r3,44(r2)
      rc = 0;
     a98:	e0000415 	stw	zero,16(fp)
    }
    break;
     a9c:	00000d06 	br	ad4 <alt_avalon_jtag_uart_ioctl+0xf4>

  case TIOCGCONNECTED:
    /* Find out whether host is connected */
    if (dev->timeout != INT_MAX)
     aa0:	e0800317 	ldw	r2,12(fp)
     aa4:	10c00b17 	ldw	r3,44(r2)
     aa8:	00a00034 	movhi	r2,32768
     aac:	10bfffc4 	addi	r2,r2,-1
     ab0:	18800826 	beq	r3,r2,ad4 <alt_avalon_jtag_uart_ioctl+0xf4>
    {
      *((int *)arg) = (dev->host_inactive < dev->timeout) ? 1 : 0;
     ab4:	e1400217 	ldw	r5,8(fp)
     ab8:	e0800317 	ldw	r2,12(fp)
     abc:	e0c00317 	ldw	r3,12(fp)
     ac0:	11001317 	ldw	r4,76(r2)
     ac4:	18800b17 	ldw	r2,44(r3)
     ac8:	2085803a 	cmpltu	r2,r4,r2
     acc:	28800015 	stw	r2,0(r5)
      rc = 0;
     ad0:	e0000415 	stw	zero,16(fp)
    }
    break;

  default:
    break;
  }

  return rc;
     ad4:	e0800417 	ldw	r2,16(fp)
}
     ad8:	df000917 	ldw	fp,36(sp)
     adc:	dec00a04 	addi	sp,sp,40
     ae0:	f800283a 	ret

00000ae4 <alt_avalon_jtag_uart_timeout>:


/*
 * Timeout routine is called every second
 */

alt_u32 alt_avalon_jtag_uart_timeout(void * context) 
{
     ae4:	defffb04 	addi	sp,sp,-20
     ae8:	df000415 	stw	fp,16(sp)
     aec:	d839883a 	mov	fp,sp
     af0:	e1000015 	stw	r4,0(fp)
  unsigned int control;

  alt_avalon_jtag_uart_dev* dev = (alt_avalon_jtag_uart_dev *) context;
     af4:	e0800017 	ldw	r2,0(fp)
     af8:	e0800215 	stw	r2,8(fp)

  control = IORD_ALTERA_AVALON_JTAG_UART_CONTROL(dev->base);
     afc:	e0800217 	ldw	r2,8(fp)
     b00:	10800a17 	ldw	r2,40(r2)
     b04:	10800104 	addi	r2,r2,4
     b08:	10800037 	ldwio	r2,0(r2)
     b0c:	e0800115 	stw	r2,4(fp)

  if (control & ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK)
     b10:	e0800117 	ldw	r2,4(fp)
     b14:	1004d2ba 	srli	r2,r2,10
     b18:	1080004c 	andi	r2,r2,1
     b1c:	1005003a 	cmpeq	r2,r2,zero
     b20:	10000b1e 	bne	r2,zero,b50 <alt_avalon_jtag_uart_timeout+0x6c>
  {
    IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(dev->base, dev->irq_enable | ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK);
     b24:	e0800217 	ldw	r2,8(fp)
     b28:	10800a17 	ldw	r2,40(r2)
     b2c:	10800104 	addi	r2,r2,4
     b30:	1007883a 	mov	r3,r2
     b34:	e0800217 	ldw	r2,8(fp)
     b38:	10801217 	ldw	r2,72(r2)
     b3c:	10810014 	ori	r2,r2,1024
     b40:	18800035 	stwio	r2,0(r3)
    dev->host_inactive = 0;
     b44:	e0800217 	ldw	r2,8(fp)
     b48:	10001315 	stw	zero,76(r2)
     b4c:	00000a06 	br	b78 <alt_avalon_jtag_uart_timeout+0x94>
  }
  else if (dev->host_inactive < INT_MAX - 2)
     b50:	e0800217 	ldw	r2,8(fp)
     b54:	10c01317 	ldw	r3,76(r2)
     b58:	00a00034 	movhi	r2,32768
     b5c:	10bfff04 	addi	r2,r2,-4
     b60:	10c00536 	bltu	r2,r3,b78 <alt_avalon_jtag_uart_timeout+0x94>
    dev->host_inactive++;
     b64:	e0c00217 	ldw	r3,8(fp)
     b68:	e0800217 	ldw	r2,8(fp)
     b6c:	10801317 	ldw	r2,76(r2)
     b70:	10800044 	addi	r2,r2,1
     b74:	18801315 	stw	r2,76(r3)
 */

static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void)
{
  return _alt_tick_rate;
     b78:	d0a00b17 	ldw	r2,-32724(gp)
     b7c:	e0800315 	stw	r2,12(fp)
     b80:	e0800317 	ldw	r2,12(fp)

  return alt_ticks_per_second();
}
     b84:	df000417 	ldw	fp,16(sp)
     b88:	dec00504 	addi	sp,sp,20
     b8c:	f800283a 	ret

00000b90 <alt_avalon_jtag_uart_init>:

/* Driver initialisation code.  Register interrupts and start a timer
 * which we can use to check whether the host is there.
 */

void alt_avalon_jtag_uart_init(alt_avalon_jtag_uart_dev* dev, int base, int irq)
{
     b90:	defff704 	addi	sp,sp,-36
     b94:	dfc00815 	stw	ra,32(sp)
     b98:	df000715 	stw	fp,28(sp)
     b9c:	d839883a 	mov	fp,sp
     ba0:	e1000015 	stw	r4,0(fp)
     ba4:	e1400115 	stw	r5,4(fp)
     ba8:	e1800215 	stw	r6,8(fp)
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
     bac:	e0000315 	stw	zero,12(fp)
     bb0:	e0000415 	stw	zero,16(fp)
     bb4:	e0000515 	stw	zero,20(fp)
  ALT_FLAG_CREATE(&dev->events, 0);
  ALT_SEM_CREATE(&dev->read_lock, 1);
  ALT_SEM_CREATE(&dev->write_lock, 1);

  /* enable read interrupts at the device */
  dev->irq_enable = ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK;
     bb8:	e0c00017 	ldw	r3,0(fp)
     bbc:	00800044 	movi	r2,1
     bc0:	18801215 	stw	r2,72(r3)

  IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, dev->irq_enable); 
     bc4:	e0800117 	ldw	r2,4(fp)
     bc8:	10800104 	addi	r2,r2,4
     bcc:	1007883a 	mov	r3,r2
     bd0:	e0800017 	ldw	r2,0(fp)
     bd4:	10801217 	ldw	r2,72(r2)
     bd8:	18800035 	stwio	r2,0(r3)
  
  /* register the interrupt handler */
  if (alt_irq_register(irq, dev, alt_avalon_jtag_uart_irq) >= 0)
     bdc:	e1000217 	ldw	r4,8(fp)
     be0:	e1400017 	ldw	r5,0(fp)
     be4:	01800034 	movhi	r6,0
     be8:	3181f404 	addi	r6,r6,2000
     bec:	00011840 	call	1184 <alt_irq_register>
     bf0:	1004803a 	cmplt	r2,r2,zero
     bf4:	1000021e 	bne	r2,zero,c00 <alt_avalon_jtag_uart_init+0x70>
  {
    /* make the device available to the system */
    alt_dev_reg(&dev->dev);
     bf8:	e1000017 	ldw	r4,0(fp)
     bfc:	0000c540 	call	c54 <alt_dev_reg>
  }

  /* Register an alarm to go off every second to check for presence of host */
  dev->host_inactive = 0;
     c00:	e0800017 	ldw	r2,0(fp)
     c04:	10001315 	stw	zero,76(r2)
 */

static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void)
{
  return _alt_tick_rate;
     c08:	d0a00b17 	ldw	r2,-32724(gp)
     c0c:	e0800615 	stw	r2,24(fp)
     c10:	e1400617 	ldw	r5,24(fp)
     c14:	e0800017 	ldw	r2,0(fp)
     c18:	11000c04 	addi	r4,r2,48
     c1c:	01800034 	movhi	r6,0
     c20:	3182b904 	addi	r6,r6,2788
     c24:	e1c00017 	ldw	r7,0(fp)
     c28:	0000d380 	call	d38 <alt_alarm_start>
     c2c:	1004403a 	cmpge	r2,r2,zero
     c30:	1000041e 	bne	r2,zero,c44 <alt_avalon_jtag_uart_init+0xb4>

  if (alt_alarm_start(&dev->alarm, alt_ticks_per_second(), &alt_avalon_jtag_uart_timeout, dev) < 0)
  {
    /* If we can't set the alarm then record "don't know if host present" 
     * and behave as though the host is present.
     */
    dev->timeout = INT_MAX;
     c34:	e0c00017 	ldw	r3,0(fp)
     c38:	00a00034 	movhi	r2,32768
     c3c:	10bfffc4 	addi	r2,r2,-1
     c40:	18800b15 	stw	r2,44(r3)
  }
}
     c44:	dfc00817 	ldw	ra,32(sp)
     c48:	df000717 	ldw	fp,28(sp)
     c4c:	dec00904 	addi	sp,sp,36
     c50:	f800283a 	ret

00000c54 <alt_dev_reg>:

extern int alt_fs_reg  (alt_dev* dev); 

static ALT_INLINE int alt_dev_reg (alt_dev* dev)
{
     c54:	defffd04 	addi	sp,sp,-12
     c58:	dfc00215 	stw	ra,8(sp)
     c5c:	df000115 	stw	fp,4(sp)
     c60:	d839883a 	mov	fp,sp
     c64:	e1000015 	stw	r4,0(fp)
  extern alt_llist alt_dev_list;

  return alt_dev_llist_insert ((alt_dev_llist*) dev, &alt_dev_list);
     c68:	e1000017 	ldw	r4,0(fp)
     c6c:	d1600504 	addi	r5,gp,-32748
     c70:	0000ea80 	call	ea8 <alt_dev_llist_insert>
}
     c74:	dfc00217 	ldw	ra,8(sp)
     c78:	df000117 	ldw	fp,4(sp)
     c7c:	dec00304 	addi	sp,sp,12
     c80:	f800283a 	ret

00000c84 <alt_avalon_timer_sc_irq>:
 * alarms, see alt_tick.c for further details.
 */

static void alt_avalon_timer_sc_irq (void* base, alt_u32 id)
{
     c84:	defffc04 	addi	sp,sp,-16
     c88:	dfc00315 	stw	ra,12(sp)
     c8c:	df000215 	stw	fp,8(sp)
     c90:	d839883a 	mov	fp,sp
     c94:	e1000015 	stw	r4,0(fp)
     c98:	e1400115 	stw	r5,4(fp)
  /* clear the interrupt */

  IOWR_ALTERA_AVALON_TIMER_STATUS (base, 0);
     c9c:	e0800017 	ldw	r2,0(fp)
     ca0:	10000035 	stwio	zero,0(r2)

  /* notify the system of a clock tick */

  alt_tick ();
     ca4:	00016800 	call	1680 <alt_tick>
}
     ca8:	dfc00317 	ldw	ra,12(sp)
     cac:	df000217 	ldw	fp,8(sp)
     cb0:	dec00404 	addi	sp,sp,16
     cb4:	f800283a 	ret

00000cb8 <alt_avalon_timer_sc_init>:

/*
 * alt_avalon_timer_sc_init() is called to initialise the timer that will be 
 * used to provide the periodic system clock. This is called from the 
 * auto-generated alt_sys_init() function.
 */

void alt_avalon_timer_sc_init (void* base, alt_u32 irq, alt_u32 freq)
{
     cb8:	defff904 	addi	sp,sp,-28
     cbc:	dfc00615 	stw	ra,24(sp)
     cc0:	df000515 	stw	fp,20(sp)
     cc4:	d839883a 	mov	fp,sp
     cc8:	e1000015 	stw	r4,0(fp)
     ccc:	e1400115 	stw	r5,4(fp)
     cd0:	e1800215 	stw	r6,8(fp)
 * in order to initialise the value of the clock frequency.
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_sysclk_init (alt_u32 nticks)
{
     cd4:	e0800217 	ldw	r2,8(fp)
     cd8:	e0800315 	stw	r2,12(fp)
  if (! _alt_tick_rate)
     cdc:	d0a00b17 	ldw	r2,-32724(gp)
     ce0:	1004c03a 	cmpne	r2,r2,zero
     ce4:	1000041e 	bne	r2,zero,cf8 <alt_avalon_timer_sc_init+0x40>
  {
    _alt_tick_rate = nticks;
     ce8:	e0800317 	ldw	r2,12(fp)
     cec:	d0a00b15 	stw	r2,-32724(gp)
     cf0:	e0000415 	stw	zero,16(fp)
     cf4:	00000206 	br	d00 <alt_avalon_timer_sc_init+0x48>
    return 0;
  }
  else
  {
    return -1;
     cf8:	00bfffc4 	movi	r2,-1
     cfc:	e0800415 	stw	r2,16(fp)
  /* set the system clock frequency */
  
  alt_sysclk_init (freq);
  
  /* set to free running mode */
  
  IOWR_ALTERA_AVALON_TIMER_CONTROL (base, 
     d00:	e0800017 	ldw	r2,0(fp)
     d04:	10800104 	addi	r2,r2,4
     d08:	1007883a 	mov	r3,r2
     d0c:	008001c4 	movi	r2,7
     d10:	18800035 	stwio	r2,0(r3)
            ALTERA_AVALON_TIMER_CONTROL_ITO_MSK  |
            ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
            ALTERA_AVALON_TIMER_CONTROL_START_MSK);

  /* register the interrupt handler, and enable the interrupt */
    
  alt_irq_register (irq, base, alt_avalon_timer_sc_irq);    
     d14:	e1000117 	ldw	r4,4(fp)
     d18:	e1400017 	ldw	r5,0(fp)
     d1c:	01800034 	movhi	r6,0
     d20:	31832104 	addi	r6,r6,3204
     d24:	00011840 	call	1184 <alt_irq_register>
}
     d28:	dfc00617 	ldw	ra,24(sp)
     d2c:	df000517 	ldw	fp,20(sp)
     d30:	dec00704 	addi	sp,sp,28
     d34:	f800283a 	ret

00000d38 <alt_alarm_start>:

int alt_alarm_start (alt_alarm* alarm, alt_u32 nticks,
                     alt_u32 (*callback) (void* context),
                     void* context)
{
     d38:	defff504 	addi	sp,sp,-44
     d3c:	df000a15 	stw	fp,40(sp)
     d40:	d839883a 	mov	fp,sp
     d44:	e1000015 	stw	r4,0(fp)
     d48:	e1400115 	stw	r5,4(fp)
     d4c:	e1800215 	stw	r6,8(fp)
     d50:	e1c00315 	stw	r7,12(fp)
  alt_irq_context irq_context;
  alt_u32 current_nticks = 0;
     d54:	e0000515 	stw	zero,20(fp)
 */

static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void)
{
  return _alt_tick_rate;
     d58:	d0a00b17 	ldw	r2,-32724(gp)
     d5c:	e0800615 	stw	r2,24(fp)
     d60:	e0800617 	ldw	r2,24(fp)
     d64:	1005003a 	cmpeq	r2,r2,zero
     d68:	10003f1e 	bne	r2,zero,e68 <alt_alarm_start+0x130>
  
  if (alt_ticks_per_second ())
  {
    if (alarm)
     d6c:	e0800017 	ldw	r2,0(fp)
     d70:	1005003a 	cmpeq	r2,r2,zero
     d74:	1000391e 	bne	r2,zero,e5c <alt_alarm_start+0x124>
    {
      alarm->callback = callback;
     d78:	e0c00017 	ldw	r3,0(fp)
     d7c:	e0800217 	ldw	r2,8(fp)
     d80:	18800315 	stw	r2,12(r3)
      alarm->context  = context;
     d84:	e0c00017 	ldw	r3,0(fp)
     d88:	e0800317 	ldw	r2,12(fp)
     d8c:	18800515 	stw	r2,20(r3)
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
     d90:	0005303a 	rdctl	r2,status
     d94:	e0800815 	stw	r2,32(fp)
  NIOS2_WRITE_STATUS (0);
     d98:	0001703a 	wrctl	status,zero
     d9c:	e0800817 	ldw	r2,32(fp)
     da0:	e0800715 	stw	r2,28(fp)
     da4:	e0800717 	ldw	r2,28(fp)
     da8:	e0800415 	stw	r2,16(fp)
 */

static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_nticks (void)
{
  return _alt_nticks;
     dac:	d0a00c17 	ldw	r2,-32720(gp)
     db0:	e0800815 	stw	r2,32(fp)
     db4:	e0800817 	ldw	r2,32(fp)
     db8:	e0800515 	stw	r2,20(fp)
 
      irq_context = alt_irq_disable_all ();
      
      current_nticks = alt_nticks();
      
      alarm->time = nticks + current_nticks + 1; 
     dbc:	e1000017 	ldw	r4,0(fp)
     dc0:	e0c00117 	ldw	r3,4(fp)
     dc4:	e0800517 	ldw	r2,20(fp)
     dc8:	1885883a 	add	r2,r3,r2
     dcc:	10800044 	addi	r2,r2,1
     dd0:	20800215 	stw	r2,8(r4)
      
      /* 
       * If the desired alarm time causes a roll-over, set the rollover
       * flag. This will prevent the subsequent tick event from causing
       * an alarm too early.
       */
      if(alarm->time < current_nticks)
     dd4:	e0800017 	ldw	r2,0(fp)
     dd8:	10c00217 	ldw	r3,8(r2)
     ddc:	e0800517 	ldw	r2,20(fp)
     de0:	1880042e 	bgeu	r3,r2,df4 <alt_alarm_start+0xbc>
      {
        alarm->rollover = 1;
     de4:	e0c00017 	ldw	r3,0(fp)
     de8:	00800044 	movi	r2,1
     dec:	18800405 	stb	r2,16(r3)
     df0:	00000206 	br	dfc <alt_alarm_start+0xc4>
      }
      else
      {
        alarm->rollover = 0;
     df4:	e0800017 	ldw	r2,0(fp)
     df8:	10000405 	stb	zero,16(r2)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_insert(alt_llist* list, 
                alt_llist* entry)
{
     dfc:	d0a00d04 	addi	r2,gp,-32716
     e00:	e0800815 	stw	r2,32(fp)
     e04:	e0800017 	ldw	r2,0(fp)
     e08:	e0800715 	stw	r2,28(fp)
  entry->previous = list;
     e0c:	e0c00717 	ldw	r3,28(fp)
     e10:	e0800817 	ldw	r2,32(fp)
     e14:	18800115 	stw	r2,4(r3)
  entry->next     = list->next;
     e18:	e0c00717 	ldw	r3,28(fp)
     e1c:	e0800817 	ldw	r2,32(fp)
     e20:	10800017 	ldw	r2,0(r2)
     e24:	18800015 	stw	r2,0(r3)

  list->next->previous = entry;
     e28:	e0800817 	ldw	r2,32(fp)
     e2c:	10c00017 	ldw	r3,0(r2)
     e30:	e0800717 	ldw	r2,28(fp)
     e34:	18800115 	stw	r2,4(r3)
  list->next           = entry;
     e38:	e0c00817 	ldw	r3,32(fp)
     e3c:	e0800717 	ldw	r2,28(fp)
     e40:	18800015 	stw	r2,0(r3)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_enable_all (alt_irq_context context)
{
     e44:	e0800417 	ldw	r2,16(fp)
     e48:	e0800815 	stw	r2,32(fp)
  NIOS2_WRITE_STATUS (context);
     e4c:	e0800817 	ldw	r2,32(fp)
     e50:	1001703a 	wrctl	status,r2
      }
    
      alt_llist_insert (&alt_alarm_list, &alarm->llist);
      alt_irq_enable_all (irq_context);

      return 0;
     e54:	e0000915 	stw	zero,36(fp)
     e58:	00000506 	br	e70 <alt_alarm_start+0x138>
    }
    else
    {
      return -EINVAL;
     e5c:	00bffa84 	movi	r2,-22
     e60:	e0800915 	stw	r2,36(fp)
     e64:	00000206 	br	e70 <alt_alarm_start+0x138>
    }
  }
  else
  {
    return -ENOTSUP;
     e68:	00bfde84 	movi	r2,-134
     e6c:	e0800915 	stw	r2,36(fp)
  }
}
     e70:	e0800917 	ldw	r2,36(fp)
     e74:	df000a17 	ldw	fp,40(sp)
     e78:	dec00b04 	addi	sp,sp,44
     e7c:	f800283a 	ret

00000e80 <alt_dev_null_write>:
 * indicates that the data has been successfully transmitted.
 */

static int alt_dev_null_write (alt_fd* fd, const char* ptr, int len)
{
     e80:	defffc04 	addi	sp,sp,-16
     e84:	df000315 	stw	fp,12(sp)
     e88:	d839883a 	mov	fp,sp
     e8c:	e1000015 	stw	r4,0(fp)
     e90:	e1400115 	stw	r5,4(fp)
     e94:	e1800215 	stw	r6,8(fp)
  return len;
     e98:	e0800217 	ldw	r2,8(fp)
}
     e9c:	df000317 	ldw	fp,12(sp)
     ea0:	dec00404 	addi	sp,sp,16
     ea4:	f800283a 	ret

00000ea8 <alt_dev_llist_insert>:
 *
 */

int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list)
{
     ea8:	defff904 	addi	sp,sp,-28
     eac:	dfc00615 	stw	ra,24(sp)
     eb0:	df000515 	stw	fp,20(sp)
     eb4:	d839883a 	mov	fp,sp
     eb8:	e1000015 	stw	r4,0(fp)
     ebc:	e1400115 	stw	r5,4(fp)
  /*
   * check that the device exists, and that it has a valid name.
   */

  if (!dev || !dev->name)
     ec0:	e0800017 	ldw	r2,0(fp)
     ec4:	1005003a 	cmpeq	r2,r2,zero
     ec8:	1000041e 	bne	r2,zero,edc <alt_dev_llist_insert+0x34>
     ecc:	e0800017 	ldw	r2,0(fp)
     ed0:	10800217 	ldw	r2,8(r2)
     ed4:	1004c03a 	cmpne	r2,r2,zero
     ed8:	1000071e 	bne	r2,zero,ef8 <alt_dev_llist_insert+0x50>
  {
    ALT_ERRNO = EINVAL;
     edc:	0000f580 	call	f58 <alt_get_errno>
     ee0:	1007883a 	mov	r3,r2
     ee4:	00800584 	movi	r2,22
     ee8:	18800015 	stw	r2,0(r3)
    return -EINVAL;
     eec:	00bffa84 	movi	r2,-22
     ef0:	e0800415 	stw	r2,16(fp)
     ef4:	00001306 	br	f44 <alt_dev_llist_insert+0x9c>
 */

static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_insert(alt_llist* list, 
                alt_llist* entry)
{
     ef8:	e0800117 	ldw	r2,4(fp)
     efc:	e0800215 	stw	r2,8(fp)
     f00:	e0800017 	ldw	r2,0(fp)
     f04:	e0800315 	stw	r2,12(fp)
  entry->previous = list;
     f08:	e0c00317 	ldw	r3,12(fp)
     f0c:	e0800217 	ldw	r2,8(fp)
     f10:	18800115 	stw	r2,4(r3)
  entry->next     = list->next;
     f14:	e0c00317 	ldw	r3,12(fp)
     f18:	e0800217 	ldw	r2,8(fp)
     f1c:	10800017 	ldw	r2,0(r2)
     f20:	18800015 	stw	r2,0(r3)

  list->next->previous = entry;
     f24:	e0800217 	ldw	r2,8(fp)
     f28:	10c00017 	ldw	r3,0(r2)
     f2c:	e0800317 	ldw	r2,12(fp)
     f30:	18800115 	stw	r2,4(r3)
  list->next           = entry;
     f34:	e0c00217 	ldw	r3,8(fp)
     f38:	e0800317 	ldw	r2,12(fp)
     f3c:	18800015 	stw	r2,0(r3)
  }
  
  /*
   * register the device.
   */
  
  alt_llist_insert(list, &dev->llist);

  return 0;  
     f40:	e0000415 	stw	zero,16(fp)
}
     f44:	e0800417 	ldw	r2,16(fp)
     f48:	dfc00617 	ldw	ra,24(sp)
     f4c:	df000517 	ldw	fp,20(sp)
     f50:	dec00704 	addi	sp,sp,28
     f54:	f800283a 	ret

00000f58 <alt_get_errno>:

extern int errno;

static ALT_INLINE int* alt_get_errno(void)
{
     f58:	defffd04 	addi	sp,sp,-12
     f5c:	dfc00215 	stw	ra,8(sp)
     f60:	df000115 	stw	fp,4(sp)
     f64:	d839883a 	mov	fp,sp
  return ((alt_errno) ? alt_errno() : &errno);
     f68:	d0a00817 	ldw	r2,-32736(gp)
     f6c:	1005003a 	cmpeq	r2,r2,zero
     f70:	1000041e 	bne	r2,zero,f84 <alt_get_errno+0x2c>
     f74:	d0a00817 	ldw	r2,-32736(gp)
     f78:	103ee83a 	callr	r2
     f7c:	e0800015 	stw	r2,0(fp)
     f80:	00000206 	br	f8c <alt_get_errno+0x34>
     f84:	d0a01704 	addi	r2,gp,-32676
     f88:	e0800015 	stw	r2,0(fp)
     f8c:	e0800017 	ldw	r2,0(fp)
}
     f90:	dfc00217 	ldw	ra,8(sp)
     f94:	df000117 	ldw	fp,4(sp)
     f98:	dec00304 	addi	sp,sp,12
     f9c:	f800283a 	ret

00000fa0 <_do_ctors>:
 * Run the C++ static constructors.
 */

void _do_ctors(void)
{
     fa0:	defffd04 	addi	sp,sp,-12
     fa4:	dfc00215 	stw	ra,8(sp)
     fa8:	df000115 	stw	fp,4(sp)
     fac:	d839883a 	mov	fp,sp
  constructor* ctor;

  for (ctor = &__CTOR_END__[-1]; ctor >= __CTOR_LIST__; ctor--)
     fb0:	00800034 	movhi	r2,0
     fb4:	108a7204 	addi	r2,r2,10696
     fb8:	e0800015 	stw	r2,0(fp)
     fbc:	e0c00017 	ldw	r3,0(fp)
     fc0:	00800034 	movhi	r2,0
     fc4:	108a7304 	addi	r2,r2,10700
     fc8:	18800736 	bltu	r3,r2,fe8 <_do_ctors+0x48>
        (*ctor) (); 
     fcc:	e0800017 	ldw	r2,0(fp)
     fd0:	10800017 	ldw	r2,0(r2)
     fd4:	103ee83a 	callr	r2
     fd8:	e0800017 	ldw	r2,0(fp)
     fdc:	10bfff04 	addi	r2,r2,-4
     fe0:	e0800015 	stw	r2,0(fp)
     fe4:	003ff506 	br	fbc <_do_ctors+0x1c>
}
     fe8:	dfc00217 	ldw	ra,8(sp)
     fec:	df000117 	ldw	fp,4(sp)
     ff0:	dec00304 	addi	sp,sp,12
     ff4:	f800283a 	ret

00000ff8 <_do_dtors>:
 * Run the C++ static destructors.
 */

void _do_dtors(void)
{
     ff8:	defffd04 	addi	sp,sp,-12
     ffc:	dfc00215 	stw	ra,8(sp)
    1000:	df000115 	stw	fp,4(sp)
    1004:	d839883a 	mov	fp,sp
  destructor* dtor;

  for (dtor = &__DTOR_END__[-1]; dtor >= __DTOR_LIST__; dtor--)
    1008:	00800034 	movhi	r2,0
    100c:	108a7204 	addi	r2,r2,10696
    1010:	e0800015 	stw	r2,0(fp)
    1014:	e0c00017 	ldw	r3,0(fp)
    1018:	00800034 	movhi	r2,0
    101c:	108a7304 	addi	r2,r2,10700
    1020:	18800736 	bltu	r3,r2,1040 <_do_dtors+0x48>
        (*dtor) (); 
    1024:	e0800017 	ldw	r2,0(fp)
    1028:	10800017 	ldw	r2,0(r2)
    102c:	103ee83a 	callr	r2
    1030:	e0800017 	ldw	r2,0(fp)
    1034:	10bfff04 	addi	r2,r2,-4
    1038:	e0800015 	stw	r2,0(fp)
    103c:	003ff506 	br	1014 <_do_dtors+0x1c>
}
    1040:	dfc00217 	ldw	ra,8(sp)
    1044:	df000117 	ldw	fp,4(sp)
    1048:	dec00304 	addi	sp,sp,12
    104c:	f800283a 	ret

00001050 <alt_open_fd>:
 * remains unchanged.
 */

static void alt_open_fd(alt_fd* fd, const char* name, int flags, int mode)
{
    1050:	defff904 	addi	sp,sp,-28
    1054:	dfc00615 	stw	ra,24(sp)
    1058:	df000515 	stw	fp,20(sp)
    105c:	d839883a 	mov	fp,sp
    1060:	e1000015 	stw	r4,0(fp)
    1064:	e1400115 	stw	r5,4(fp)
    1068:	e1800215 	stw	r6,8(fp)
    106c:	e1c00315 	stw	r7,12(fp)
  int old;

  old = open (name, flags, mode);
    1070:	e1000117 	ldw	r4,4(fp)
    1074:	e1400217 	ldw	r5,8(fp)
    1078:	e1800317 	ldw	r6,12(fp)
    107c:	00013cc0 	call	13cc <open>
    1080:	e0800415 	stw	r2,16(fp)

  if (old >= 0)
    1084:	e0800417 	ldw	r2,16(fp)
    1088:	1004803a 	cmplt	r2,r2,zero
    108c:	10001c1e 	bne	r2,zero,1100 <alt_open_fd+0xb0>
  {
    fd->dev      = alt_fd_list[old].dev;
    1090:	e1000017 	ldw	r4,0(fp)
    1094:	00c00034 	movhi	r3,0
    1098:	18cea304 	addi	r3,r3,14988
    109c:	e0800417 	ldw	r2,16(fp)
    10a0:	10800324 	muli	r2,r2,12
    10a4:	10c5883a 	add	r2,r2,r3
    10a8:	10800017 	ldw	r2,0(r2)
    10ac:	20800015 	stw	r2,0(r4)
    fd->priv     = alt_fd_list[old].priv;
    10b0:	e1000017 	ldw	r4,0(fp)
    10b4:	00c00034 	movhi	r3,0
    10b8:	18cea304 	addi	r3,r3,14988
    10bc:	e0800417 	ldw	r2,16(fp)
    10c0:	10800324 	muli	r2,r2,12
    10c4:	10c5883a 	add	r2,r2,r3
    10c8:	10800104 	addi	r2,r2,4
    10cc:	10800017 	ldw	r2,0(r2)
    10d0:	20800115 	stw	r2,4(r4)
    fd->fd_flags = alt_fd_list[old].fd_flags;
    10d4:	e1000017 	ldw	r4,0(fp)
    10d8:	00c00034 	movhi	r3,0
    10dc:	18cea304 	addi	r3,r3,14988
    10e0:	e0800417 	ldw	r2,16(fp)
    10e4:	10800324 	muli	r2,r2,12
    10e8:	10c5883a 	add	r2,r2,r3
    10ec:	10800204 	addi	r2,r2,8
    10f0:	10800017 	ldw	r2,0(r2)
    10f4:	20800215 	stw	r2,8(r4)

    alt_release_fd (old);
    10f8:	e1000417 	ldw	r4,16(fp)
    10fc:	00015940 	call	1594 <alt_release_fd>
  }
} 
    1100:	dfc00617 	ldw	ra,24(sp)
    1104:	df000517 	ldw	fp,20(sp)
    1108:	dec00704 	addi	sp,sp,28
    110c:	f800283a 	ret

00001110 <alt_io_redirect>:

/*
 * alt_io_redirect() is called once the device/filesystem lists have been 
 * initialised, but before main(). Its function is to redirect standard in,
 * standard out and standard error so that they point to the devices selected by
 * the user (as defined in system.h).
 *
 * Prior to the call to this function, io is directed towards /dev/null. If
 * i/o can not be redirected to the requested device, for example if the device 
 * does not exist, then it remains directed at /dev/null. 
 */
 
void alt_io_redirect(const char* stdout_dev, 
                     const char* stdin_dev, 
                     const char* stderr_dev)
{
    1110:	defffb04 	addi	sp,sp,-20
    1114:	dfc00415 	stw	ra,16(sp)
    1118:	df000315 	stw	fp,12(sp)
    111c:	d839883a 	mov	fp,sp
    1120:	e1000015 	stw	r4,0(fp)
    1124:	e1400115 	stw	r5,4(fp)
    1128:	e1800215 	stw	r6,8(fp)
  /* Redirect the channels */

  alt_open_fd (&alt_fd_list[STDOUT_FILENO], stdout_dev, O_WRONLY, 0777);
    112c:	01000034 	movhi	r4,0
    1130:	210ea604 	addi	r4,r4,15000
    1134:	e1400017 	ldw	r5,0(fp)
    1138:	01800044 	movi	r6,1
    113c:	01c07fc4 	movi	r7,511
    1140:	00010500 	call	1050 <alt_open_fd>
  alt_open_fd (&alt_fd_list[STDIN_FILENO], stdin_dev, O_RDONLY, 0777);
    1144:	01000034 	movhi	r4,0
    1148:	210ea304 	addi	r4,r4,14988
    114c:	e1400117 	ldw	r5,4(fp)
    1150:	000d883a 	mov	r6,zero
    1154:	01c07fc4 	movi	r7,511
    1158:	00010500 	call	1050 <alt_open_fd>
  alt_open_fd (&alt_fd_list[STDERR_FILENO], stderr_dev, O_WRONLY, 0777);
    115c:	01000034 	movhi	r4,0
    1160:	210ea904 	addi	r4,r4,15012
    1164:	e1400217 	ldw	r5,8(fp)
    1168:	01800044 	movi	r6,1
    116c:	01c07fc4 	movi	r7,511
    1170:	00010500 	call	1050 <alt_open_fd>
}  
    1174:	dfc00417 	ldw	ra,16(sp)
    1178:	df000317 	ldw	fp,12(sp)
    117c:	dec00504 	addi	sp,sp,20
    1180:	f800283a 	ret

00001184 <alt_irq_register>:
 
int alt_irq_register (alt_u32 id, 
                      void* context, 
                      void (*handler)(void*, alt_u32))
{
    1184:	defff304 	addi	sp,sp,-52
    1188:	df000c15 	stw	fp,48(sp)
    118c:	d839883a 	mov	fp,sp
    1190:	e1000015 	stw	r4,0(fp)
    1194:	e1400115 	stw	r5,4(fp)
    1198:	e1800215 	stw	r6,8(fp)
  int rc = -EINVAL;  
    119c:	00bffa84 	movi	r2,-22
    11a0:	e0800315 	stw	r2,12(fp)
  alt_irq_context status;

  if (id < ALT_NIRQ)
    11a4:	e0800017 	ldw	r2,0(fp)
    11a8:	10800828 	cmpgeui	r2,r2,32
    11ac:	1000511e 	bne	r2,zero,12f4 <alt_irq_register+0x170>
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
    11b0:	0005303a 	rdctl	r2,status
    11b4:	e0800615 	stw	r2,24(fp)
  NIOS2_WRITE_STATUS (0);
    11b8:	0001703a 	wrctl	status,zero
    11bc:	e0800617 	ldw	r2,24(fp)
    11c0:	e0800515 	stw	r2,20(fp)
    11c4:	e0800517 	ldw	r2,20(fp)
    11c8:	e0800415 	stw	r2,16(fp)
  {
    /* 
     * interrupts are disabled while the handler tables are updated to ensure
     * that an interrupt doesn't occur while the tables are in an inconsistant
     * state.
     */

    status = alt_irq_disable_all ();

    alt_irq[id].handler = handler;
    11cc:	00c00034 	movhi	r3,0
    11d0:	18d10604 	addi	r3,r3,17432
    11d4:	e0800017 	ldw	r2,0(fp)
    11d8:	10800224 	muli	r2,r2,8
    11dc:	10c7883a 	add	r3,r2,r3
    11e0:	e0800217 	ldw	r2,8(fp)
    11e4:	18800015 	stw	r2,0(r3)
    alt_irq[id].context = context;
    11e8:	00c00034 	movhi	r3,0
    11ec:	18d10604 	addi	r3,r3,17432
    11f0:	e0800017 	ldw	r2,0(fp)
    11f4:	10800224 	muli	r2,r2,8
    11f8:	10c5883a 	add	r2,r2,r3
    11fc:	10c00104 	addi	r3,r2,4
    1200:	e0800117 	ldw	r2,4(fp)
    1204:	18800015 	stw	r2,0(r3)

    rc = (handler) ? alt_irq_enable (id): alt_irq_disable (id);
    1208:	e0800217 	ldw	r2,8(fp)
    120c:	1005003a 	cmpeq	r2,r2,zero
    1210:	1000191e 	bne	r2,zero,1278 <alt_irq_register+0xf4>
 *  
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enable (alt_u32 id)
{
    1214:	e0800017 	ldw	r2,0(fp)
    1218:	e0800615 	stw	r2,24(fp)
    121c:	0005303a 	rdctl	r2,status
    1220:	e0800915 	stw	r2,36(fp)
    1224:	0001703a 	wrctl	status,zero
    1228:	e0800917 	ldw	r2,36(fp)
    122c:	e0800815 	stw	r2,32(fp)
    1230:	e0800817 	ldw	r2,32(fp)
    1234:	e0800715 	stw	r2,28(fp)
  alt_irq_context  status;
  extern volatile alt_u32 alt_irq_active;

  status = alt_irq_disable_all ();

  alt_irq_active |= (1 << id);
    1238:	00c00044 	movi	r3,1
    123c:	e0800617 	ldw	r2,24(fp)
    1240:	1886983a 	sll	r3,r3,r2
    1244:	d0a00917 	ldw	r2,-32732(gp)
    1248:	10c4b03a 	or	r2,r2,r3
    124c:	d0a00915 	stw	r2,-32732(gp)
  NIOS2_WRITE_IENABLE (alt_irq_active);
    1250:	d0a00917 	ldw	r2,-32732(gp)
    1254:	100170fa 	wrctl	ienable,r2
    1258:	e0800717 	ldw	r2,28(fp)
    125c:	e0800915 	stw	r2,36(fp)
    1260:	e0800917 	ldw	r2,36(fp)
    1264:	1001703a 	wrctl	status,r2

  alt_irq_enable_all(status);
    1268:	e0000515 	stw	zero,20(fp)
    126c:	e0800517 	ldw	r2,20(fp)
    1270:	e0800b15 	stw	r2,44(fp)
    1274:	00001906 	br	12dc <alt_irq_register+0x158>
    1278:	e0800017 	ldw	r2,0(fp)
    127c:	e0800915 	stw	r2,36(fp)
    1280:	0005303a 	rdctl	r2,status
    1284:	e0800a15 	stw	r2,40(fp)
    1288:	0001703a 	wrctl	status,zero
    128c:	e0800a17 	ldw	r2,40(fp)
    1290:	e0800615 	stw	r2,24(fp)
    1294:	e0800617 	ldw	r2,24(fp)
    1298:	e0800715 	stw	r2,28(fp)
    129c:	00c00044 	movi	r3,1
    12a0:	e0800917 	ldw	r2,36(fp)
    12a4:	1884983a 	sll	r2,r3,r2
    12a8:	0086303a 	nor	r3,zero,r2
    12ac:	d0a00917 	ldw	r2,-32732(gp)
    12b0:	10c4703a 	and	r2,r2,r3
    12b4:	d0a00915 	stw	r2,-32732(gp)
    12b8:	d0a00917 	ldw	r2,-32732(gp)
    12bc:	100170fa 	wrctl	ienable,r2
    12c0:	e0800717 	ldw	r2,28(fp)
    12c4:	e0800a15 	stw	r2,40(fp)
    12c8:	e0800a17 	ldw	r2,40(fp)
    12cc:	1001703a 	wrctl	status,r2
    12d0:	e0000815 	stw	zero,32(fp)
    12d4:	e0800817 	ldw	r2,32(fp)
    12d8:	e0800b15 	stw	r2,44(fp)
    12dc:	e0800b17 	ldw	r2,44(fp)
    12e0:	e0800315 	stw	r2,12(fp)
    12e4:	e0800417 	ldw	r2,16(fp)
    12e8:	e0800a15 	stw	r2,40(fp)
    12ec:	e0800a17 	ldw	r2,40(fp)
    12f0:	1001703a 	wrctl	status,r2

    alt_irq_enable_all(status);
  }
  return rc; 
    12f4:	e0800317 	ldw	r2,12(fp)
}
    12f8:	df000c17 	ldw	fp,48(sp)
    12fc:	dec00d04 	addi	sp,sp,52
    1300:	f800283a 	ret

00001304 <alt_file_locked>:
 * themselves, and report the error from the filesystems open() function. 
 */ 

static int alt_file_locked (alt_fd* fd)
{
    1304:	defffc04 	addi	sp,sp,-16
    1308:	df000315 	stw	fp,12(sp)
    130c:	d839883a 	mov	fp,sp
    1310:	e1000015 	stw	r4,0(fp)
  alt_u32 i;

  /*
   * Mark the file descriptor as belonging to a device.
   */

  fd->fd_flags |= ALT_FD_DEV;
    1314:	e0c00017 	ldw	r3,0(fp)
    1318:	e0800017 	ldw	r2,0(fp)
    131c:	10800217 	ldw	r2,8(r2)
    1320:	10900034 	orhi	r2,r2,16384
    1324:	18800215 	stw	r2,8(r3)

  /*
   * Loop through all current file descriptors searching for one that's locked
   * for exclusive access. If a match is found, generate an error.
   */

  for (i = 0; i <= alt_max_fd; i++)
    1328:	e0000115 	stw	zero,4(fp)
    132c:	d0e00717 	ldw	r3,-32740(gp)
    1330:	e0800117 	ldw	r2,4(fp)
    1334:	18802036 	bltu	r3,r2,13b8 <alt_file_locked+0xb4>
  {
    if ((alt_fd_list[i].dev == fd->dev) &&
    1338:	00c00034 	movhi	r3,0
    133c:	18cea304 	addi	r3,r3,14988
    1340:	e0800117 	ldw	r2,4(fp)
    1344:	10800324 	muli	r2,r2,12
    1348:	10c5883a 	add	r2,r2,r3
    134c:	e0c00017 	ldw	r3,0(fp)
    1350:	11000017 	ldw	r4,0(r2)
    1354:	18800017 	ldw	r2,0(r3)
    1358:	2080131e 	bne	r4,r2,13a8 <alt_file_locked+0xa4>
    135c:	00c00034 	movhi	r3,0
    1360:	18cea304 	addi	r3,r3,14988
    1364:	e0800117 	ldw	r2,4(fp)
    1368:	10800324 	muli	r2,r2,12
    136c:	10c5883a 	add	r2,r2,r3
    1370:	10800204 	addi	r2,r2,8
    1374:	10800017 	ldw	r2,0(r2)
    1378:	1004403a 	cmpge	r2,r2,zero
    137c:	10000a1e 	bne	r2,zero,13a8 <alt_file_locked+0xa4>
    1380:	e0800117 	ldw	r2,4(fp)
    1384:	10c00324 	muli	r3,r2,12
    1388:	00800034 	movhi	r2,0
    138c:	108ea304 	addi	r2,r2,14988
    1390:	1887883a 	add	r3,r3,r2
    1394:	e0800017 	ldw	r2,0(fp)
    1398:	18800326 	beq	r3,r2,13a8 <alt_file_locked+0xa4>
        (alt_fd_list[i].fd_flags & ALT_FD_EXCL) &&
        (&alt_fd_list[i] != fd))
    {
      return -EACCES;
    139c:	00bffcc4 	movi	r2,-13
    13a0:	e0800215 	stw	r2,8(fp)
    13a4:	00000506 	br	13bc <alt_file_locked+0xb8>
    13a8:	e0800117 	ldw	r2,4(fp)
    13ac:	10800044 	addi	r2,r2,1
    13b0:	e0800115 	stw	r2,4(fp)
    13b4:	003fdd06 	br	132c <alt_file_locked+0x28>
    }
  }
  
  /* The device is not locked */
 
  return 0;
    13b8:	e0000215 	stw	zero,8(fp)
}
    13bc:	e0800217 	ldw	r2,8(fp)
    13c0:	df000317 	ldw	fp,12(sp)
    13c4:	dec00404 	addi	sp,sp,16
    13c8:	f800283a 	ret

000013cc <open>:

/*
 * open() is called in order to get a file descriptor that reference the file
 * or device named "name". This descriptor can then be used to manipulate the
 * file/device using the standard system calls, e.g. write(), read(), ioctl()
 * etc.
 *
 * This is equivalent to the standard open() system call.
 *
 * ALT_OPEN is mapped onto the open() system call in alt_syscall.h
 */
 
int ALT_OPEN (const char* file, int flags, int mode)
{ 
    13cc:	defff404 	addi	sp,sp,-48
    13d0:	dfc00b15 	stw	ra,44(sp)
    13d4:	df000a15 	stw	fp,40(sp)
    13d8:	d839883a 	mov	fp,sp
    13dc:	e1000015 	stw	r4,0(fp)
    13e0:	e1400115 	stw	r5,4(fp)
    13e4:	e1800215 	stw	r6,8(fp)
  alt_dev* dev;
  alt_fd*  fd;
  int index  = -1;
    13e8:	00bfffc4 	movi	r2,-1
    13ec:	e0800515 	stw	r2,20(fp)
  int status = -ENODEV;
    13f0:	00bffb44 	movi	r2,-19
    13f4:	e0800615 	stw	r2,24(fp)
  int isafs = 0;
    13f8:	e0000715 	stw	zero,28(fp)

  /* 
   * Check the device list, to see if a device with a matching name is 
   * registered.
   */
  
  if (!(dev = alt_find_dev (file, &alt_dev_list)))
    13fc:	e1000017 	ldw	r4,0(fp)
    1400:	d1600504 	addi	r5,gp,-32748
    1404:	00017800 	call	1780 <alt_find_dev>
    1408:	e0800315 	stw	r2,12(fp)
    140c:	e0800317 	ldw	r2,12(fp)
    1410:	1004c03a 	cmpne	r2,r2,zero
    1414:	1000051e 	bne	r2,zero,142c <open+0x60>
  {
    /* No matching device, so try the filesystem list */

    dev   = alt_find_file (file);
    1418:	e1000017 	ldw	r4,0(fp)
    141c:	00018100 	call	1810 <alt_find_file>
    1420:	e0800315 	stw	r2,12(fp)
    isafs = 1;
    1424:	00800044 	movi	r2,1
    1428:	e0800715 	stw	r2,28(fp)
  }

  /* 
   * If a matching device or filesystem is found, allocate a file descriptor. 
   */

  if (dev)
    142c:	e0800317 	ldw	r2,12(fp)
    1430:	1005003a 	cmpeq	r2,r2,zero
    1434:	1000301e 	bne	r2,zero,14f8 <open+0x12c>
  {
    if ((index = alt_get_fd (dev)) < 0)
    1438:	e1000317 	ldw	r4,12(fp)
    143c:	00018f40 	call	18f4 <alt_get_fd>
    1440:	e0800515 	stw	r2,20(fp)
    1444:	e0800517 	ldw	r2,20(fp)
    1448:	1004403a 	cmpge	r2,r2,zero
    144c:	1000031e 	bne	r2,zero,145c <open+0x90>
    {
      status = index;
    1450:	e0800517 	ldw	r2,20(fp)
    1454:	e0800615 	stw	r2,24(fp)
    1458:	00002906 	br	1500 <open+0x134>
    }
    else
    {
      fd = &alt_fd_list[index];
    145c:	e0800517 	ldw	r2,20(fp)
    1460:	10c00324 	muli	r3,r2,12
    1464:	00800034 	movhi	r2,0
    1468:	108ea304 	addi	r2,r2,14988
    146c:	1885883a 	add	r2,r3,r2
    1470:	e0800415 	stw	r2,16(fp)
      fd->fd_flags = (flags & ~ALT_FD_FLAGS_MASK);
    1474:	e1000417 	ldw	r4,16(fp)
    1478:	e0c00117 	ldw	r3,4(fp)
    147c:	00900034 	movhi	r2,16384
    1480:	10bfffc4 	addi	r2,r2,-1
    1484:	1884703a 	and	r2,r3,r2
    1488:	20800215 	stw	r2,8(r4)
      
      /* If this is a device, ensure it isn't already locked */

      if (isafs || ((status = alt_file_locked (fd)) >= 0))
    148c:	e0800717 	ldw	r2,28(fp)
    1490:	1004c03a 	cmpne	r2,r2,zero
    1494:	1000071e 	bne	r2,zero,14b4 <open+0xe8>
    1498:	e1000417 	ldw	r4,16(fp)
    149c:	00013040 	call	1304 <alt_file_locked>
    14a0:	e0800615 	stw	r2,24(fp)
    14a4:	e0800617 	ldw	r2,24(fp)
    14a8:	1004403a 	cmpge	r2,r2,zero
    14ac:	1000011e 	bne	r2,zero,14b4 <open+0xe8>
    14b0:	00001306 	br	1500 <open+0x134>
      {
        /* 
         * If the device or filesystem provides an open() callback function,
         * call it now to perform any device/filesystem specific operations.
         */
    
        status = (dev->open) ? dev->open(fd, file, flags, mode): 0;
    14b4:	e0800317 	ldw	r2,12(fp)
    14b8:	10800317 	ldw	r2,12(r2)
    14bc:	1005003a 	cmpeq	r2,r2,zero
    14c0:	1000091e 	bne	r2,zero,14e8 <open+0x11c>
    14c4:	e0800317 	ldw	r2,12(fp)
    14c8:	10800317 	ldw	r2,12(r2)
    14cc:	e1000417 	ldw	r4,16(fp)
    14d0:	e1400017 	ldw	r5,0(fp)
    14d4:	e1800117 	ldw	r6,4(fp)
    14d8:	e1c00217 	ldw	r7,8(fp)
    14dc:	103ee83a 	callr	r2
    14e0:	e0800915 	stw	r2,36(fp)
    14e4:	00000106 	br	14ec <open+0x120>
    14e8:	e0000915 	stw	zero,36(fp)
    14ec:	e0800917 	ldw	r2,36(fp)
    14f0:	e0800615 	stw	r2,24(fp)
    14f4:	00000206 	br	1500 <open+0x134>
      }
    }
  }
  else
  {
    status = -ENODEV;
    14f8:	00bffb44 	movi	r2,-19
    14fc:	e0800615 	stw	r2,24(fp)
  }

  /* Allocation failed, so clean up and return an error */ 

  if (status < 0)
    1500:	e0800617 	ldw	r2,24(fp)
    1504:	1004403a 	cmpge	r2,r2,zero
    1508:	1000091e 	bne	r2,zero,1530 <open+0x164>
  {
    alt_release_fd (index);  
    150c:	e1000517 	ldw	r4,20(fp)
    1510:	00015940 	call	1594 <alt_release_fd>
    ALT_ERRNO = -status;
    1514:	000154c0 	call	154c <alt_get_errno>
    1518:	e0c00617 	ldw	r3,24(fp)
    151c:	00c7c83a 	sub	r3,zero,r3
    1520:	10c00015 	stw	r3,0(r2)
    return -1;
    1524:	00bfffc4 	movi	r2,-1
    1528:	e0800815 	stw	r2,32(fp)
    152c:	00000206 	br	1538 <open+0x16c>
  }
  
  /* return the reference upon success */

  return index;
    1530:	e0800517 	ldw	r2,20(fp)
    1534:	e0800815 	stw	r2,32(fp)
}
    1538:	e0800817 	ldw	r2,32(fp)
    153c:	dfc00b17 	ldw	ra,44(sp)
    1540:	df000a17 	ldw	fp,40(sp)
    1544:	dec00c04 	addi	sp,sp,48
    1548:	f800283a 	ret

0000154c <alt_get_errno>:

extern int errno;

static ALT_INLINE int* alt_get_errno(void)
{
    154c:	defffd04 	addi	sp,sp,-12
    1550:	dfc00215 	stw	ra,8(sp)
    1554:	df000115 	stw	fp,4(sp)
    1558:	d839883a 	mov	fp,sp
  return ((alt_errno) ? alt_errno() : &errno);
    155c:	d0a00817 	ldw	r2,-32736(gp)
    1560:	1005003a 	cmpeq	r2,r2,zero
    1564:	1000041e 	bne	r2,zero,1578 <alt_get_errno+0x2c>
    1568:	d0a00817 	ldw	r2,-32736(gp)
    156c:	103ee83a 	callr	r2
    1570:	e0800015 	stw	r2,0(fp)
    1574:	00000206 	br	1580 <alt_get_errno+0x34>
    1578:	d0a01704 	addi	r2,gp,-32676
    157c:	e0800015 	stw	r2,0(fp)
    1580:	e0800017 	ldw	r2,0(fp)
}
    1584:	dfc00217 	ldw	ra,8(sp)
    1588:	df000117 	ldw	fp,4(sp)
    158c:	dec00304 	addi	sp,sp,12
    1590:	f800283a 	ret

00001594 <alt_release_fd>:
 * error cannont be released backed to the pool. They are always reserved.
 */

void alt_release_fd (int fd)
{
    1594:	defffe04 	addi	sp,sp,-8
    1598:	df000115 	stw	fp,4(sp)
    159c:	d839883a 	mov	fp,sp
    15a0:	e1000015 	stw	r4,0(fp)
  if (fd > 2)
    15a4:	e0800017 	ldw	r2,0(fp)
    15a8:	108000d0 	cmplti	r2,r2,3
    15ac:	10000d1e 	bne	r2,zero,15e4 <alt_release_fd+0x50>
  {
    alt_fd_list[fd].fd_flags = 0;
    15b0:	00c00034 	movhi	r3,0
    15b4:	18cea304 	addi	r3,r3,14988
    15b8:	e0800017 	ldw	r2,0(fp)
    15bc:	10800324 	muli	r2,r2,12
    15c0:	10c5883a 	add	r2,r2,r3
    15c4:	10800204 	addi	r2,r2,8
    15c8:	10000015 	stw	zero,0(r2)
    alt_fd_list[fd].dev      = 0;
    15cc:	00c00034 	movhi	r3,0
    15d0:	18cea304 	addi	r3,r3,14988
    15d4:	e0800017 	ldw	r2,0(fp)
    15d8:	10800324 	muli	r2,r2,12
    15dc:	10c5883a 	add	r2,r2,r3
    15e0:	10000015 	stw	zero,0(r2)
  }
}
    15e4:	df000117 	ldw	fp,4(sp)
    15e8:	dec00204 	addi	sp,sp,8
    15ec:	f800283a 	ret

000015f0 <alt_alarm_stop>:
 * the alarm executes.
 */

void alt_alarm_stop (alt_alarm* alarm)
{
    15f0:	defffb04 	addi	sp,sp,-20
    15f4:	df000415 	stw	fp,16(sp)
    15f8:	d839883a 	mov	fp,sp
    15fc:	e1000015 	stw	r4,0(fp)
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
    1600:	0005303a 	rdctl	r2,status
    1604:	e0800315 	stw	r2,12(fp)
  NIOS2_WRITE_STATUS (0);
    1608:	0001703a 	wrctl	status,zero
    160c:	e0800317 	ldw	r2,12(fp)
    1610:	e0800215 	stw	r2,8(fp)
    1614:	e0800217 	ldw	r2,8(fp)
    1618:	e0800115 	stw	r2,4(fp)
 * input argument is the element to remove.
 */
     
static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_remove(alt_llist* entry)
{
    161c:	e0800017 	ldw	r2,0(fp)
    1620:	e0800315 	stw	r2,12(fp)
  entry->next->previous = entry->previous;
    1624:	e0800317 	ldw	r2,12(fp)
    1628:	10c00017 	ldw	r3,0(r2)
    162c:	e0800317 	ldw	r2,12(fp)
    1630:	10800117 	ldw	r2,4(r2)
    1634:	18800115 	stw	r2,4(r3)
  entry->previous->next = entry->next;
    1638:	e0800317 	ldw	r2,12(fp)
    163c:	10c00117 	ldw	r3,4(r2)
    1640:	e0800317 	ldw	r2,12(fp)
    1644:	10800017 	ldw	r2,0(r2)
    1648:	18800015 	stw	r2,0(r3)

  /* 
   * Set the entry to point to itself, so that any further calls to
   * alt_llist_remove() are harmless.
   */

  entry->previous = entry;
    164c:	e0c00317 	ldw	r3,12(fp)
    1650:	e0800317 	ldw	r2,12(fp)
    1654:	18800115 	stw	r2,4(r3)
  entry->next     = entry;
    1658:	e0c00317 	ldw	r3,12(fp)
    165c:	e0800317 	ldw	r2,12(fp)
    1660:	18800015 	stw	r2,0(r3)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_enable_all (alt_irq_context context)
{
    1664:	e0800117 	ldw	r2,4(fp)
    1668:	e0800315 	stw	r2,12(fp)
  NIOS2_WRITE_STATUS (context);
    166c:	e0800317 	ldw	r2,12(fp)
    1670:	1001703a 	wrctl	status,r2
  alt_irq_context irq_context;

  irq_context = alt_irq_disable_all();
  alt_llist_remove (&alarm->llist);
  alt_irq_enable_all (irq_context);
}
    1674:	df000417 	ldw	fp,16(sp)
    1678:	dec00504 	addi	sp,sp,20
    167c:	f800283a 	ret

00001680 <alt_tick>:

/*
 * alt_tick() is periodically called by the system clock driver in order to
 * process the registered list of alarms. Each alarm is registed with a
 * callback interval, and a callback function, "callback". 
 *
 * The return value of the callback function indicates how many ticks are to
 * elapse until the next callback. A return value of zero indicates that the
 * alarm should be deactivated. 
 * 
 * alt_tick() is expected to run at interrupt level.
 */

void alt_tick (void)
{
    1680:	defffb04 	addi	sp,sp,-20
    1684:	dfc00415 	stw	ra,16(sp)
    1688:	df000315 	stw	fp,12(sp)
    168c:	d839883a 	mov	fp,sp
  alt_alarm* next;
  alt_alarm* alarm = (alt_alarm*) alt_alarm_list.next;
    1690:	d0a00d17 	ldw	r2,-32716(gp)
    1694:	e0800115 	stw	r2,4(fp)

  alt_u32    next_callback;

  /* update the tick counter */

  _alt_nticks++;
    1698:	d0a00c17 	ldw	r2,-32720(gp)
    169c:	10800044 	addi	r2,r2,1
    16a0:	d0a00c15 	stw	r2,-32720(gp)

  /* process the registered callbacks */

  while (alarm != (alt_alarm*) &alt_alarm_list)
    16a4:	e0c00117 	ldw	r3,4(fp)
    16a8:	d0a00d04 	addi	r2,gp,-32716
    16ac:	18803026 	beq	r3,r2,1770 <alt_tick+0xf0>
  {
    next = (alt_alarm*) alarm->llist.next;
    16b0:	e0800117 	ldw	r2,4(fp)
    16b4:	10800017 	ldw	r2,0(r2)
    16b8:	e0800015 	stw	r2,0(fp)

    /* 
     * Upon the tick-counter rolling over it is safe to clear the 
     * roll-over flag; once the flag is cleared this (or subsequnt)
     * tick events are enabled to generate an alarm event. 
     */
    if ((alarm->rollover) && (_alt_nticks == 0))
    16bc:	e0800117 	ldw	r2,4(fp)
    16c0:	10800403 	ldbu	r2,16(r2)
    16c4:	1005003a 	cmpeq	r2,r2,zero
    16c8:	1000051e 	bne	r2,zero,16e0 <alt_tick+0x60>
    16cc:	d0a00c17 	ldw	r2,-32720(gp)
    16d0:	1004c03a 	cmpne	r2,r2,zero
    16d4:	1000021e 	bne	r2,zero,16e0 <alt_tick+0x60>
    {
      alarm->rollover = 0;
    16d8:	e0800117 	ldw	r2,4(fp)
    16dc:	10000405 	stb	zero,16(r2)
    }
    
    /* if the alarm period has expired, make the callback */    
    if ((alarm->time <= _alt_nticks) && (alarm->rollover == 0))
    16e0:	e0800117 	ldw	r2,4(fp)
    16e4:	10c00217 	ldw	r3,8(r2)
    16e8:	d0a00c17 	ldw	r2,-32720(gp)
    16ec:	10c01d36 	bltu	r2,r3,1764 <alt_tick+0xe4>
    16f0:	e0800117 	ldw	r2,4(fp)
    16f4:	10800403 	ldbu	r2,16(r2)
    16f8:	1004c03a 	cmpne	r2,r2,zero
    16fc:	1000191e 	bne	r2,zero,1764 <alt_tick+0xe4>
    {
      next_callback = alarm->callback (alarm->context);
    1700:	e0800117 	ldw	r2,4(fp)
    1704:	e0c00117 	ldw	r3,4(fp)
    1708:	10800317 	ldw	r2,12(r2)
    170c:	19000517 	ldw	r4,20(r3)
    1710:	103ee83a 	callr	r2
    1714:	e0800215 	stw	r2,8(fp)

      /* deactivate the alarm if the return value is zero */

      if (next_callback == 0)
    1718:	e0800217 	ldw	r2,8(fp)
    171c:	1004c03a 	cmpne	r2,r2,zero
    1720:	1000031e 	bne	r2,zero,1730 <alt_tick+0xb0>
      {
        alt_alarm_stop (alarm);
    1724:	e1000117 	ldw	r4,4(fp)
    1728:	00015f00 	call	15f0 <alt_alarm_stop>
    172c:	00000d06 	br	1764 <alt_tick+0xe4>
      }
      else
      {
        alarm->time += next_callback;
    1730:	e1000117 	ldw	r4,4(fp)
    1734:	e0800117 	ldw	r2,4(fp)
    1738:	10c00217 	ldw	r3,8(r2)
    173c:	e0800217 	ldw	r2,8(fp)
    1740:	1885883a 	add	r2,r3,r2
    1744:	20800215 	stw	r2,8(r4)
        
        /* 
         * If the desired alarm time causes a roll-over, set the rollover
         * flag. This will prevent the subsequent tick event from causing
         * an alarm too early.
         */
        if(alarm->time < _alt_nticks)
    1748:	e0800117 	ldw	r2,4(fp)
    174c:	10c00217 	ldw	r3,8(r2)
    1750:	d0a00c17 	ldw	r2,-32720(gp)
    1754:	1880032e 	bgeu	r3,r2,1764 <alt_tick+0xe4>
        {
          alarm->rollover = 1;
    1758:	e0c00117 	ldw	r3,4(fp)
    175c:	00800044 	movi	r2,1
    1760:	18800405 	stb	r2,16(r3)
        }
      }
    }
    alarm = next;
    1764:	e0800017 	ldw	r2,0(fp)
    1768:	e0800115 	stw	r2,4(fp)
    176c:	003fcd06 	br	16a4 <alt_tick+0x24>
  }

  /* 
   * Update the operating system specific timer facilities.
   */

  ALT_OS_TIME_TICK();
}
    1770:	dfc00417 	ldw	ra,16(sp)
    1774:	df000317 	ldw	fp,12(sp)
    1778:	dec00504 	addi	sp,sp,20
    177c:	f800283a 	ret

00001780 <alt_find_dev>:
 * be found.
 */
 
alt_dev* alt_find_dev(const char* name, alt_llist* llist)
{
    1780:	defff904 	addi	sp,sp,-28
    1784:	dfc00615 	stw	ra,24(sp)
    1788:	df000515 	stw	fp,20(sp)
    178c:	d839883a 	mov	fp,sp
    1790:	e1000015 	stw	r4,0(fp)
    1794:	e1400115 	stw	r5,4(fp)
  alt_dev* next = (alt_dev*) llist->next;
    1798:	e0800117 	ldw	r2,4(fp)
    179c:	10800017 	ldw	r2,0(r2)
    17a0:	e0800215 	stw	r2,8(fp)
  alt_32 len;

  len  = strlen(name) + 1;
    17a4:	e1000017 	ldw	r4,0(fp)
    17a8:	00023780 	call	2378 <strlen>
    17ac:	10800044 	addi	r2,r2,1
    17b0:	e0800315 	stw	r2,12(fp)

  /*
   * Check each list entry in turn, until a match is found, or we reach the
   * end of the list (i.e. next winds up pointing back to the list head).
   */ 

  while (next != (alt_dev*) llist)
    17b4:	e0c00217 	ldw	r3,8(fp)
    17b8:	e0800117 	ldw	r2,4(fp)
    17bc:	18800e26 	beq	r3,r2,17f8 <alt_find_dev+0x78>
  {

    /* 
     * memcmp() is used here rather than strcmp() in order to reduce the size
     * of the executable.
     */

    if (!memcmp (next->name, name, len))
    17c0:	e0800217 	ldw	r2,8(fp)
    17c4:	11000217 	ldw	r4,8(r2)
    17c8:	e1400017 	ldw	r5,0(fp)
    17cc:	e1800317 	ldw	r6,12(fp)
    17d0:	00022000 	call	2200 <memcmp>
    17d4:	1004c03a 	cmpne	r2,r2,zero
    17d8:	1000031e 	bne	r2,zero,17e8 <alt_find_dev+0x68>
    {
      /* match found */

      return next;
    17dc:	e0800217 	ldw	r2,8(fp)
    17e0:	e0800415 	stw	r2,16(fp)
    17e4:	00000506 	br	17fc <alt_find_dev+0x7c>
    }
    next = (alt_dev*) next->llist.next;
    17e8:	e0800217 	ldw	r2,8(fp)
    17ec:	10800017 	ldw	r2,0(r2)
    17f0:	e0800215 	stw	r2,8(fp)
    17f4:	003fef06 	br	17b4 <alt_find_dev+0x34>
  }
  
  /* No match found */
  
  return NULL;
    17f8:	e0000415 	stw	zero,16(fp)
}
    17fc:	e0800417 	ldw	r2,16(fp)
    1800:	dfc00617 	ldw	ra,24(sp)
    1804:	df000517 	ldw	fp,20(sp)
    1808:	dec00704 	addi	sp,sp,28
    180c:	f800283a 	ret

00001810 <alt_find_file>:
 * "/myfilesystem/junk.txt" would match: "/myfilesystem", but not: "/myfile". 
 */
 
alt_dev* alt_find_file (const char* name)
{
    1810:	defffa04 	addi	sp,sp,-24
    1814:	dfc00515 	stw	ra,20(sp)
    1818:	df000415 	stw	fp,16(sp)
    181c:	d839883a 	mov	fp,sp
    1820:	e1000015 	stw	r4,0(fp)
  alt_dev* next = (alt_dev*) alt_fs_list.next;   
    1824:	d0a00317 	ldw	r2,-32756(gp)
    1828:	e0800115 	stw	r2,4(fp)

  alt_32 len;
 
  /*
   * Check each list entry in turn, until a match is found, or we reach the
   * end of the list (i.e. next winds up pointing back to the list head).
   */ 
 
  while (next != (alt_dev*) &alt_fs_list)
    182c:	e0c00117 	ldw	r3,4(fp)
    1830:	d0a00304 	addi	r2,gp,-32756
    1834:	18802926 	beq	r3,r2,18dc <alt_find_file+0xcc>
  {
    len = strlen(next->name);
    1838:	e0800117 	ldw	r2,4(fp)
    183c:	11000217 	ldw	r4,8(r2)
    1840:	00023780 	call	2378 <strlen>
    1844:	e0800215 	stw	r2,8(fp)
    
    if (next->name[len-1] == '/')
    1848:	e0800117 	ldw	r2,4(fp)
    184c:	10c00217 	ldw	r3,8(r2)
    1850:	e0800217 	ldw	r2,8(fp)
    1854:	1885883a 	add	r2,r3,r2
    1858:	10bfffc4 	addi	r2,r2,-1
    185c:	10800007 	ldb	r2,0(r2)
    1860:	10800bd8 	cmpnei	r2,r2,47
    1864:	1000031e 	bne	r2,zero,1874 <alt_find_file+0x64>
    {
      len -= 1;
    1868:	e0800217 	ldw	r2,8(fp)
    186c:	10bfffc4 	addi	r2,r2,-1
    1870:	e0800215 	stw	r2,8(fp)
    }

    if (((name[len] == '/') || (name[len] == '\0')) && 
    1874:	e0c00017 	ldw	r3,0(fp)
    1878:	e0800217 	ldw	r2,8(fp)
    187c:	1885883a 	add	r2,r3,r2
    1880:	10800007 	ldb	r2,0(r2)
    1884:	10800be0 	cmpeqi	r2,r2,47
    1888:	1000061e 	bne	r2,zero,18a4 <alt_find_file+0x94>
    188c:	e0c00017 	ldw	r3,0(fp)
    1890:	e0800217 	ldw	r2,8(fp)
    1894:	1885883a 	add	r2,r3,r2
    1898:	10800007 	ldb	r2,0(r2)
    189c:	1004c03a 	cmpne	r2,r2,zero
    18a0:	10000a1e 	bne	r2,zero,18cc <alt_find_file+0xbc>
    18a4:	e0800117 	ldw	r2,4(fp)
    18a8:	11000217 	ldw	r4,8(r2)
    18ac:	e1400017 	ldw	r5,0(fp)
    18b0:	e1800217 	ldw	r6,8(fp)
    18b4:	00022000 	call	2200 <memcmp>
    18b8:	1004c03a 	cmpne	r2,r2,zero
    18bc:	1000031e 	bne	r2,zero,18cc <alt_find_file+0xbc>
        !memcmp (next->name, name, len))
    {
      /* match found */

      return next;
    18c0:	e0800117 	ldw	r2,4(fp)
    18c4:	e0800315 	stw	r2,12(fp)
    18c8:	00000506 	br	18e0 <alt_find_file+0xd0>
    }
    next = (alt_dev*) next->llist.next;
    18cc:	e0800117 	ldw	r2,4(fp)
    18d0:	10800017 	ldw	r2,0(r2)
    18d4:	e0800115 	stw	r2,4(fp)
    18d8:	003fd406 	br	182c <alt_find_file+0x1c>
  }
  
  /* No match found */
  
  return NULL;     
    18dc:	e0000315 	stw	zero,12(fp)
}
    18e0:	e0800317 	ldw	r2,12(fp)
    18e4:	dfc00517 	ldw	ra,20(sp)
    18e8:	df000417 	ldw	fp,16(sp)
    18ec:	dec00604 	addi	sp,sp,24
    18f0:	f800283a 	ret

000018f4 <alt_get_fd>:
 * negative value indicates failure.
 */

int alt_get_fd (alt_dev* dev)
{
    18f4:	defffa04 	addi	sp,sp,-24
    18f8:	df000515 	stw	fp,20(sp)
    18fc:	d839883a 	mov	fp,sp
    1900:	e1000015 	stw	r4,0(fp)
  alt_32 i;
  int rc = -EMFILE;
    1904:	00bffa04 	movi	r2,-24
    1908:	e0800215 	stw	r2,8(fp)
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
    190c:	e0000315 	stw	zero,12(fp)
  
  /* 
   * Take the alt_fd_list_lock semaphore in order to avoid races when 
   * accessing the file descriptor pool.
   */
  
  ALT_SEM_PEND(alt_fd_list_lock, 0);
  
  /* 
   * Search through the list of file descriptors, and allocate the first
   * free descriptor that's found. 
   *
   * If a free descriptor is found, then the value of "alt_max_fd" is 
   * updated accordingly. "alt_max_fd" is a 'highwater mark' which 
   * indicates the highest file descriptor ever allocated. This is used to
   * improve efficency when searching the file descriptor list, and 
   * therefore reduce contention on the alt_fd_list_lock semaphore. 
   */

  for (i = 0; i < ALT_MAX_FD; i++)
    1910:	e0000115 	stw	zero,4(fp)
    1914:	e0800117 	ldw	r2,4(fp)
    1918:	10800808 	cmpgei	r2,r2,32
    191c:	10001b1e 	bne	r2,zero,198c <alt_get_fd+0x98>
  {
    if (!alt_fd_list[i].dev)
    1920:	00c00034 	movhi	r3,0
    1924:	18cea304 	addi	r3,r3,14988
    1928:	e0800117 	ldw	r2,4(fp)
    192c:	10800324 	muli	r2,r2,12
    1930:	10c5883a 	add	r2,r2,r3
    1934:	10800017 	ldw	r2,0(r2)
    1938:	1004c03a 	cmpne	r2,r2,zero
    193c:	10000f1e 	bne	r2,zero,197c <alt_get_fd+0x88>
    {
      alt_fd_list[i].dev = dev;
    1940:	00c00034 	movhi	r3,0
    1944:	18cea304 	addi	r3,r3,14988
    1948:	e0800117 	ldw	r2,4(fp)
    194c:	10800324 	muli	r2,r2,12
    1950:	10c7883a 	add	r3,r2,r3
    1954:	e0800017 	ldw	r2,0(fp)
    1958:	18800015 	stw	r2,0(r3)
      if (i > alt_max_fd)
    195c:	e0c00117 	ldw	r3,4(fp)
    1960:	d0a00717 	ldw	r2,-32740(gp)
    1964:	10c0020e 	bge	r2,r3,1970 <alt_get_fd+0x7c>
      {
        alt_max_fd = i;
    1968:	e0800117 	ldw	r2,4(fp)
    196c:	d0a00715 	stw	r2,-32740(gp)
      }
      rc = i;
    1970:	e0800117 	ldw	r2,4(fp)
    1974:	e0800215 	stw	r2,8(fp)
      goto alt_get_fd_exit;
    1978:	00000406 	br	198c <alt_get_fd+0x98>
    197c:	e0800117 	ldw	r2,4(fp)
    1980:	10800044 	addi	r2,r2,1
    1984:	e0800115 	stw	r2,4(fp)
    1988:	003fe206 	br	1914 <alt_get_fd+0x20>
 */

static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
{
  return 0;
    198c:	e0000415 	stw	zero,16(fp)
    }
  }

 alt_get_fd_exit:

  /*
   * Release the alt_fd_list_lock semaphore now that we are done with the
   * file descriptor pool.
   */

  ALT_SEM_POST(alt_fd_list_lock);

  return rc;
    1990:	e0800217 	ldw	r2,8(fp)
}
    1994:	df000517 	ldw	fp,20(sp)
    1998:	dec00604 	addi	sp,sp,24
    199c:	f800283a 	ret

000019a0 <atexit>:
    19a0:	d0a00f17 	ldw	r2,-32708(gp)
    19a4:	defffe04 	addi	sp,sp,-8
    19a8:	dc000015 	stw	r16,0(sp)
    19ac:	dfc00115 	stw	ra,4(sp)
    19b0:	11405217 	ldw	r5,328(r2)
    19b4:	2021883a 	mov	r16,r4
    19b8:	01004304 	movi	r4,268
    19bc:	28001b26 	beq	r5,zero,1a2c <atexit+0x8c>
    19c0:	28c00117 	ldw	r3,4(r5)
    19c4:	008007c4 	movi	r2,31
    19c8:	10c00d16 	blt	r2,r3,1a00 <atexit+0x60>
    19cc:	28800104 	addi	r2,r5,4
    19d0:	10c00017 	ldw	r3,0(r2)
    19d4:	000d883a 	mov	r6,zero
    19d8:	180890ba 	slli	r4,r3,2
    19dc:	18c00044 	addi	r3,r3,1
    19e0:	10c00015 	stw	r3,0(r2)
    19e4:	2149883a 	add	r4,r4,r5
    19e8:	24000215 	stw	r16,8(r4)
    19ec:	3005883a 	mov	r2,r6
    19f0:	dfc00117 	ldw	ra,4(sp)
    19f4:	dc000017 	ldw	r16,0(sp)
    19f8:	dec00204 	addi	sp,sp,8
    19fc:	f800283a 	ret
    1a00:	0001b200 	call	1b20 <malloc>
    1a04:	100b883a 	mov	r5,r2
    1a08:	01bfffc4 	movi	r6,-1
    1a0c:	103ff726 	beq	r2,zero,19ec <atexit+0x4c>
    1a10:	d0e00f17 	ldw	r3,-32708(gp)
    1a14:	10004215 	stw	zero,264(r2)
    1a18:	10000115 	stw	zero,4(r2)
    1a1c:	18805217 	ldw	r2,328(r3)
    1a20:	28800015 	stw	r2,0(r5)
    1a24:	19405215 	stw	r5,328(r3)
    1a28:	003fe806 	br	19cc <atexit+0x2c>
    1a2c:	01400034 	movhi	r5,0
    1a30:	29514604 	addi	r5,r5,17688
    1a34:	11405215 	stw	r5,328(r2)
    1a38:	003fe106 	br	19c0 <atexit+0x20>

00001a3c <exit>:
    1a3c:	d0a00f17 	ldw	r2,-32708(gp)
    1a40:	defff804 	addi	sp,sp,-32
    1a44:	dd800015 	stw	r22,0(sp)
    1a48:	dfc00715 	stw	ra,28(sp)
    1a4c:	dc000615 	stw	r16,24(sp)
    1a50:	dc400515 	stw	r17,20(sp)
    1a54:	dc800415 	stw	r18,16(sp)
    1a58:	dcc00315 	stw	r19,12(sp)
    1a5c:	dd000215 	stw	r20,8(sp)
    1a60:	dd400115 	stw	r21,4(sp)
    1a64:	15005217 	ldw	r20,328(r2)
    1a68:	202d883a 	mov	r22,r4
    1a6c:	a0002526 	beq	r20,zero,1b04 <exit+0xc8>
    1a70:	a0800117 	ldw	r2,4(r20)
    1a74:	a5402204 	addi	r21,r20,136
    1a78:	0027883a 	mov	r19,zero
    1a7c:	143fffc4 	addi	r16,r2,-1
    1a80:	8006803a 	cmplt	r3,r16,zero
    1a84:	1800021e 	bne	r3,zero,1a90 <exit+0x54>
    1a88:	00800044 	movi	r2,1
    1a8c:	1426983a 	sll	r19,r2,r16
    1a90:	1800191e 	bne	r3,zero,1af8 <exit+0xbc>
    1a94:	800490ba 	slli	r2,r16,2
    1a98:	1025883a 	mov	r18,r2
    1a9c:	1505883a 	add	r2,r2,r20
    1aa0:	14400204 	addi	r17,r2,8
    1aa4:	00000806 	br	1ac8 <exit+0x8c>
    1aa8:	88800017 	ldw	r2,0(r17)
    1aac:	29400017 	ldw	r5,0(r5)
    1ab0:	843fffc4 	addi	r16,r16,-1
    1ab4:	94bfff04 	addi	r18,r18,-4
    1ab8:	103ee83a 	callr	r2
    1abc:	8c7fff04 	addi	r17,r17,-4
    1ac0:	9827d07a 	srai	r19,r19,1
    1ac4:	80000c16 	blt	r16,zero,1af8 <exit+0xbc>
    1ac8:	a8802017 	ldw	r2,128(r21)
    1acc:	954b883a 	add	r5,r18,r21
    1ad0:	b009883a 	mov	r4,r22
    1ad4:	14c4703a 	and	r2,r2,r19
    1ad8:	103ff31e 	bne	r2,zero,1aa8 <exit+0x6c>
    1adc:	88800017 	ldw	r2,0(r17)
    1ae0:	843fffc4 	addi	r16,r16,-1
    1ae4:	94bfff04 	addi	r18,r18,-4
    1ae8:	103ee83a 	callr	r2
    1aec:	8c7fff04 	addi	r17,r17,-4
    1af0:	9827d07a 	srai	r19,r19,1
    1af4:	803ff40e 	bge	r16,zero,1ac8 <exit+0x8c>
    1af8:	a5000017 	ldw	r20,0(r20)
    1afc:	a03fdc1e 	bne	r20,zero,1a70 <exit+0x34>
    1b00:	d0a00f17 	ldw	r2,-32708(gp)
    1b04:	10c00f17 	ldw	r3,60(r2)
    1b08:	1800021e 	bne	r3,zero,1b14 <exit+0xd8>
    1b0c:	b009883a 	mov	r4,r22
    1b10:	00028fc0 	call	28fc <_exit>
    1b14:	1009883a 	mov	r4,r2
    1b18:	183ee83a 	callr	r3
    1b1c:	003ffb06 	br	1b0c <exit+0xd0>

00001b20 <malloc>:
    1b20:	200b883a 	mov	r5,r4
    1b24:	d1200f17 	ldw	r4,-32708(gp)
    1b28:	02000034 	movhi	r8,0
    1b2c:	4206d204 	addi	r8,r8,6984
    1b30:	4000683a 	jmp	r8

00001b34 <free>:
    1b34:	200b883a 	mov	r5,r4
    1b38:	d1200f17 	ldw	r4,-32708(gp)
    1b3c:	02000034 	movhi	r8,0
    1b40:	42093e04 	addi	r8,r8,9464
    1b44:	4000683a 	jmp	r8

00001b48 <_malloc_r>:
    1b48:	defff504 	addi	sp,sp,-44
    1b4c:	28c002c4 	addi	r3,r5,11
    1b50:	00800584 	movi	r2,22
    1b54:	dc400715 	stw	r17,28(sp)
    1b58:	dc800615 	stw	r18,24(sp)
    1b5c:	dfc00a15 	stw	ra,40(sp)
    1b60:	df000915 	stw	fp,36(sp)
    1b64:	dc000815 	stw	r16,32(sp)
    1b68:	dcc00515 	stw	r19,20(sp)
    1b6c:	dd000415 	stw	r20,16(sp)
    1b70:	dd400315 	stw	r21,12(sp)
    1b74:	dd800215 	stw	r22,8(sp)
    1b78:	ddc00115 	stw	r23,4(sp)
    1b7c:	2025883a 	mov	r18,r4
    1b80:	04400404 	movi	r17,16
    1b84:	10c0032e 	bgeu	r2,r3,1b94 <_malloc_r+0x4c>
    1b88:	00bffe04 	movi	r2,-8
    1b8c:	18a2703a 	and	r17,r3,r2
    1b90:	88000116 	blt	r17,zero,1b98 <_malloc_r+0x50>
    1b94:	89400d2e 	bgeu	r17,r5,1bcc <_malloc_r+0x84>
    1b98:	0005883a 	mov	r2,zero
    1b9c:	dfc00a17 	ldw	ra,40(sp)
    1ba0:	df000917 	ldw	fp,36(sp)
    1ba4:	dc000817 	ldw	r16,32(sp)
    1ba8:	dc400717 	ldw	r17,28(sp)
    1bac:	dc800617 	ldw	r18,24(sp)
    1bb0:	dcc00517 	ldw	r19,20(sp)
    1bb4:	dd000417 	ldw	r20,16(sp)
    1bb8:	dd400317 	ldw	r21,12(sp)
    1bbc:	dd800217 	ldw	r22,8(sp)
    1bc0:	ddc00117 	ldw	r23,4(sp)
    1bc4:	dec00b04 	addi	sp,sp,44
    1bc8:	f800283a 	ret
    1bcc:	9009883a 	mov	r4,r18
    1bd0:	000291c0 	call	291c <__malloc_lock>
    1bd4:	00807dc4 	movi	r2,503
    1bd8:	14401536 	bltu	r2,r17,1c30 <_malloc_r+0xe8>
    1bdc:	03400034 	movhi	r13,0
    1be0:	6b4fec04 	addi	r13,r13,16304
    1be4:	8b4d883a 	add	r6,r17,r13
    1be8:	34000317 	ldw	r16,12(r6)
    1bec:	8812d0fa 	srli	r9,r17,3
    1bf0:	81803e26 	beq	r16,r6,1cec <_malloc_r+0x1a4>
    1bf4:	80c00117 	ldw	r3,4(r16)
    1bf8:	00bfff04 	movi	r2,-4
    1bfc:	82000317 	ldw	r8,12(r16)
    1c00:	1886703a 	and	r3,r3,r2
    1c04:	80cb883a 	add	r5,r16,r3
    1c08:	28800117 	ldw	r2,4(r5)
    1c0c:	81c00217 	ldw	r7,8(r16)
    1c10:	9009883a 	mov	r4,r18
    1c14:	10800054 	ori	r2,r2,1
    1c18:	41c00215 	stw	r7,8(r8)
    1c1c:	28800115 	stw	r2,4(r5)
    1c20:	3a000315 	stw	r8,12(r7)
    1c24:	00029380 	call	2938 <__malloc_unlock>
    1c28:	80800204 	addi	r2,r16,8
    1c2c:	003fdb06 	br	1b9c <_malloc_r+0x54>
    1c30:	8806d27a 	srli	r3,r17,9
    1c34:	8812d0fa 	srli	r9,r17,3
    1c38:	18000926 	beq	r3,zero,1c60 <_malloc_r+0x118>
    1c3c:	00800104 	movi	r2,4
    1c40:	10c02f2e 	bgeu	r2,r3,1d00 <_malloc_r+0x1b8>
    1c44:	00800504 	movi	r2,20
    1c48:	1a4016c4 	addi	r9,r3,91
    1c4c:	10c0042e 	bgeu	r2,r3,1c60 <_malloc_r+0x118>
    1c50:	00801504 	movi	r2,84
    1c54:	10c11536 	bltu	r2,r3,20ac <_malloc_r+0x564>
    1c58:	8804d33a 	srli	r2,r17,12
    1c5c:	12401b84 	addi	r9,r2,110
    1c60:	480490fa 	slli	r2,r9,3
    1c64:	03400034 	movhi	r13,0
    1c68:	6b4fec04 	addi	r13,r13,16304
    1c6c:	134b883a 	add	r5,r2,r13
    1c70:	2c000317 	ldw	r16,12(r5)
    1c74:	81400926 	beq	r16,r5,1c9c <_malloc_r+0x154>
    1c78:	01ffff04 	movi	r7,-4
    1c7c:	018003c4 	movi	r6,15
    1c80:	80800117 	ldw	r2,4(r16)
    1c84:	11c6703a 	and	r3,r2,r7
    1c88:	1c49c83a 	sub	r4,r3,r17
    1c8c:	3100aa16 	blt	r6,r4,1f38 <_malloc_r+0x3f0>
    1c90:	2000690e 	bge	r4,zero,1e38 <_malloc_r+0x2f0>
    1c94:	84000317 	ldw	r16,12(r16)
    1c98:	817ff91e 	bne	r16,r5,1c80 <_malloc_r+0x138>
    1c9c:	4a400044 	addi	r9,r9,1
    1ca0:	03000034 	movhi	r12,0
    1ca4:	630fee04 	addi	r12,r12,16312
    1ca8:	64000217 	ldw	r16,8(r12)
    1cac:	83002826 	beq	r16,r12,1d50 <_malloc_r+0x208>
    1cb0:	80800117 	ldw	r2,4(r16)
    1cb4:	00ffff04 	movi	r3,-4
    1cb8:	10c6703a 	and	r3,r2,r3
    1cbc:	1c49c83a 	sub	r4,r3,r17
    1cc0:	008003c4 	movi	r2,15
    1cc4:	11006616 	blt	r2,r4,1e60 <_malloc_r+0x318>
    1cc8:	63000315 	stw	r12,12(r12)
    1ccc:	63000215 	stw	r12,8(r12)
    1cd0:	20000e16 	blt	r4,zero,1d0c <_malloc_r+0x1c4>
    1cd4:	80c7883a 	add	r3,r16,r3
    1cd8:	18800117 	ldw	r2,4(r3)
    1cdc:	9009883a 	mov	r4,r18
    1ce0:	10800054 	ori	r2,r2,1
    1ce4:	18800115 	stw	r2,4(r3)
    1ce8:	003fce06 	br	1c24 <_malloc_r+0xdc>
    1cec:	81800204 	addi	r6,r16,8
    1cf0:	34000317 	ldw	r16,12(r6)
    1cf4:	81bfbf1e 	bne	r16,r6,1bf4 <_malloc_r+0xac>
    1cf8:	4a400084 	addi	r9,r9,2
    1cfc:	003fe806 	br	1ca0 <_malloc_r+0x158>
    1d00:	8804d1ba 	srli	r2,r17,6
    1d04:	12400e04 	addi	r9,r2,56
    1d08:	003fd506 	br	1c60 <_malloc_r+0x118>
    1d0c:	00807fc4 	movi	r2,511
    1d10:	10c09436 	bltu	r2,r3,1f64 <_malloc_r+0x41c>
    1d14:	1808d0fa 	srli	r4,r3,3
    1d18:	61bffe04 	addi	r6,r12,-8
    1d1c:	00800044 	movi	r2,1
    1d20:	200a90fa 	slli	r5,r4,3
    1d24:	2007d0ba 	srai	r3,r4,2
    1d28:	31000117 	ldw	r4,4(r6)
    1d2c:	2991883a 	add	r8,r5,r6
    1d30:	41c00217 	ldw	r7,8(r8)
    1d34:	10c4983a 	sll	r2,r2,r3
    1d38:	82000315 	stw	r8,12(r16)
    1d3c:	81c00215 	stw	r7,8(r16)
    1d40:	2088b03a 	or	r4,r4,r2
    1d44:	3c000315 	stw	r16,12(r7)
    1d48:	31000115 	stw	r4,4(r6)
    1d4c:	44000215 	stw	r16,8(r8)
    1d50:	4807883a 	mov	r3,r9
    1d54:	4800a616 	blt	r9,zero,1ff0 <_malloc_r+0x4a8>
    1d58:	1807d0ba 	srai	r3,r3,2
    1d5c:	03400034 	movhi	r13,0
    1d60:	6b4fec04 	addi	r13,r13,16304
    1d64:	00800044 	movi	r2,1
    1d68:	10ce983a 	sll	r7,r2,r3
    1d6c:	69000117 	ldw	r4,4(r13)
    1d70:	21c04836 	bltu	r4,r7,1e94 <_malloc_r+0x34c>
    1d74:	21c4703a 	and	r2,r4,r7
    1d78:	10000a1e 	bne	r2,zero,1da4 <_malloc_r+0x25c>
    1d7c:	39cf883a 	add	r7,r7,r7
    1d80:	00bfff04 	movi	r2,-4
    1d84:	4884703a 	and	r2,r9,r2
    1d88:	21c6703a 	and	r3,r4,r7
    1d8c:	12400104 	addi	r9,r2,4
    1d90:	1800041e 	bne	r3,zero,1da4 <_malloc_r+0x25c>
    1d94:	39cf883a 	add	r7,r7,r7
    1d98:	4a400104 	addi	r9,r9,4
    1d9c:	21c4703a 	and	r2,r4,r7
    1da0:	103ffc26 	beq	r2,zero,1d94 <_malloc_r+0x24c>
    1da4:	480490fa 	slli	r2,r9,3
    1da8:	4817883a 	mov	r11,r9
    1dac:	134d883a 	add	r6,r2,r13
    1db0:	300b883a 	mov	r5,r6
    1db4:	2c000317 	ldw	r16,12(r5)
    1db8:	81400926 	beq	r16,r5,1de0 <_malloc_r+0x298>
    1dbc:	02bfff04 	movi	r10,-4
    1dc0:	020003c4 	movi	r8,15
    1dc4:	80800117 	ldw	r2,4(r16)
    1dc8:	1286703a 	and	r3,r2,r10
    1dcc:	1c49c83a 	sub	r4,r3,r17
    1dd0:	41008016 	blt	r8,r4,1fd4 <_malloc_r+0x48c>
    1dd4:	2000180e 	bge	r4,zero,1e38 <_malloc_r+0x2f0>
    1dd8:	84000317 	ldw	r16,12(r16)
    1ddc:	817ff91e 	bne	r16,r5,1dc4 <_malloc_r+0x27c>
    1de0:	4a400044 	addi	r9,r9,1
    1de4:	488000cc 	andi	r2,r9,3
    1de8:	29400204 	addi	r5,r5,8
    1dec:	103ff11e 	bne	r2,zero,1db4 <_malloc_r+0x26c>
    1df0:	588000cc 	andi	r2,r11,3
    1df4:	31bffe04 	addi	r6,r6,-8
    1df8:	5affffc4 	addi	r11,r11,-1
    1dfc:	1000e526 	beq	r2,zero,2194 <_malloc_r+0x64c>
    1e00:	30800217 	ldw	r2,8(r6)
    1e04:	11bffa26 	beq	r2,r6,1df0 <_malloc_r+0x2a8>
    1e08:	03400034 	movhi	r13,0
    1e0c:	6b4fec04 	addi	r13,r13,16304
    1e10:	39cf883a 	add	r7,r7,r7
    1e14:	68c00117 	ldw	r3,4(r13)
    1e18:	19c01e36 	bltu	r3,r7,1e94 <_malloc_r+0x34c>
    1e1c:	3800031e 	bne	r7,zero,1e2c <_malloc_r+0x2e4>
    1e20:	00001c06 	br	1e94 <_malloc_r+0x34c>
    1e24:	39cf883a 	add	r7,r7,r7
    1e28:	4a400104 	addi	r9,r9,4
    1e2c:	19c4703a 	and	r2,r3,r7
    1e30:	103ffc26 	beq	r2,zero,1e24 <_malloc_r+0x2dc>
    1e34:	003fdb06 	br	1da4 <_malloc_r+0x25c>
    1e38:	80c7883a 	add	r3,r16,r3
    1e3c:	18800117 	ldw	r2,4(r3)
    1e40:	82000317 	ldw	r8,12(r16)
    1e44:	81c00217 	ldw	r7,8(r16)
    1e48:	10800054 	ori	r2,r2,1
    1e4c:	9009883a 	mov	r4,r18
    1e50:	18800115 	stw	r2,4(r3)
    1e54:	41c00215 	stw	r7,8(r8)
    1e58:	3a000315 	stw	r8,12(r7)
    1e5c:	003f7106 	br	1c24 <_malloc_r+0xdc>
    1e60:	88800054 	ori	r2,r17,1
    1e64:	844b883a 	add	r5,r16,r17
    1e68:	80800115 	stw	r2,4(r16)
    1e6c:	2905883a 	add	r2,r5,r4
    1e70:	20c00054 	ori	r3,r4,1
    1e74:	61400315 	stw	r5,12(r12)
    1e78:	61400215 	stw	r5,8(r12)
    1e7c:	11000015 	stw	r4,0(r2)
    1e80:	9009883a 	mov	r4,r18
    1e84:	2b000215 	stw	r12,8(r5)
    1e88:	28c00115 	stw	r3,4(r5)
    1e8c:	2b000315 	stw	r12,12(r5)
    1e90:	003f6406 	br	1c24 <_malloc_r+0xdc>
    1e94:	6d400217 	ldw	r21,8(r13)
    1e98:	00bfff04 	movi	r2,-4
    1e9c:	a8c00117 	ldw	r3,4(r21)
    1ea0:	18ac703a 	and	r22,r3,r2
    1ea4:	b449c83a 	sub	r4,r22,r17
    1ea8:	b4400236 	bltu	r22,r17,1eb4 <_malloc_r+0x36c>
    1eac:	008003c4 	movi	r2,15
    1eb0:	11002316 	blt	r2,r4,1f40 <_malloc_r+0x3f8>
    1eb4:	d0a01317 	ldw	r2,-32692(gp)
    1eb8:	073fffc4 	movi	fp,-1
    1ebc:	b02f883a 	mov	r23,r22
    1ec0:	8887883a 	add	r3,r17,r2
    1ec4:	d0a01217 	ldw	r2,-32696(gp)
    1ec8:	ada7883a 	add	r19,r21,r22
    1ecc:	1d000404 	addi	r20,r3,16
    1ed0:	17000326 	beq	r2,fp,1ee0 <_malloc_r+0x398>
    1ed4:	18c403c4 	addi	r3,r3,4111
    1ed8:	00bc0004 	movi	r2,-4096
    1edc:	18a8703a 	and	r20,r3,r2
    1ee0:	9009883a 	mov	r4,r18
    1ee4:	a00b883a 	mov	r5,r20
    1ee8:	db400015 	stw	r13,0(sp)
    1eec:	000232c0 	call	232c <_sbrk_r>
    1ef0:	1021883a 	mov	r16,r2
    1ef4:	db400017 	ldw	r13,0(sp)
    1ef8:	17000426 	beq	r2,fp,1f0c <_malloc_r+0x3c4>
    1efc:	14c03e2e 	bgeu	r2,r19,1ff8 <_malloc_r+0x4b0>
    1f00:	00800034 	movhi	r2,0
    1f04:	108fec04 	addi	r2,r2,16304
    1f08:	a8803b26 	beq	r21,r2,1ff8 <_malloc_r+0x4b0>
    1f0c:	68800217 	ldw	r2,8(r13)
    1f10:	013fff04 	movi	r4,-4
    1f14:	10c00117 	ldw	r3,4(r2)
    1f18:	1906703a 	and	r3,r3,r4
    1f1c:	1c49c83a 	sub	r4,r3,r17
    1f20:	1c400236 	bltu	r3,r17,1f2c <_malloc_r+0x3e4>
    1f24:	008003c4 	movi	r2,15
    1f28:	11000516 	blt	r2,r4,1f40 <_malloc_r+0x3f8>
    1f2c:	9009883a 	mov	r4,r18
    1f30:	00029380 	call	2938 <__malloc_unlock>
    1f34:	003f1806 	br	1b98 <_malloc_r+0x50>
    1f38:	4a7fffc4 	addi	r9,r9,-1
    1f3c:	003f5706 	br	1c9c <_malloc_r+0x154>
    1f40:	6c000217 	ldw	r16,8(r13)
    1f44:	88800054 	ori	r2,r17,1
    1f48:	21000054 	ori	r4,r4,1
    1f4c:	8447883a 	add	r3,r16,r17
    1f50:	80800115 	stw	r2,4(r16)
    1f54:	19000115 	stw	r4,4(r3)
    1f58:	9009883a 	mov	r4,r18
    1f5c:	68c00215 	stw	r3,8(r13)
    1f60:	003f3006 	br	1c24 <_malloc_r+0xdc>
    1f64:	180ad27a 	srli	r5,r3,9
    1f68:	1808d0fa 	srli	r4,r3,3
    1f6c:	28000426 	beq	r5,zero,1f80 <_malloc_r+0x438>
    1f70:	00800104 	movi	r2,4
    1f74:	11405836 	bltu	r2,r5,20d8 <_malloc_r+0x590>
    1f78:	1804d1ba 	srli	r2,r3,6
    1f7c:	11000e04 	addi	r4,r2,56
    1f80:	200490fa 	slli	r2,r4,3
    1f84:	01400034 	movhi	r5,0
    1f88:	294fec04 	addi	r5,r5,16304
    1f8c:	1351883a 	add	r8,r2,r13
    1f90:	41c00217 	ldw	r7,8(r8)
    1f94:	3a006d26 	beq	r7,r8,214c <_malloc_r+0x604>
    1f98:	38800117 	ldw	r2,4(r7)
    1f9c:	013fff04 	movi	r4,-4
    1fa0:	1104703a 	and	r2,r2,r4
    1fa4:	1880052e 	bgeu	r3,r2,1fbc <_malloc_r+0x474>
    1fa8:	39c00217 	ldw	r7,8(r7)
    1fac:	3a000326 	beq	r7,r8,1fbc <_malloc_r+0x474>
    1fb0:	38800117 	ldw	r2,4(r7)
    1fb4:	1104703a 	and	r2,r2,r4
    1fb8:	18bffb36 	bltu	r3,r2,1fa8 <_malloc_r+0x460>
    1fbc:	3a000317 	ldw	r8,12(r7)
    1fc0:	82000315 	stw	r8,12(r16)
    1fc4:	81c00215 	stw	r7,8(r16)
    1fc8:	3c000315 	stw	r16,12(r7)
    1fcc:	44000215 	stw	r16,8(r8)
    1fd0:	003f5f06 	br	1d50 <_malloc_r+0x208>
    1fd4:	82000317 	ldw	r8,12(r16)
    1fd8:	81c00217 	ldw	r7,8(r16)
    1fdc:	88800054 	ori	r2,r17,1
    1fe0:	844b883a 	add	r5,r16,r17
    1fe4:	41c00215 	stw	r7,8(r8)
    1fe8:	3a000315 	stw	r8,12(r7)
    1fec:	003f9e06 	br	1e68 <_malloc_r+0x320>
    1ff0:	48c000c4 	addi	r3,r9,3
    1ff4:	003f5806 	br	1d58 <_malloc_r+0x210>
    1ff8:	07000034 	movhi	fp,0
    1ffc:	e70fe204 	addi	fp,fp,16264
    2000:	e0800017 	ldw	r2,0(fp)
    2004:	1505883a 	add	r2,r2,r20
    2008:	e0800015 	stw	r2,0(fp)
    200c:	84c05826 	beq	r16,r19,2170 <_malloc_r+0x628>
    2010:	d0e01217 	ldw	r3,-32696(gp)
    2014:	00bfffc4 	movi	r2,-1
    2018:	18805326 	beq	r3,r2,2168 <_malloc_r+0x620>
    201c:	e0800017 	ldw	r2,0(fp)
    2020:	84c7c83a 	sub	r3,r16,r19
    2024:	10c5883a 	add	r2,r2,r3
    2028:	e0800015 	stw	r2,0(fp)
    202c:	80c001cc 	andi	r3,r16,7
    2030:	0027883a 	mov	r19,zero
    2034:	18000326 	beq	r3,zero,2044 <_malloc_r+0x4fc>
    2038:	00800204 	movi	r2,8
    203c:	10e7c83a 	sub	r19,r2,r3
    2040:	84e1883a 	add	r16,r16,r19
    2044:	8505883a 	add	r2,r16,r20
    2048:	1083ffcc 	andi	r2,r2,4095
    204c:	00c40004 	movi	r3,4096
    2050:	1887c83a 	sub	r3,r3,r2
    2054:	98e7883a 	add	r19,r19,r3
    2058:	9009883a 	mov	r4,r18
    205c:	980b883a 	mov	r5,r19
    2060:	db400015 	stw	r13,0(sp)
    2064:	000232c0 	call	232c <_sbrk_r>
    2068:	1007883a 	mov	r3,r2
    206c:	00bfffc4 	movi	r2,-1
    2070:	db400017 	ldw	r13,0(sp)
    2074:	18804e26 	beq	r3,r2,21b0 <_malloc_r+0x668>
    2078:	e0800017 	ldw	r2,0(fp)
    207c:	1c07c83a 	sub	r3,r3,r16
    2080:	1cc9883a 	add	r4,r3,r19
    2084:	14c5883a 	add	r2,r2,r19
    2088:	e0800015 	stw	r2,0(fp)
    208c:	6c000215 	stw	r16,8(r13)
    2090:	20800054 	ori	r2,r4,1
    2094:	ab404426 	beq	r21,r13,21a8 <_malloc_r+0x660>
    2098:	014003c4 	movi	r5,15
    209c:	2d801636 	bltu	r5,r22,20f8 <_malloc_r+0x5b0>
    20a0:	00800044 	movi	r2,1
    20a4:	80800115 	stw	r2,4(r16)
    20a8:	003f9806 	br	1f0c <_malloc_r+0x3c4>
    20ac:	00805504 	movi	r2,340
    20b0:	10c00336 	bltu	r2,r3,20c0 <_malloc_r+0x578>
    20b4:	8804d3fa 	srli	r2,r17,15
    20b8:	12401dc4 	addi	r9,r2,119
    20bc:	003ee806 	br	1c60 <_malloc_r+0x118>
    20c0:	00815504 	movi	r2,1364
    20c4:	02401f84 	movi	r9,126
    20c8:	10fee536 	bltu	r2,r3,1c60 <_malloc_r+0x118>
    20cc:	8804d4ba 	srli	r2,r17,18
    20d0:	12401f04 	addi	r9,r2,124
    20d4:	003ee206 	br	1c60 <_malloc_r+0x118>
    20d8:	00800504 	movi	r2,20
    20dc:	290016c4 	addi	r4,r5,91
    20e0:	117fa72e 	bgeu	r2,r5,1f80 <_malloc_r+0x438>
    20e4:	00801504 	movi	r2,84
    20e8:	11403a36 	bltu	r2,r5,21d4 <_malloc_r+0x68c>
    20ec:	1804d33a 	srli	r2,r3,12
    20f0:	11001b84 	addi	r4,r2,110
    20f4:	003fa206 	br	1f80 <_malloc_r+0x438>
    20f8:	80800115 	stw	r2,4(r16)
    20fc:	a8800117 	ldw	r2,4(r21)
    2100:	00fffe04 	movi	r3,-8
    2104:	b13ffd04 	addi	r4,r22,-12
    2108:	20ee703a 	and	r23,r4,r3
    210c:	1080004c 	andi	r2,r2,1
    2110:	15c4b03a 	or	r2,r2,r23
    2114:	a8800115 	stw	r2,4(r21)
    2118:	adc7883a 	add	r3,r21,r23
    211c:	00800144 	movi	r2,5
    2120:	18800215 	stw	r2,8(r3)
    2124:	18800115 	stw	r2,4(r3)
    2128:	2dc02436 	bltu	r5,r23,21bc <_malloc_r+0x674>
    212c:	e0c00017 	ldw	r3,0(fp)
    2130:	d0a01117 	ldw	r2,-32700(gp)
    2134:	10c0012e 	bgeu	r2,r3,213c <_malloc_r+0x5f4>
    2138:	d0e01115 	stw	r3,-32700(gp)
    213c:	d0a01017 	ldw	r2,-32704(gp)
    2140:	10ff722e 	bgeu	r2,r3,1f0c <_malloc_r+0x3c4>
    2144:	d0e01015 	stw	r3,-32704(gp)
    2148:	003f7006 	br	1f0c <_malloc_r+0x3c4>
    214c:	2005d0ba 	srai	r2,r4,2
    2150:	00c00044 	movi	r3,1
    2154:	29000117 	ldw	r4,4(r5)
    2158:	1886983a 	sll	r3,r3,r2
    215c:	20c8b03a 	or	r4,r4,r3
    2160:	29000115 	stw	r4,4(r5)
    2164:	003f9606 	br	1fc0 <_malloc_r+0x478>
    2168:	d4201215 	stw	r16,-32696(gp)
    216c:	003faf06 	br	202c <_malloc_r+0x4e4>
    2170:	8083ffcc 	andi	r2,r16,4095
    2174:	103fa61e 	bne	r2,zero,2010 <_malloc_r+0x4c8>
    2178:	00800034 	movhi	r2,0
    217c:	108fec04 	addi	r2,r2,16304
    2180:	10c00217 	ldw	r3,8(r2)
    2184:	a5c9883a 	add	r4,r20,r23
    2188:	20800054 	ori	r2,r4,1
    218c:	18800115 	stw	r2,4(r3)
    2190:	003fe606 	br	212c <_malloc_r+0x5e4>
    2194:	68800117 	ldw	r2,4(r13)
    2198:	01c6303a 	nor	r3,zero,r7
    219c:	10c4703a 	and	r2,r2,r3
    21a0:	68800115 	stw	r2,4(r13)
    21a4:	003f1806 	br	1e08 <_malloc_r+0x2c0>
    21a8:	80800115 	stw	r2,4(r16)
    21ac:	003fdf06 	br	212c <_malloc_r+0x5e4>
    21b0:	0027883a 	mov	r19,zero
    21b4:	8007883a 	mov	r3,r16
    21b8:	003faf06 	br	2078 <_malloc_r+0x530>
    21bc:	a9400204 	addi	r5,r21,8
    21c0:	9009883a 	mov	r4,r18
    21c4:	db400015 	stw	r13,0(sp)
    21c8:	00024f80 	call	24f8 <_free_r>
    21cc:	db400017 	ldw	r13,0(sp)
    21d0:	003fd606 	br	212c <_malloc_r+0x5e4>
    21d4:	00805504 	movi	r2,340
    21d8:	11400336 	bltu	r2,r5,21e8 <_malloc_r+0x6a0>
    21dc:	1804d3fa 	srli	r2,r3,15
    21e0:	11001dc4 	addi	r4,r2,119
    21e4:	003f6606 	br	1f80 <_malloc_r+0x438>
    21e8:	00815504 	movi	r2,1364
    21ec:	01001f84 	movi	r4,126
    21f0:	117f6336 	bltu	r2,r5,1f80 <_malloc_r+0x438>
    21f4:	1804d4ba 	srli	r2,r3,18
    21f8:	11001f04 	addi	r4,r2,124
    21fc:	003f6006 	br	1f80 <_malloc_r+0x438>

00002200 <memcmp>:
    2200:	01c000c4 	movi	r7,3
    2204:	3980032e 	bgeu	r7,r6,2214 <memcmp+0x14>
    2208:	2144b03a 	or	r2,r4,r5
    220c:	11c4703a 	and	r2,r2,r7
    2210:	10000d26 	beq	r2,zero,2248 <memcmp+0x48>
    2214:	31bfffc4 	addi	r6,r6,-1
    2218:	00bfffc4 	movi	r2,-1
    221c:	30800826 	beq	r6,r2,2240 <memcmp+0x40>
    2220:	100f883a 	mov	r7,r2
    2224:	20c00003 	ldbu	r3,0(r4)
    2228:	28800003 	ldbu	r2,0(r5)
    222c:	31bfffc4 	addi	r6,r6,-1
    2230:	21000044 	addi	r4,r4,1
    2234:	29400044 	addi	r5,r5,1
    2238:	18800b1e 	bne	r3,r2,2268 <memcmp+0x68>
    223c:	31fff91e 	bne	r6,r7,2224 <memcmp+0x24>
    2240:	0005883a 	mov	r2,zero
    2244:	f800283a 	ret
    2248:	20c00017 	ldw	r3,0(r4)
    224c:	28800017 	ldw	r2,0(r5)
    2250:	18bff01e 	bne	r3,r2,2214 <memcmp+0x14>
    2254:	31bfff04 	addi	r6,r6,-4
    2258:	21000104 	addi	r4,r4,4
    225c:	29400104 	addi	r5,r5,4
    2260:	39bff936 	bltu	r7,r6,2248 <memcmp+0x48>
    2264:	003feb06 	br	2214 <memcmp+0x14>
    2268:	1885c83a 	sub	r2,r3,r2
    226c:	f800283a 	ret

00002270 <memcpy>:
    2270:	020003c4 	movi	r8,15
    2274:	2007883a 	mov	r3,r4
    2278:	4180032e 	bgeu	r8,r6,2288 <memcpy+0x18>
    227c:	2904b03a 	or	r2,r5,r4
    2280:	108000cc 	andi	r2,r2,3
    2284:	10000c26 	beq	r2,zero,22b8 <memcpy+0x48>
    2288:	31bfffc4 	addi	r6,r6,-1
    228c:	00bfffc4 	movi	r2,-1
    2290:	30800726 	beq	r6,r2,22b0 <memcpy+0x40>
    2294:	100f883a 	mov	r7,r2
    2298:	28800003 	ldbu	r2,0(r5)
    229c:	31bfffc4 	addi	r6,r6,-1
    22a0:	29400044 	addi	r5,r5,1
    22a4:	18800005 	stb	r2,0(r3)
    22a8:	18c00044 	addi	r3,r3,1
    22ac:	31fffa1e 	bne	r6,r7,2298 <memcpy+0x28>
    22b0:	2005883a 	mov	r2,r4
    22b4:	f800283a 	ret
    22b8:	200f883a 	mov	r7,r4
    22bc:	28800017 	ldw	r2,0(r5)
    22c0:	29400104 	addi	r5,r5,4
    22c4:	31bffc04 	addi	r6,r6,-16
    22c8:	38800015 	stw	r2,0(r7)
    22cc:	28c00017 	ldw	r3,0(r5)
    22d0:	39c00104 	addi	r7,r7,4
    22d4:	29400104 	addi	r5,r5,4
    22d8:	38c00015 	stw	r3,0(r7)
    22dc:	28800017 	ldw	r2,0(r5)
    22e0:	39c00104 	addi	r7,r7,4
    22e4:	29400104 	addi	r5,r5,4
    22e8:	38800015 	stw	r2,0(r7)
    22ec:	28c00017 	ldw	r3,0(r5)
    22f0:	39c00104 	addi	r7,r7,4
    22f4:	29400104 	addi	r5,r5,4
    22f8:	38c00015 	stw	r3,0(r7)
    22fc:	39c00104 	addi	r7,r7,4
    2300:	41bfee36 	bltu	r8,r6,22bc <memcpy+0x4c>
    2304:	00c000c4 	movi	r3,3
    2308:	1980062e 	bgeu	r3,r6,2324 <memcpy+0xb4>
    230c:	28800017 	ldw	r2,0(r5)
    2310:	31bfff04 	addi	r6,r6,-4
    2314:	29400104 	addi	r5,r5,4
    2318:	38800015 	stw	r2,0(r7)
    231c:	39c00104 	addi	r7,r7,4
    2320:	19bffa36 	bltu	r3,r6,230c <memcpy+0x9c>
    2324:	3807883a 	mov	r3,r7
    2328:	003fd706 	br	2288 <memcpy+0x18>

0000232c <_sbrk_r>:
    232c:	defffe04 	addi	sp,sp,-8
    2330:	dc000015 	stw	r16,0(sp)
    2334:	2021883a 	mov	r16,r4
    2338:	2809883a 	mov	r4,r5
    233c:	dfc00115 	stw	ra,4(sp)
    2340:	d0201715 	stw	zero,-32676(gp)
    2344:	00029540 	call	2954 <sbrk>
    2348:	1007883a 	mov	r3,r2
    234c:	00bfffc4 	movi	r2,-1
    2350:	18800526 	beq	r3,r2,2368 <_sbrk_r+0x3c>
    2354:	1805883a 	mov	r2,r3
    2358:	dfc00117 	ldw	ra,4(sp)
    235c:	dc000017 	ldw	r16,0(sp)
    2360:	dec00204 	addi	sp,sp,8
    2364:	f800283a 	ret
    2368:	d0a01717 	ldw	r2,-32676(gp)
    236c:	103ff926 	beq	r2,zero,2354 <_sbrk_r+0x28>
    2370:	80800015 	stw	r2,0(r16)
    2374:	003ff706 	br	2354 <_sbrk_r+0x28>

00002378 <strlen>:
    2378:	208000cc 	andi	r2,r4,3
    237c:	200f883a 	mov	r7,r4
    2380:	1000101e 	bne	r2,zero,23c4 <strlen+0x4c>
    2384:	20800017 	ldw	r2,0(r4)
    2388:	01bfbff4 	movhi	r6,65279
    238c:	31bfbfc4 	addi	r6,r6,-257
    2390:	01602074 	movhi	r5,32897
    2394:	29602004 	addi	r5,r5,-32640
    2398:	00000206 	br	23a4 <strlen+0x2c>
    239c:	21000104 	addi	r4,r4,4
    23a0:	20800017 	ldw	r2,0(r4)
    23a4:	0086303a 	nor	r3,zero,r2
    23a8:	1185883a 	add	r2,r2,r6
    23ac:	10c4703a 	and	r2,r2,r3
    23b0:	1144703a 	and	r2,r2,r5
    23b4:	103ff926 	beq	r2,zero,239c <strlen+0x24>
    23b8:	20800007 	ldb	r2,0(r4)
    23bc:	10000326 	beq	r2,zero,23cc <strlen+0x54>
    23c0:	21000044 	addi	r4,r4,1
    23c4:	20800007 	ldb	r2,0(r4)
    23c8:	103ffd1e 	bne	r2,zero,23c0 <strlen+0x48>
    23cc:	21c5c83a 	sub	r2,r4,r7
    23d0:	f800283a 	ret

000023d4 <_malloc_trim_r>:
    23d4:	defffb04 	addi	sp,sp,-20
    23d8:	dcc00015 	stw	r19,0(sp)
    23dc:	04c00034 	movhi	r19,0
    23e0:	9ccfec04 	addi	r19,r19,16304
    23e4:	dc000315 	stw	r16,12(sp)
    23e8:	dc400215 	stw	r17,8(sp)
    23ec:	dc800115 	stw	r18,4(sp)
    23f0:	2823883a 	mov	r17,r5
    23f4:	2021883a 	mov	r16,r4
    23f8:	dfc00415 	stw	ra,16(sp)
    23fc:	000291c0 	call	291c <__malloc_lock>
    2400:	98800217 	ldw	r2,8(r19)
    2404:	8009883a 	mov	r4,r16
    2408:	000b883a 	mov	r5,zero
    240c:	10c00117 	ldw	r3,4(r2)
    2410:	00bfff04 	movi	r2,-4
    2414:	18a4703a 	and	r18,r3,r2
    2418:	9463c83a 	sub	r17,r18,r17
    241c:	8c43fbc4 	addi	r17,r17,4079
    2420:	8822d33a 	srli	r17,r17,12
    2424:	00840004 	movi	r2,4096
    2428:	8c7fffc4 	addi	r17,r17,-1
    242c:	8822933a 	slli	r17,r17,12
    2430:	88800616 	blt	r17,r2,244c <_malloc_trim_r+0x78>
    2434:	000232c0 	call	232c <_sbrk_r>
    2438:	98c00217 	ldw	r3,8(r19)
    243c:	8009883a 	mov	r4,r16
    2440:	044bc83a 	sub	r5,zero,r17
    2444:	1c87883a 	add	r3,r3,r18
    2448:	18800926 	beq	r3,r2,2470 <_malloc_trim_r+0x9c>
    244c:	00029380 	call	2938 <__malloc_unlock>
    2450:	0005883a 	mov	r2,zero
    2454:	dfc00417 	ldw	ra,16(sp)
    2458:	dc000317 	ldw	r16,12(sp)
    245c:	dc400217 	ldw	r17,8(sp)
    2460:	dc800117 	ldw	r18,4(sp)
    2464:	dcc00017 	ldw	r19,0(sp)
    2468:	dec00504 	addi	sp,sp,20
    246c:	f800283a 	ret
    2470:	8009883a 	mov	r4,r16
    2474:	000232c0 	call	232c <_sbrk_r>
    2478:	944dc83a 	sub	r6,r18,r17
    247c:	00ffffc4 	movi	r3,-1
    2480:	8009883a 	mov	r4,r16
    2484:	000b883a 	mov	r5,zero
    2488:	01c00034 	movhi	r7,0
    248c:	39cfe204 	addi	r7,r7,16264
    2490:	31800054 	ori	r6,r6,1
    2494:	10c00926 	beq	r2,r3,24bc <_malloc_trim_r+0xe8>
    2498:	38800017 	ldw	r2,0(r7)
    249c:	98c00217 	ldw	r3,8(r19)
    24a0:	8009883a 	mov	r4,r16
    24a4:	1445c83a 	sub	r2,r2,r17
    24a8:	38800015 	stw	r2,0(r7)
    24ac:	19800115 	stw	r6,4(r3)
    24b0:	00029380 	call	2938 <__malloc_unlock>
    24b4:	00800044 	movi	r2,1
    24b8:	003fe606 	br	2454 <_malloc_trim_r+0x80>
    24bc:	000232c0 	call	232c <_sbrk_r>
    24c0:	99400217 	ldw	r5,8(r19)
    24c4:	100d883a 	mov	r6,r2
    24c8:	8009883a 	mov	r4,r16
    24cc:	1165c83a 	sub	r18,r2,r5
    24d0:	008003c4 	movi	r2,15
    24d4:	90c00054 	ori	r3,r18,1
    24d8:	14bfdc0e 	bge	r2,r18,244c <_malloc_trim_r+0x78>
    24dc:	28c00115 	stw	r3,4(r5)
    24e0:	d0e01217 	ldw	r3,-32696(gp)
    24e4:	00800034 	movhi	r2,0
    24e8:	108fe204 	addi	r2,r2,16264
    24ec:	30c7c83a 	sub	r3,r6,r3
    24f0:	10c00015 	stw	r3,0(r2)
    24f4:	003fd506 	br	244c <_malloc_trim_r+0x78>

000024f8 <_free_r>:
    24f8:	defffd04 	addi	sp,sp,-12
    24fc:	dc000115 	stw	r16,4(sp)
    2500:	dc400015 	stw	r17,0(sp)
    2504:	dfc00215 	stw	ra,8(sp)
    2508:	2821883a 	mov	r16,r5
    250c:	2023883a 	mov	r17,r4
    2510:	28003226 	beq	r5,zero,25dc <_free_r+0xe4>
    2514:	000291c0 	call	291c <__malloc_lock>
    2518:	82bffe04 	addi	r10,r16,-8
    251c:	51400117 	ldw	r5,4(r10)
    2520:	00bfff84 	movi	r2,-2
    2524:	03000034 	movhi	r12,0
    2528:	630fec04 	addi	r12,r12,16304
    252c:	2892703a 	and	r9,r5,r2
    2530:	524d883a 	add	r6,r10,r9
    2534:	30c00117 	ldw	r3,4(r6)
    2538:	61000217 	ldw	r4,8(r12)
    253c:	00bfff04 	movi	r2,-4
    2540:	1896703a 	and	r11,r3,r2
    2544:	21804e26 	beq	r4,r6,2680 <_free_r+0x188>
    2548:	2880004c 	andi	r2,r5,1
    254c:	32c00115 	stw	r11,4(r6)
    2550:	000b883a 	mov	r5,zero
    2554:	1000091e 	bne	r2,zero,257c <_free_r+0x84>
    2558:	50c00017 	ldw	r3,0(r10)
    255c:	60800204 	addi	r2,r12,8
    2560:	50d5c83a 	sub	r10,r10,r3
    2564:	51000217 	ldw	r4,8(r10)
    2568:	48d3883a 	add	r9,r9,r3
    256c:	20807426 	beq	r4,r2,2740 <_free_r+0x248>
    2570:	52000317 	ldw	r8,12(r10)
    2574:	41000215 	stw	r4,8(r8)
    2578:	22000315 	stw	r8,12(r4)
    257c:	32c7883a 	add	r3,r6,r11
    2580:	18800117 	ldw	r2,4(r3)
    2584:	2808c03a 	cmpne	r4,r5,zero
    2588:	1080004c 	andi	r2,r2,1
    258c:	1000061e 	bne	r2,zero,25a8 <_free_r+0xb0>
    2590:	4ad3883a 	add	r9,r9,r11
    2594:	20001626 	beq	r4,zero,25f0 <_free_r+0xf8>
    2598:	30c00217 	ldw	r3,8(r6)
    259c:	32000317 	ldw	r8,12(r6)
    25a0:	40c00215 	stw	r3,8(r8)
    25a4:	1a000315 	stw	r8,12(r3)
    25a8:	48800054 	ori	r2,r9,1
    25ac:	5247883a 	add	r3,r10,r9
    25b0:	50800115 	stw	r2,4(r10)
    25b4:	1a400015 	stw	r9,0(r3)
    25b8:	20001726 	beq	r4,zero,2618 <_free_r+0x120>
    25bc:	8809883a 	mov	r4,r17
    25c0:	02000034 	movhi	r8,0
    25c4:	420a4e04 	addi	r8,r8,10552
    25c8:	dfc00217 	ldw	ra,8(sp)
    25cc:	dc000117 	ldw	r16,4(sp)
    25d0:	dc400017 	ldw	r17,0(sp)
    25d4:	dec00304 	addi	sp,sp,12
    25d8:	4000683a 	jmp	r8
    25dc:	dfc00217 	ldw	ra,8(sp)
    25e0:	dc000117 	ldw	r16,4(sp)
    25e4:	dc400017 	ldw	r17,0(sp)
    25e8:	dec00304 	addi	sp,sp,12
    25ec:	f800283a 	ret
    25f0:	30c00217 	ldw	r3,8(r6)
    25f4:	00800034 	movhi	r2,0
    25f8:	108fee04 	addi	r2,r2,16312
    25fc:	18bfe71e 	bne	r3,r2,259c <_free_r+0xa4>
    2600:	1a800315 	stw	r10,12(r3)
    2604:	1a800215 	stw	r10,8(r3)
    2608:	01000044 	movi	r4,1
    260c:	50c00215 	stw	r3,8(r10)
    2610:	50c00315 	stw	r3,12(r10)
    2614:	003fe406 	br	25a8 <_free_r+0xb0>
    2618:	00807fc4 	movi	r2,511
    261c:	12402b36 	bltu	r2,r9,26cc <_free_r+0x1d4>
    2620:	4806d0fa 	srli	r3,r9,3
    2624:	01800034 	movhi	r6,0
    2628:	318fec04 	addi	r6,r6,16304
    262c:	00800044 	movi	r2,1
    2630:	180890fa 	slli	r4,r3,3
    2634:	1807d0ba 	srai	r3,r3,2
    2638:	31400117 	ldw	r5,4(r6)
    263c:	2191883a 	add	r8,r4,r6
    2640:	41c00217 	ldw	r7,8(r8)
    2644:	10c4983a 	sll	r2,r2,r3
    2648:	52000315 	stw	r8,12(r10)
    264c:	51c00215 	stw	r7,8(r10)
    2650:	288ab03a 	or	r5,r5,r2
    2654:	3a800315 	stw	r10,12(r7)
    2658:	31400115 	stw	r5,4(r6)
    265c:	42800215 	stw	r10,8(r8)
    2660:	8809883a 	mov	r4,r17
    2664:	02000034 	movhi	r8,0
    2668:	420a4e04 	addi	r8,r8,10552
    266c:	dfc00217 	ldw	ra,8(sp)
    2670:	dc000117 	ldw	r16,4(sp)
    2674:	dc400017 	ldw	r17,0(sp)
    2678:	dec00304 	addi	sp,sp,12
    267c:	4000683a 	jmp	r8
    2680:	2880004c 	andi	r2,r5,1
    2684:	4ad3883a 	add	r9,r9,r11
    2688:	1000071e 	bne	r2,zero,26a8 <_free_r+0x1b0>
    268c:	50c00017 	ldw	r3,0(r10)
    2690:	50d5c83a 	sub	r10,r10,r3
    2694:	52000317 	ldw	r8,12(r10)
    2698:	51c00217 	ldw	r7,8(r10)
    269c:	48d3883a 	add	r9,r9,r3
    26a0:	41c00215 	stw	r7,8(r8)
    26a4:	3a000315 	stw	r8,12(r7)
    26a8:	d0a01417 	ldw	r2,-32688(gp)
    26ac:	48c00054 	ori	r3,r9,1
    26b0:	62800215 	stw	r10,8(r12)
    26b4:	50c00115 	stw	r3,4(r10)
    26b8:	48bfc036 	bltu	r9,r2,25bc <_free_r+0xc4>
    26bc:	d1601317 	ldw	r5,-32692(gp)
    26c0:	8809883a 	mov	r4,r17
    26c4:	00023d40 	call	23d4 <_malloc_trim_r>
    26c8:	003fbc06 	br	25bc <_free_r+0xc4>
    26cc:	4808d27a 	srli	r4,r9,9
    26d0:	4806d0fa 	srli	r3,r9,3
    26d4:	2000151e 	bne	r4,zero,272c <_free_r+0x234>
    26d8:	180490fa 	slli	r2,r3,3
    26dc:	01400034 	movhi	r5,0
    26e0:	294fec04 	addi	r5,r5,16304
    26e4:	1311883a 	add	r8,r2,r12
    26e8:	41c00217 	ldw	r7,8(r8)
    26ec:	3a001e26 	beq	r7,r8,2768 <_free_r+0x270>
    26f0:	38800117 	ldw	r2,4(r7)
    26f4:	00ffff04 	movi	r3,-4
    26f8:	10c4703a 	and	r2,r2,r3
    26fc:	4880052e 	bgeu	r9,r2,2714 <_free_r+0x21c>
    2700:	39c00217 	ldw	r7,8(r7)
    2704:	3a000326 	beq	r7,r8,2714 <_free_r+0x21c>
    2708:	38800117 	ldw	r2,4(r7)
    270c:	10c4703a 	and	r2,r2,r3
    2710:	48bffb36 	bltu	r9,r2,2700 <_free_r+0x208>
    2714:	3a000317 	ldw	r8,12(r7)
    2718:	52000315 	stw	r8,12(r10)
    271c:	51c00215 	stw	r7,8(r10)
    2720:	3a800315 	stw	r10,12(r7)
    2724:	42800215 	stw	r10,8(r8)
    2728:	003fcd06 	br	2660 <_free_r+0x168>
    272c:	00800104 	movi	r2,4
    2730:	11000536 	bltu	r2,r4,2748 <_free_r+0x250>
    2734:	4804d1ba 	srli	r2,r9,6
    2738:	10c00e04 	addi	r3,r2,56
    273c:	003fe606 	br	26d8 <_free_r+0x1e0>
    2740:	01400044 	movi	r5,1
    2744:	003f8d06 	br	257c <_free_r+0x84>
    2748:	00800504 	movi	r2,20
    274c:	20c016c4 	addi	r3,r4,91
    2750:	113fe12e 	bgeu	r2,r4,26d8 <_free_r+0x1e0>
    2754:	00801504 	movi	r2,84
    2758:	11000a36 	bltu	r2,r4,2784 <_free_r+0x28c>
    275c:	4804d33a 	srli	r2,r9,12
    2760:	10c01b84 	addi	r3,r2,110
    2764:	003fdc06 	br	26d8 <_free_r+0x1e0>
    2768:	1805d0ba 	srai	r2,r3,2
    276c:	00c00044 	movi	r3,1
    2770:	29000117 	ldw	r4,4(r5)
    2774:	1886983a 	sll	r3,r3,r2
    2778:	20c8b03a 	or	r4,r4,r3
    277c:	29000115 	stw	r4,4(r5)
    2780:	003fe506 	br	2718 <_free_r+0x220>
    2784:	00805504 	movi	r2,340
    2788:	11000336 	bltu	r2,r4,2798 <_free_r+0x2a0>
    278c:	4804d3fa 	srli	r2,r9,15
    2790:	10c01dc4 	addi	r3,r2,119
    2794:	003fd006 	br	26d8 <_free_r+0x1e0>
    2798:	00815504 	movi	r2,1364
    279c:	00c01f84 	movi	r3,126
    27a0:	113fcd36 	bltu	r2,r4,26d8 <_free_r+0x1e0>
    27a4:	4804d4ba 	srli	r2,r9,18
    27a8:	10c01f04 	addi	r3,r2,124
    27ac:	003fca06 	br	26d8 <_free_r+0x1e0>

000027b0 <udivmodsi4>:
    27b0:	00800044 	movi	r2,1
    27b4:	000f883a 	mov	r7,zero
    27b8:	2900082e 	bgeu	r5,r4,27dc <udivmodsi4+0x2c>
    27bc:	28000716 	blt	r5,zero,27dc <udivmodsi4+0x2c>
    27c0:	294b883a 	add	r5,r5,r5
    27c4:	1085883a 	add	r2,r2,r2
    27c8:	29000e2e 	bgeu	r5,r4,2804 <udivmodsi4+0x54>
    27cc:	1007003a 	cmpeq	r3,r2,zero
    27d0:	1800081e 	bne	r3,zero,27f4 <udivmodsi4+0x44>
    27d4:	283ffa0e 	bge	r5,zero,27c0 <udivmodsi4+0x10>
    27d8:	1800061e 	bne	r3,zero,27f4 <udivmodsi4+0x44>
    27dc:	21400236 	bltu	r4,r5,27e8 <udivmodsi4+0x38>
    27e0:	2149c83a 	sub	r4,r4,r5
    27e4:	388eb03a 	or	r7,r7,r2
    27e8:	1004d07a 	srli	r2,r2,1
    27ec:	280ad07a 	srli	r5,r5,1
    27f0:	103ffa1e 	bne	r2,zero,27dc <udivmodsi4+0x2c>
    27f4:	3000011e 	bne	r6,zero,27fc <udivmodsi4+0x4c>
    27f8:	3809883a 	mov	r4,r7
    27fc:	2005883a 	mov	r2,r4
    2800:	f800283a 	ret
    2804:	1007003a 	cmpeq	r3,r2,zero
    2808:	183ff426 	beq	r3,zero,27dc <udivmodsi4+0x2c>
    280c:	003ff906 	br	27f4 <udivmodsi4+0x44>

00002810 <__divsi3>:
    2810:	defffe04 	addi	sp,sp,-8
    2814:	dc000015 	stw	r16,0(sp)
    2818:	dfc00115 	stw	ra,4(sp)
    281c:	000d883a 	mov	r6,zero
    2820:	0021883a 	mov	r16,zero
    2824:	20000816 	blt	r4,zero,2848 <__divsi3+0x38>
    2828:	28000a16 	blt	r5,zero,2854 <__divsi3+0x44>
    282c:	00027b00 	call	27b0 <udivmodsi4>
    2830:	80000126 	beq	r16,zero,2838 <__divsi3+0x28>
    2834:	0085c83a 	sub	r2,zero,r2
    2838:	dfc00117 	ldw	ra,4(sp)
    283c:	dc000017 	ldw	r16,0(sp)
    2840:	dec00204 	addi	sp,sp,8
    2844:	f800283a 	ret
    2848:	0109c83a 	sub	r4,zero,r4
    284c:	0021003a 	cmpeq	r16,zero,zero
    2850:	283ff60e 	bge	r5,zero,282c <__divsi3+0x1c>
    2854:	014bc83a 	sub	r5,zero,r5
    2858:	8021003a 	cmpeq	r16,r16,zero
    285c:	003ff306 	br	282c <__divsi3+0x1c>

00002860 <__modsi3>:
    2860:	defffe04 	addi	sp,sp,-8
    2864:	dc000015 	stw	r16,0(sp)
    2868:	dfc00115 	stw	ra,4(sp)
    286c:	01800044 	movi	r6,1
    2870:	0021883a 	mov	r16,zero
    2874:	20000816 	blt	r4,zero,2898 <__modsi3+0x38>
    2878:	28000a16 	blt	r5,zero,28a4 <__modsi3+0x44>
    287c:	00027b00 	call	27b0 <udivmodsi4>
    2880:	80000126 	beq	r16,zero,2888 <__modsi3+0x28>
    2884:	0085c83a 	sub	r2,zero,r2
    2888:	dfc00117 	ldw	ra,4(sp)
    288c:	dc000017 	ldw	r16,0(sp)
    2890:	dec00204 	addi	sp,sp,8
    2894:	f800283a 	ret
    2898:	0109c83a 	sub	r4,zero,r4
    289c:	3021883a 	mov	r16,r6
    28a0:	283ff60e 	bge	r5,zero,287c <__modsi3+0x1c>
    28a4:	014bc83a 	sub	r5,zero,r5
    28a8:	003ff406 	br	287c <__modsi3+0x1c>

000028ac <__udivsi3>:
    28ac:	000d883a 	mov	r6,zero
    28b0:	02000034 	movhi	r8,0
    28b4:	4209ec04 	addi	r8,r8,10160
    28b8:	4000683a 	jmp	r8

000028bc <__umodsi3>:
    28bc:	01800044 	movi	r6,1
    28c0:	02000034 	movhi	r8,0
    28c4:	4209ec04 	addi	r8,r8,10160
    28c8:	4000683a 	jmp	r8

000028cc <alt_sim_halt>:
#endif


static ALT_ALWAYS_INLINE void alt_sim_halt(int exit_code)
{
    28cc:	defffd04 	addi	sp,sp,-12
    28d0:	df000215 	stw	fp,8(sp)
    28d4:	d839883a 	mov	fp,sp
    28d8:	e1000015 	stw	r4,0(fp)
  int r2 = exit_code;
    28dc:	e0800017 	ldw	r2,0(fp)
    28e0:	e0800115 	stw	r2,4(fp)

#if defined(NIOS2_HAS_DEBUG_STUB) && (defined(ALT_BREAK_ON_EXIT) || defined(ALT_PROVIDE_GMON))

  int r3 = (1 << 2);

#ifdef ALT_PROVIDE_GMON
  extern unsigned int alt_gmon_data[];
  int r4 = (int)alt_gmon_data;
  r3 |= (1 << 4);

  usleep(100000);

#define ALT_GMON_DATA ,"D04"(r4)
#else
#define ALT_GMON_DATA
#endif

  __asm__ volatile ("wrctl ctl6, %0" : : "r"(1), "D02"(r2) );

  __asm__ volatile ("\n0:\n\taddi %0,%0, -1\n\tbgt %0,zero,0b" : : "r" (ALT_CPU_FREQ/100) ); /* Delay for >30ms */

  __asm__ volatile ("break 2" : : "D02"(r2), "D03"(r3) ALT_GMON_DATA );

#else

  __asm__ volatile ("wrctl ctl6, %0" : : "r"(1), "D02"(r2) );
    28e4:	00c00044 	movi	r3,1
    28e8:	e0800117 	ldw	r2,4(fp)
    28ec:	180171ba 	wrctl	ctl6,r3

#endif
}
    28f0:	df000217 	ldw	fp,8(sp)
    28f4:	dec00304 	addi	sp,sp,12
    28f8:	f800283a 	ret

000028fc <_exit>:
 * ALT_EXIT is mapped onto the _exit() system call in alt_syscall.h
 */

void ALT_EXIT (int exit_code)
{
    28fc:	defffd04 	addi	sp,sp,-12
    2900:	dfc00215 	stw	ra,8(sp)
    2904:	df000115 	stw	fp,4(sp)
    2908:	d839883a 	mov	fp,sp
    290c:	e1000015 	stw	r4,0(fp)
  /* Stop all other threads */

  ALT_OS_STOP();

  /* Provide notification to the simulator that we've stopped */

  ALT_SIM_HALT(exit_code);
    2910:	e1000017 	ldw	r4,0(fp)
    2914:	00028cc0 	call	28cc <alt_sim_halt>

  /* spin forever, since there's no where to go back to */

  while (1);
    2918:	003fff06 	br	2918 <_exit+0x1c>

0000291c <__malloc_lock>:
 * this requires that malloc is never called by an interrupt service routine.
 */

void __malloc_lock ( struct _reent *_r )
{
    291c:	defffe04 	addi	sp,sp,-8
    2920:	df000115 	stw	fp,4(sp)
    2924:	d839883a 	mov	fp,sp
    2928:	e1000015 	stw	r4,0(fp)
    292c:	df000117 	ldw	fp,4(sp)
    2930:	dec00204 	addi	sp,sp,8
    2934:	f800283a 	ret

00002938 <__malloc_unlock>:
}

/*
 *
 */

void __malloc_unlock ( struct _reent *_r )
{
    2938:	defffe04 	addi	sp,sp,-8
    293c:	df000115 	stw	fp,4(sp)
    2940:	d839883a 	mov	fp,sp
    2944:	e1000015 	stw	r4,0(fp)
    2948:	df000117 	ldw	fp,4(sp)
    294c:	dec00204 	addi	sp,sp,8
    2950:	f800283a 	ret

00002954 <sbrk>:
 
caddr_t ALT_SBRK (int incr) __attribute__ ((no_instrument_function ));

caddr_t ALT_SBRK (int incr)
{ 
    2954:	defffa04 	addi	sp,sp,-24
    2958:	df000515 	stw	fp,20(sp)
    295c:	d839883a 	mov	fp,sp
    2960:	e1000015 	stw	r4,0(fp)
       alt_irq_disable_all (void)
{
  alt_irq_context context;

  NIOS2_READ_STATUS (context);
    2964:	0005303a 	rdctl	r2,status
    2968:	e0800415 	stw	r2,16(fp)
  NIOS2_WRITE_STATUS (0);
    296c:	0001703a 	wrctl	status,zero
    2970:	e0800417 	ldw	r2,16(fp)
    2974:	e0800315 	stw	r2,12(fp)
    2978:	e0800317 	ldw	r2,12(fp)
    297c:	e0800115 	stw	r2,4(fp)
  alt_irq_context context;
  char *prev_heap_end; 

  context = alt_irq_disable_all();

  /* Always return data aligned on a word boundary */
  heap_end = (char *)(((unsigned int)heap_end + 3) & ~3);
    2980:	d0a01517 	ldw	r2,-32684(gp)
    2984:	10c000c4 	addi	r3,r2,3
    2988:	00bfff04 	movi	r2,-4
    298c:	1884703a 	and	r2,r3,r2
    2990:	d0a01515 	stw	r2,-32684(gp)

#ifdef ALT_MAX_HEAP_BYTES
  /*  
   * User specified a maximum heap size.  Return -1 if it would
   * be exceeded by this sbrk call.
   */
  if (((heap_end + incr) - __alt_heap_start) > ALT_MAX_HEAP_BYTES) {
    alt_irq_enable_all(context);
    return (caddr_t)-1;
  }
#endif

  prev_heap_end = heap_end; 
    2994:	d0a01517 	ldw	r2,-32684(gp)
    2998:	e0800215 	stw	r2,8(fp)
  heap_end += incr; 
    299c:	d0e01517 	ldw	r3,-32684(gp)
    29a0:	e0800017 	ldw	r2,0(fp)
    29a4:	1885883a 	add	r2,r3,r2
    29a8:	d0a01515 	stw	r2,-32684(gp)
 */

static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_enable_all (alt_irq_context context)
{
    29ac:	e0800117 	ldw	r2,4(fp)
    29b0:	e0800415 	stw	r2,16(fp)
  NIOS2_WRITE_STATUS (context);
    29b4:	e0800417 	ldw	r2,16(fp)
    29b8:	1001703a 	wrctl	status,r2

#ifdef ALT_STACK_CHECK
  /*
   * If the stack and heap are contiguous then extending the heap reduces the
   * space available for the stack.  If we are still using the default stack
   * then adjust the stack limit to note this, while checking for stack
   * pointer overflow. 
   * If the stack limit isn't pointing at the top of the heap then the code
   * is using a different stack so none of this needs to be done.
   */

  if (alt_stack_limit() == prev_heap_end)
  {
    if (alt_stack_pointer() <= heap_end)
      alt_report_stack_overflow();

    alt_set_stack_limit(heap_end);
  }

#ifdef ALT_EXCEPTION_STACK
  /*
   * If we are executing from the exception stack then compare against the
   * stack we switched away from as well.  The exception stack is a fixed
   * size so doesn't need to be checked.
   */

  if (alt_exception_old_stack_limit == prev_heap_end)
  {
    if (alt_exception_old_stack_limit <= heap_end)
      alt_report_stack_overflow();

    alt_exception_old_stack_limit = heap_end;
  }
#endif

#endif

  alt_irq_enable_all(context);

  return (caddr_t) prev_heap_end; 
    29bc:	e0800217 	ldw	r2,8(fp)
} 
    29c0:	df000517 	ldw	fp,20(sp)
    29c4:	dec00604 	addi	sp,sp,24
    29c8:	f800283a 	ret
