---
# System prepended metadata

title: LAB 6

---

# LAB 6
#### Name:Aseem Anand
#### Roll No:CS22B008
### My C program:
#include<stdio.h>
int main(){
    int A[100];
    for(int i=0;i<100;i++){
        A[i]=1;
    }
    int sum=0;
    for(int i=0;i<100;i++){
        sum+=A[i];
    }
    return 0;
}
### Assembly code Without Optimisation:
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        addi    sp,sp,-432
        sw      s0,428(sp)
        addi    s0,sp,432
        sw      zero,-20(s0)
        j       .L2
.L3:
        lw      a5,-20(s0)
        slli    a5,a5,2
        addi    a5,a5,-16
        add     a5,a5,s0
        li      a4,1
        sw      a4,-412(a5)
        lw      a5,-20(s0)
        addi    a5,a5,1
        sw      a5,-20(s0)
.L2:
        lw      a4,-20(s0)
        li      a5,99
        ble     a4,a5,.L3
        sw      zero,-24(s0)
        sw      zero,-28(s0)
        j       .L4
.L5:
        lw      a5,-28(s0)
        slli    a5,a5,2
        addi    a5,a5,-16
        add     a5,a5,s0
        lw      a5,-412(a5)
        lw      a4,-24(s0)
        add     a5,a4,a5
        sw      a5,-24(s0)
        lw      a5,-28(s0)
        addi    a5,a5,1
        sw      a5,-28(s0)
.L4:
        lw      a4,-28(s0)
        li      a5,99
        ble     a4,a5,.L5
        li      a5,0
        mv      a0,a5
        lw      s0,428(sp)
        addi    sp,sp,432
        jr      ra
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:825bytes**
**Contents:**
text-8756
data-1372
bss-840
dec-10968
hex-2ad8
filename-hundered.elf 
   
### Assembly code for o0 : 
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        addi    sp,sp,-432
        sw      s0,428(sp)
        addi    s0,sp,432
        sw      zero,-20(s0)
        j       .L2
.L3:
        lw      a5,-20(s0)
        slli    a5,a5,2
        addi    a5,a5,-16
        add     a5,a5,s0
        li      a4,1
        sw      a4,-412(a5)
        lw      a5,-20(s0)
        addi    a5,a5,1
        sw      a5,-20(s0)
.L2:
        lw      a4,-20(s0)
        li      a5,99
        ble     a4,a5,.L3
        sw      zero,-24(s0)
        sw      zero,-28(s0)
        j       .L4
.L5:
        lw      a5,-28(s0)
        slli    a5,a5,2
        addi    a5,a5,-16
        add     a5,a5,s0
        lw      a5,-412(a5)
        lw      a4,-24(s0)
        add     a5,a4,a5
        sw      a5,-24(s0)
        lw      a5,-28(s0)
        addi    a5,a5,1
        sw      a5,-28(s0)
.L4:
        lw      a4,-28(s0)
        li      a5,99
        ble     a4,a5,.L5
        li      a5,0
        mv      a0,a5
        lw      s0,428(sp)
        addi    sp,sp,432
        jr      ra
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:825bytes**
**Contents:**
text-8756
data-1372
bss-840
dec-10968
hex-2ad8
filename-hundered_o0.elf 
### Assembly code for o1:
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        li      a5,100
.L2:
        addi    a5,a5,-1
        bne     a5,zero,.L2
        li      a5,100
.L3:
        addi    a5,a5,-1
        bne     a5,zero,.L3
        li      a0,0
        ret
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:374bytes**
**Contents:**
   text-8632
   data-1372
   bss-840
   dec-10844
   hex-2a5c
   filename-hundered_o1.elf
### Assembly code for o2 : 
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .section        .text.startup,"ax",@progbits
        .align  2
        .globl  main
        .type   main, @function
main:
        li      a0,0
        ret
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:317bytes**
**Content:**
text-8608
data-1372
bss-840
dec-10820
hex-2a44
filename-hundered_o2.elf
### Assembly code for o3 : 
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .section        .text.startup,"ax",@progbits
        .align  2
        .globl  main
        .type   main, @function
main:
        li      a0,0
        ret
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:317bytes**
**Content:**
text-8608
data-1372
bss-840
dec-10820
hex-2a44
filename-hundered_o3.elf
### Assembly code for os : 
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .section        .text.startup,"ax",@progbits
        .align  2
        .globl  main
        .type   main, @function
main:
        li      a0,0
        ret
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:317bytes**
**Content:**
text-8608
data-1372
bss-840
dec-10820
hex-2a44
filename-hundered_os.elf
### Assembly code for ofast : 
        .file   "hundered.c"
        .option nopic
        .attribute arch, "rv32i2p1"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .section        .text.startup,"ax",@progbits
        .align  2
        .globl  main
        .type   main, @function
main:
        li      a0,0
        ret
        .size   main, .-main
        .ident  "GCC: (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0"
**SIZE:317bytes**   
**Content:**
text-8608
data-1372
bss-840
dec-10820
hex-2a44
filename-hundered_ofast.elf