#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*/ calc_sum(int, double *, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int read_vecs(int *, double *, double *);
void main() {
  double x[100], y[100], z[100];
  int vecsize;
  double *f = x;
  double *g = y;
  double *h = z;
  int check = read_vecs(&vecsize, f, g);
  if (check == -1) {
    printf("Input format error\n");
  } else {
    calc_sum(vecsize, f, g, h);
    int i;
    for (i = 0; i < vecsize; i++) {
      printf("%f\n", z[i]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x990,%rsp
lea    -0x320(%rbp),%rax
mov    %rax,-0x970(%rbp)
lea    -0x640(%rbp),%rax
mov    %rax,-0x978(%rbp)
lea    -0x960(%rbp),%rax
mov    %rax,-0x980(%rbp)
mov    -0x970(%rbp),%rsi
mov    -0x978(%rbp),%rdx
lea    -0x964(%rbp),%rdi
call   1050 <read_vecs@plt>
mov    %eax,-0x984(%rbp)
cmpl   $0xffffffff,-0x984(%rbp)
jne    11a5 <main+0x75>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xe8>
mov    -0x964(%rbp),%edi
mov    -0x970(%rbp),%rsi
mov    -0x978(%rbp),%rdx
mov    -0x980(%rbp),%rcx
call   1040 <calc_sum@plt>
movl   $0x0,-0x988(%rbp)
mov    -0x988(%rbp),%eax
cmp    -0x964(%rbp),%eax
jge    1213 <main+0xe3>
movslq -0x988(%rbp),%rax
movsd  -0x960(%rbp,%rax,8),%xmm0
ff ff
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x988(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x988(%rbp)
jmp    11cf <main+0x9f>
jmp    1218 <main+0xe8>
add    $0x990,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x978,%rsp
lea    0xc(%rsp),%rdi
lea    0x650(%rsp),%rsi
lea    0x330(%rsp),%rdx
call   1060 <read_vecs@plt>
cmp    $0xffffffff,%eax
je     11c0 <main+0x80>
mov    0xc(%rsp),%edi
lea    0x650(%rsp),%rsi
lea    0x330(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <calc_sum@plt>
cmpl   $0x0,0xc(%rsp)
jle    11cc <main+0x8c>
xor    %ebx,%ebx
lea    0xe69(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsd  0x10(%rsp,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11a0 <main+0x60>
jmp    11cc <main+0x8c>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x978,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Input format error\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define void @main() {
%1 = alloca [100 x double]
%2 = alloca [100 x double]
%3 = alloca [100 x double]
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [100 x double], [100 x double]* %1, i64 0, i64 0
store double* %10, double** %5
%11 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 0
store double* %11, double** %6
%12 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
store double* %12, double** %7
%13 = load double*, double** %5
%14 = load double*, double** %6
%15 = call i32 @read_vecs(i32* %4, double* %13, double* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %40
20: ; preds = %0
%21 = load i32, i32* %4
%22 = load double*, double** %5
%23 = load double*, double** %6
%24 = load double*, double** %7
%25 = call i32 @calc_sum(i32 %21, double* %22, double* %23, double* %24)
store i32 0, i32* %9
br label %26
26: ; preds = %36, %20
%27 = load i32, i32* %9
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %32
%34 = load double, double* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %26
39: ; preds = %26
br label %40
40: ; preds = %39, %18
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%f\0A\00"
@str = [19 x i8] c"Input format error\00"
define void @main() {
%1 = alloca [100 x double]
%2 = alloca [100 x double]
%3 = alloca [100 x double]
%4 = alloca i32
%5 = bitcast [100 x double]* %1 to i8*
%6 = bitcast [100 x double]* %2 to i8*
%7 = bitcast [100 x double]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [100 x double], [100 x double]* %1, i64 0, i64 0
%10 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 0
%11 = call i32 @read_vecs(i32* %4, double* %9, double* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %30
15: ; preds = %0
%16 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
%17 = load i32, i32* %4
%18 = call i32 @calc_sum(i32 %17, double* %9, double* %10, double* %16)
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %15, %21
%22 = phi i64 [ %26, %21 ], [ 0, %15 ]
%23 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %22
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = add nuw nsw i64 %22, 1
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %21, label %30
30: ; preds = %21, %15, %13
ret void
}