#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);
void saxpy(double *v1, double *v2, double alpha, int n) {
  double *end;
  end = v1 + n;
  if (n <= 0) {
    printf(" n %d\n", n);
    exit(1);
  }
  for (; v1 < end; v1++, v2++)
    *v1 += *v2 * alpha;
  return;
}


x86 assembly (clang, -O0):
<saxpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     116e <saxpy+0x4e>
mov    -0x1c(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    1173 <saxpy+0x53>
mov    -0x8(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11bf <saxpy+0x9f>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1173 <saxpy+0x53>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saxpy>:
push   %rax
test   %edx,%edx
jle    12a9 <saxpy+0x189>
movslq %edx,%rax
lea    (%rdi,%rax,8),%rax
lea    0x8(%rdi),%rcx
cmp    %rcx,%rax
mov    %rcx,%r10
cmova  %rax,%r10
mov    %rdi,%rdx
not    %rdx
add    %rdx,%r10
cmp    $0x18,%r10
jb     1280 <saxpy+0x160>
cmp    %rcx,%rax
cmova  %rax,%rcx
add    %rdx,%rcx
and    $0xfffffffffffffff8,%rcx
lea    (%rsi,%rcx,1),%rdx
add    $0x8,%rdx
cmp    %rdi,%rdx
jbe    117c <saxpy+0x5c>
add    %rdi,%rcx
add    $0x8,%rcx
cmp    %rsi,%rcx
ja     1280 <saxpy+0x160>
shr    $0x3,%r10
add    $0x1,%r10
mov    %r10,%r8
and    $0xfffffffffffffffc,%r8
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%r8),%rcx
mov    %rcx,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rcx,%rcx
je     129f <saxpy+0x17f>
mov    %r9,%rcx
and    $0xfffffffffffffffe,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rsi,%rdx,8),%xmm2
movupd 0x10(%rsi,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
movupd (%rdi,%rdx,8),%xmm4
addpd  %xmm2,%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm2
movupd 0x20(%rdi,%rdx,8),%xmm5
movupd 0x30(%rdi,%rdx,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
movupd 0x20(%rsi,%rdx,8),%xmm2
movupd 0x30(%rsi,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,0x20(%rdi,%rdx,8)
movupd %xmm3,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rcx
jne    11c0 <saxpy+0xa0>
test   $0x1,%r9b
je     1266 <saxpy+0x146>
movupd (%rsi,%rdx,8),%xmm2
movupd 0x10(%rsi,%rdx,8),%xmm3
movupd (%rdi,%rdx,8),%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
cmp    %r8,%r10
je     129d <saxpy+0x17d>
lea    (%rdi,%r8,8),%rdi
lea    (%rsi,%r8,8),%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rsi),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi),%xmm1
movsd  %xmm1,(%rdi)
add    $0x8,%rdi
add    $0x8,%rsi
cmp    %rax,%rdi
jb     1280 <saxpy+0x160>
pop    %rax
ret
xor    %edx,%edx
test   $0x1,%r9b
jne    1235 <saxpy+0x115>
jmp    1266 <saxpy+0x146>
lea    0xd50(%rip),%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c" n %d\0A\00"
define void @saxpy(double* %0, double* %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca double*
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store i32 %3, i32* %8
%10 = load double*, double** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds double, double* %10, i64 %12
store double* %13, double** %9
%14 = load i32, i32* %8
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %4
%17 = load i32, i32* %8
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %4
br label %21
21: ; preds = %32, %20
%22 = load double*, double** %5
%23 = load double*, double** %9
%24 = icmp ult double* %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load double*, double** %6
%27 = load double, double* %26
%28 = load double, double* %7
%29 = load double*, double** %5
%30 = load double, double* %29
%31 = call double @llvm.fmuladd.f64(double %27, double %28, double %30)
store double %31, double* %29
br label %32
32: ; preds = %25
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i32 1
store double* %34, double** %5
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i32 1
store double* %36, double** %6
br label %21
37: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c" n %d\0A\00"
define void @saxpy(double* %0, double* nocapture %1, double %2, i32 %3) {
%5 = ptrtoint double* %0 to i64
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds double, double* %0, i64 %6
%8 = icmp slt i32 %3, 1
br i1 %8, label %112, label %9
9: ; preds = %4
%10 = shl nsw i64 %6, 3
%11 = add i64 %10, %5
%12 = add i64 %5, 8
%13 = call i64 @llvm.umax.i64(i64 %11, i64 %12)
%14 = xor i64 %5, -1
%15 = add i64 %13, %14
%16 = lshr i64 %15, 3
%17 = add nuw nsw i64 %16, 1
%18 = icmp ult i64 %15, 24
br i1 %18, label %109, label %19
19: ; preds = %9
%20 = shl nsw i64 %6, 3
%21 = add i64 %20, %5
%22 = add i64 %5, 8
%23 = call i64 @llvm.umax.i64(i64 %21, i64 %22)
%24 = xor i64 %5, -1
%25 = add i64 %23, %24
%26 = lshr i64 %25, 3
%27 = add nuw nsw i64 %26, 1
%28 = getelementptr double, double* %0, i64 %27
%29 = getelementptr double, double* %1, i64 %27
%30 = icmp ugt double* %29, %0
%31 = icmp ugt double* %28, %1
%32 = and i1 %30, %31
br i1 %32, label %109, label %33
33: ; preds = %19
%34 = and i64 %17, 4611686018427387900
%35 = getelementptr double, double* %0, i64 %34
%36 = getelementptr double, double* %1, i64 %34
%37 = insertelement <2 x double> poison, double %2, i64 0
%38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
%39 = insertelement <2 x double> poison, double %2, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
%41 = add nsw i64 %34, -4
%42 = lshr exact i64 %41, 2
%43 = add nuw nsw i64 %42, 1
%44 = and i64 %43, 1
%45 = icmp eq i64 %41, 0
br i1 %45, label %87, label %46
46: ; preds = %33
%47 = and i64 %43, 9223372036854775806
br label %48
48: ; preds = %48, %46
%49 = phi i64 [ 0, %46 ], [ %84, %48 ]
%50 = phi i64 [ 0, %46 ], [ %85, %48 ]
%51 = getelementptr double, double* %0, i64 %49
%52 = getelementptr double, double* %1, i64 %49
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = getelementptr double, double* %52, i64 2
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = bitcast double* %51 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr double, double* %51, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %54, <2 x double> %38, <2 x double> %59)
%64 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> %40, <2 x double> %62)
%65 = bitcast double* %51 to <2 x double>*
store <2 x double> %63, <2 x double>* %65
%66 = bitcast double* %60 to <2 x double>*
store <2 x double> %64, <2 x double>* %66
%67 = or i64 %49, 4
%68 = getelementptr double, double* %0, i64 %67
%69 = getelementptr double, double* %1, i64 %67
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = bitcast double* %68 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = getelementptr double, double* %68, i64 2
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %71, <2 x double> %38, <2 x double> %76)
%81 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %74, <2 x double> %40, <2 x double> %79)
%82 = bitcast double* %68 to <2 x double>*
store <2 x double> %80, <2 x double>* %82
%83 = bitcast double* %77 to <2 x double>*
store <2 x double> %81, <2 x double>* %83
%84 = add nuw i64 %49, 8
%85 = add i64 %50, 2
%86 = icmp eq i64 %85, %47
br i1 %86, label %87, label %48
87: ; preds = %48, %33
%88 = phi i64 [ 0, %33 ], [ %84, %48 ]
%89 = icmp eq i64 %44, 0
br i1 %89, label %107, label %90
90: ; preds = %87
%91 = getelementptr double, double* %0, i64 %88
%92 = getelementptr double, double* %1, i64 %88
%93 = bitcast double* %92 to <2 x double>*
%94 = load <2 x double>, <2 x double>* %93
%95 = getelementptr double, double* %92, i64 2
%96 = bitcast double* %95 to <2 x double>*
%97 = load <2 x double>, <2 x double>* %96
%98 = bitcast double* %91 to <2 x double>*
%99 = load <2 x double>, <2 x double>* %98
%100 = getelementptr double, double* %91, i64 2
%101 = bitcast double* %100 to <2 x double>*
%102 = load <2 x double>, <2 x double>* %101
%103 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %94, <2 x double> %38, <2 x double> %99)
%104 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %97, <2 x double> %40, <2 x double> %102)
%105 = bitcast double* %91 to <2 x double>*
store <2 x double> %103, <2 x double>* %105
%106 = bitcast double* %100 to <2 x double>*
store <2 x double> %104, <2 x double>* %106
br label %107
107: ; preds = %87, %90
%108 = icmp eq i64 %17, %34
br i1 %108, label %124, label %109
109: ; preds = %19, %9, %107
%110 = phi double* [ %0, %19 ], [ %0, %9 ], [ %35, %107 ]
%111 = phi double* [ %1, %19 ], [ %1, %9 ], [ %36, %107 ]
br label %115
112: ; preds = %4
%113 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3)
%114 = tail call i32 @exit(i32 1)
unreachable
115: ; preds = %109, %115
%116 = phi double* [ %121, %115 ], [ %110, %109 ]
%117 = phi double* [ %122, %115 ], [ %111, %109 ]
%118 = load double, double* %117
%119 = load double, double* %116
%120 = tail call double @llvm.fmuladd.f64(double %118, double %2, double %119)
store double %120, double* %116
%121 = getelementptr inbounds double, double* %116, i64 1
%122 = getelementptr inbounds double, double* %117, i64 1
%123 = icmp ult double* %121, %7
br i1 %123, label %115, label %124
124: ; preds = %115, %107
ret void
}