#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, const char *argv[]) {
  float arr[20];
  int i, j, num, temp;
  num = 0;
  printf("Enter no of array elements: ");
  scanf("%d", &num);
  if (num == 0) {
    printf("Error. Enter a valid length.");
    exit(1);
  }
  if (num > 20) {
    printf("Maximum array length exceeded. Exiting.\n");
    exit(1);
  }
  for (i = 0; i < num; i++) {
    printf("Array element %d : ", i + 1);
    scanf("%f", &arr[i]);
  }
  j = i - 1;
  i = 0;
  temp = 0;
  while (i < j) {
    temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
    i++;
    j--;
  }
  printf("\nResult after reversal : \n");
  for (i = 0; i < num; i++) {
    printf("Array element %d: %f\n", i + 1, arr[i]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x6c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    118f <main+0x5f>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x14,-0x6c(%rbp)
jle    11b1 <main+0x81>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    1203 <main+0xd3>
mov    -0x64(%rbp),%esi
add    $0x1,%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x64(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b8 <main+0x88>
mov    -0x64(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    126d <main+0x13d>
movslq -0x64(%rbp),%rax
cvttss2si -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x70(%rbp)
movslq -0x68(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm0
movslq -0x64(%rbp),%rax
movss  %xmm0,-0x60(%rbp,%rax,4)
cvtsi2ssl -0x70(%rbp),%xmm0
movslq -0x68(%rbp),%rax
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    121a <main+0xea>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    12be <main+0x18e>
mov    -0x64(%rbp),%esi
add    $0x1,%esi
movslq -0x64(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1282 <main+0x152>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1272 <main+0x132>
cmp    $0x14,%eax
jg     128a <main+0x14a>
test   %eax,%eax
jle    121f <main+0xdf>
lea    0x10(%rsp),%r14
lea    0xea0(%rip),%r15
lea    0xead(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
add    $0x4,%r14
cmp    %rax,%rbx
jl     11b0 <main+0x70>
cmp    $0x2,%ebx
jl     121f <main+0xdf>
add    $0xfffffffffffffffe,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movss  0x14(%rsp,%rbx,4),%xmm0
movss  0x10(%rsp,%rax,4),%xmm1
movss  %xmm0,0x10(%rsp,%rax,4)
cvttps2dq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
movss  %xmm0,0x14(%rsp,%rbx,4)
add    $0x1,%rax
lea    -0x1(%rbx),%rcx
cmp    %rbx,%rax
mov    %rcx,%rbx
jl     11f0 <main+0xb0>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    1264 <main+0x124>
xor    %ebx,%ebx
lea    0xe19(%rip),%r14
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp,%rbx,4),%xmm0
add    $0x1,%rbx
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1240 <main+0x100>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xda7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xdf3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Enter no of array elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"Error. Enter a valid length.\00"
@.str.3 = [41 x i8] c"Maximum array length exceeded. Exiting.\0A\00"
@.str.4 = [20 x i8] c"Array element %d : \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [27 x i8] c"\0AResult after reversal : \0A\00"
@.str.7 = [22 x i8] c"Array element %d: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x float]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i32, i32* %9
%20 = icmp sgt i32 %19, 20
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %18
store i32 0, i32* %7
br label %25
25: ; preds = %37, %24
%26 = load i32, i32* %7
%27 = load i32, i32* %9
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %34
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %25
40: ; preds = %25
%41 = load i32, i32* %7
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %8
store i32 0, i32* %7
store i32 0, i32* %10
br label %43
43: ; preds = %47, %40
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %69
47: ; preds = %43
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %49
%51 = load float, float* %50
%52 = fptosi float %51 to i32
store i32 %52, i32* %10
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %54
%56 = load float, float* %55
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %58
store float %56, float* %59
%60 = load i32, i32* %10
%61 = sitofp i32 %60 to float
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %63
store float %61, float* %64
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
%67 = load i32, i32* %8
%68 = add nsw i32 %67, -1
store i32 %68, i32* %8
br label %43
69: ; preds = %43
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %71
71: ; preds = %84, %69
%72 = load i32, i32* %7
%73 = load i32, i32* %9
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %87
75: ; preds = %71
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [20 x float], [20 x float]* %6, i64 0, i64 %79
%81 = load float, float* %80
%82 = fpext float %81 to double
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %77, double %82)
br label %84
84: ; preds = %75
%85 = load i32, i32* %7
%86 = add nsw i32 %85, 1
store i32 %86, i32* %7
br label %71
87: ; preds = %71
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter no of array elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"Error. Enter a valid length.\00"
@.str.4 = [20 x i8] c"Array element %d : \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.7 = [22 x i8] c"Array element %d: %f\0A\00"
@str = [26 x i8] c"\0AResult after reversal : \00"
@str.8 = [40 x i8] c"Maximum array length exceeded. Exiting.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x float]
%4 = alloca i32
%5 = bitcast [20 x float]* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp sgt i32 %9, 20
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = icmp sgt i32 %9, 0
br i1 %17, label %27, label %49
18: ; preds = %14
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %27
%22 = trunc i64 %29 to i32
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %49
24: ; preds = %21
%25 = and i64 %29, 4294967295
%26 = add nsw i64 %25, -1
br label %37
27: ; preds = %16, %27
%28 = phi i64 [ %29, %27 ], [ 0, %16 ]
%29 = add nuw nsw i64 %28, 1
%30 = trunc i64 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [20 x float], [20 x float]* %3, i64 0, i64 %28
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %32)
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %29, %35
br i1 %36, label %27, label %21
37: ; preds = %24, %37
%38 = phi i64 [ 0, %24 ], [ %46, %37 ]
%39 = phi i64 [ %26, %24 ], [ %47, %37 ]
%40 = getelementptr inbounds [20 x float], [20 x float]* %3, i64 0, i64 %38
%41 = load float, float* %40
%42 = fptosi float %41 to i32
%43 = getelementptr inbounds [20 x float], [20 x float]* %3, i64 0, i64 %39
%44 = load float, float* %43
store float %44, float* %40
%45 = sitofp i32 %42 to float
store float %45, float* %43
%46 = add nuw nsw i64 %38, 1
%47 = add nsw i64 %39, -1
%48 = icmp slt i64 %46, %47
br i1 %48, label %37, label %49
49: ; preds = %37, %16, %21
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%51 = load i32, i32* %4
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %64
53: ; preds = %49, %53
%54 = phi i64 [ %55, %53 ], [ 0, %49 ]
%55 = add nuw nsw i64 %54, 1
%56 = getelementptr inbounds [20 x float], [20 x float]* %3, i64 0, i64 %54
%57 = load float, float* %56
%58 = fpext float %57 to double
%59 = trunc i64 %55 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %59, double %58)
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = icmp slt i64 %55, %62
br i1 %63, label %53, label %64
64: ; preds = %53, %49
ret i32 0
}