#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ calc_diff(int, double *, double *, double *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, 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_diff(vecsize, f, g, h);
    FILE *fp;
    fp = fopen("vector_out.dat", "w");
    int i;
    for (i = 0; i < vecsize; i++) {
      fprintf(fp, "%f\n", z[i]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9a0,%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   1070 <read_vecs@plt>
mov    %eax,-0x984(%rbp)
cmpl   $0xffffffff,-0x984(%rbp)
jne    11c3 <main+0x73>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    1255 <main+0x105>
mov    -0x964(%rbp),%edi
mov    -0x970(%rbp),%rsi
mov    -0x978(%rbp),%rdx
mov    -0x980(%rbp),%rcx
call   1050 <calc_diff@plt>
lea    0xe2a(%rip),%rdi
lea    0xe32(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x990(%rbp)
movl   $0x0,-0x994(%rbp)
mov    -0x994(%rbp),%eax
cmp    -0x964(%rbp),%eax
jge    1250 <main+0x100>
mov    -0x990(%rbp),%rdi
movslq -0x994(%rbp),%rax
movsd  -0x960(%rbp,%rax,8),%xmm0
ff ff
lea    0xdee(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x994(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x994(%rbp)
jmp    1207 <main+0xb7>
jmp    1255 <main+0x105>
add    $0x9a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x970,%rsp
lea    0xc(%rsp),%rdi
lea    0x650(%rsp),%rsi
lea    0x330(%rsp),%rdx
call   1070 <read_vecs@plt>
cmp    $0xffffffff,%eax
je     11e1 <main+0x91>
mov    0xc(%rsp),%edi
lea    0x650(%rsp),%rsi
lea    0x330(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <calc_diff@plt>
lea    0xe60(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1060 <fopen@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ed <main+0x9d>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xe52(%rip),%r14
nop
movsd  0x10(%rsp,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <main+0x70>
jmp    11ed <main+0x9d>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
add    $0x970,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [15 x i8] c"vector_out.dat\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [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 %31
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_diff(i32 %17, double* %9, double* %10, double* %16)
%19 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %15, %22
%23 = phi i64 [ %27, %22 ], [ 0, %15 ]
%24 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %23
%25 = load double, double* %24
%26 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %25)
%27 = add nuw nsw i64 %23, 1
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %22, label %31
31: ; preds = %22, %15, %13
ret void
}