Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C code
- #include <stdio.h>
- int main() {
- int n;
- double arr[100];
- printf("Enter the number of elements (1 to 100): ");
- scanf("%d", &n);
- for (int i = 0; i < n; ++i) {
- printf("Enter number%d: ", i + 1);
- scanf("%lf", &arr[i]);
- }
- // storing the largest number to arr[0]
- for (int i = 1; i < n; ++i) {
- if (arr[0] < arr[i]) {
- arr[0] = arr[i];
- }
- }
- printf("Largest element = %.2lf", arr[0]);
- return 0;
- }
- ---- Apple Silicon ARM Assembly
- .section __TEXT,__text,regular,pure_instructions
- .build_version macos, 13, 0 sdk_version 13, 3
- .globl _main ; -- Begin function main
- .p2align 2
- _main: ; @main
- .cfi_startproc
- ; %bb.0:
- stp x28, x27, [sp, #-32]! ; 16-byte Folded Spill
- .cfi_def_cfa_offset 32
- stp x29, x30, [sp, #16] ; 16-byte Folded Spill
- add x29, sp, #16
- .cfi_def_cfa w29, 16
- .cfi_offset w30, -8
- .cfi_offset w29, -16
- .cfi_offset w27, -24
- .cfi_offset w28, -32
- sub sp, sp, #832
- adrp x8, ___stack_chk_guard@GOTPAGE
- ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
- ldr x8, [x8]
- stur x8, [x29, #-24]
- str wzr, [sp, #20]
- adrp x0, l_.str@PAGE
- add x0, x0, l_.str@PAGEOFF
- bl _printf
- mov x9, sp
- add x8, sp, #16
- str x8, [x9]
- adrp x0, l_.str.1@PAGE
- add x0, x0, l_.str.1@PAGEOFF
- bl _scanf
- str wzr, [sp, #12]
- b LBB0_1
- LBB0_1: ; =>This Inner Loop Header: Depth=1
- ldr w8, [sp, #12]
- ldr w9, [sp, #16]
- subs w8, w8, w9
- cset w8, ge
- tbnz w8, #0, LBB0_4
- b LBB0_2
- LBB0_2: ; in Loop: Header=BB0_1 Depth=1
- ldr w8, [sp, #12]
- add w10, w8, #1
- mov x9, sp
- ; implicit-def: $x8
- mov x8, x10
- str x8, [x9]
- adrp x0, l_.str.2@PAGE
- add x0, x0, l_.str.2@PAGEOFF
- bl _printf
- ldrsw x9, [sp, #12]
- add x8, sp, #24
- add x8, x8, x9, lsl #3
- mov x9, sp
- str x8, [x9]
- adrp x0, l_.str.3@PAGE
- add x0, x0, l_.str.3@PAGEOFF
- bl _scanf
- b LBB0_3
- LBB0_3: ; in Loop: Header=BB0_1 Depth=1
- ldr w8, [sp, #12]
- add w8, w8, #1
- str w8, [sp, #12]
- b LBB0_1
- LBB0_4:
- mov w8, #1
- str w8, [sp, #8]
- b LBB0_5
- LBB0_5: ; =>This Inner Loop Header: Depth=1
- ldr w8, [sp, #8]
- ldr w9, [sp, #16]
- subs w8, w8, w9
- cset w8, ge
- tbnz w8, #0, LBB0_10
- b LBB0_6
- LBB0_6: ; in Loop: Header=BB0_5 Depth=1
- add x8, sp, #24
- ldr d0, [sp, #24]
- ldrsw x9, [sp, #8]
- ldr d1, [x8, x9, lsl #3]
- fcmp d0, d1
- cset w8, pl
- tbnz w8, #0, LBB0_8
- b LBB0_7
- LBB0_7: ; in Loop: Header=BB0_5 Depth=1
- ldrsw x9, [sp, #8]
- add x8, sp, #24
- ldr d0, [x8, x9, lsl #3]
- str d0, [sp, #24]
- b LBB0_8
- LBB0_8: ; in Loop: Header=BB0_5 Depth=1
- b LBB0_9
- LBB0_9: ; in Loop: Header=BB0_5 Depth=1
- ldr w8, [sp, #8]
- add w8, w8, #1
- str w8, [sp, #8]
- b LBB0_5
- LBB0_10:
- ldr d0, [sp, #24]
- mov x8, sp
- str d0, [x8]
- adrp x0, l_.str.4@PAGE
- add x0, x0, l_.str.4@PAGEOFF
- bl _printf
- ldur x9, [x29, #-24]
- adrp x8, ___stack_chk_guard@GOTPAGE
- ldr x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
- ldr x8, [x8]
- subs x8, x8, x9
- cset w8, eq
- tbnz w8, #0, LBB0_12
- b LBB0_11
- LBB0_11:
- bl ___stack_chk_fail
- LBB0_12:
- mov w0, #0
- add sp, sp, #832
- ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
- ldp x28, x27, [sp], #32 ; 16-byte Folded Reload
- ret
- .cfi_endproc
- ; -- End function
- .section __TEXT,__cstring,cstring_literals
- l_.str: ; @.str
- .asciz "Enter the number of elements (1 to 100): "
- l_.str.1: ; @.str.1
- .asciz "%d"
- l_.str.2: ; @.str.2
- .asciz "Enter number%d: "
- l_.str.3: ; @.str.3
- .asciz "%lf"
- l_.str.4: ; @.str.4
- .asciz "Largest element = %.2lf"
- .subsections_via_symbols
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement