#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*/ printf(char *, double);
double update(double);
int main() {
  int i = 0;
  double input[20] = {0, 300, 600, 900, 600, 300, 500, 00, 100, 10,
                      0, 0,   100, 25,  10,  40,  80,  10, 0,   9};
  for (i = 0; i < 20; i++) {
    printf("ketqua : %f\n", update(input[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    119e <main+0x6e>
movslq -0x8(%rbp),%rax
movsd  -0xb0(%rbp,%rax,8),%xmm0
ff ff
call   1030 <update@plt>
lea    0xf15(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1168 <main+0x38>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
lea    0xed2(%rip),%r15
lea    0xf6b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%r15,1),%xmm0
call   1030 <update@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x8,%rbx
cmp    $0xa0,%rbx
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.input = [20 x double] [double 0.000000e+00, double 3.000000e+02, double 6.000000e+02, double 9.000000e+02, double 6.000000e+02, double 3.000000e+02, double 5.000000e+02, double 0.000000e+00, double 1.000000e+02, double 1.000000e+01, double 0.000000e+00, double 0.000000e+00, double 1.000000e+02, double 2.500000e+01, double 1.000000e+01, double 4.000000e+01, double 8.000000e+01, double 1.000000e+01, double 0.000000e+00, double 9.000000e+00]
@.str = [13 x i8] c"ketqua : %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x double]
store i32 0, i32* %1
store i32 0, i32* %2
%4 = bitcast [20 x double]* %3 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 0, i64 %10
%12 = load double, double* %11
%13 = call double @update(double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %13)
br label %15
15: ; preds = %8
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %5
18: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@__const.main.input = [20 x double] [double 0.000000e+00, double 3.000000e+02, double 6.000000e+02, double 9.000000e+02, double 6.000000e+02, double 3.000000e+02, double 5.000000e+02, double 0.000000e+00, double 1.000000e+02, double 1.000000e+01, double 0.000000e+00, double 0.000000e+00, double 1.000000e+02, double 2.500000e+01, double 1.000000e+01, double 4.000000e+01, double 8.000000e+01, double 1.000000e+01, double 0.000000e+00, double 9.000000e+00]
@.str = [13 x i8] c"ketqua : %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %7, %1 ]
%3 = getelementptr inbounds [20 x double], [20 x double]* @__const.main.input, i64 0, i64 %2
%4 = load double, double* %3
%5 = tail call double @update(double %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %5)
%7 = add nuw nsw i64 %2, 1
%8 = icmp eq i64 %7, 20
br i1 %8, label %9, label %1
9: ; preds = %1
ret i32 0
}