#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 *, ...);
scalar_t__ test(int, double *, int);
int main() {
  int err = 0;
  double m0[] = {1, 1., 0, 1};
  err += test(2, m0, 0);
  double ms[] = {1, 3., 1, 3};
  err += test(2, ms, 1);
  double m1[] = {25, 15, -5, 15, 18, 0, -5, 0, 11};
  err += test(3, m1, 0);
  double m2[] = {18, 22, 54,  42,  22, 70, 86,  62,
                 54, 86, 174, 134, 42, 62, 134, 106};
  err += test(4, m2, 0);
  if (err) {
    printf("OVERALL FAILURE, %i errors\n", err);
    return 1;
  }
  printf("OVERALL SUCCESS, no errors\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x2,%edi
xor    %edx,%edx
call   1050 <test@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x50(%rbp),%rsi
mov    $0x2,%edi
mov    $0x1,%edx
call   1050 <test@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
lea    -0xa0(%rbp),%rsi
mov    $0x3,%edi
xor    %edx,%edx
call   1050 <test@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
lea    -0x120(%rbp),%rsi
mov    $0x4,%edi
xor    %edx,%edx
call   1050 <test@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1275 <main+0x145>
mov    -0x8(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128a <main+0x15a>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rsi
mov    $0x2,%edi
xor    %edx,%edx
call   1050 <test@plt>
mov    %rax,%rbx
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%r14d
mov    $0x2,%edi
mov    $0x1,%edx
call   1050 <test@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    0xede(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe6b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rsi
mov    $0x3,%edi
xor    %edx,%edx
call   1050 <test@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movaps 0xf09(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe6e(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe4f(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe30(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
lea    0x90(%rsp),%rsi
mov    $0x4,%edi
xor    %edx,%edx
call   1050 <test@plt>
add    %ebx,%eax
je     1292 <main+0x162>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a1 <main+0x171>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.m0 = [4 x double] [double 1.000000e+00, double 1.000000e+00, double 0.000000e+00, double 1.000000e+00]
@__const.main.ms = [4 x double] [double 1.000000e+00, double 3.000000e+00, double 1.000000e+00, double 3.000000e+00]
@__const.main.m1 = [9 x double] [double 2.500000e+01, double 1.500000e+01, double -5.000000e+00, double 1.500000e+01, double 1.800000e+01, double 0.000000e+00, double -5.000000e+00, double 0.000000e+00, double 1.100000e+01]
@__const.main.m2 = [16 x double] [double 1.800000e+01, double 2.200000e+01, double 5.400000e+01, double 4.200000e+01, double 2.200000e+01, double 7.000000e+01, double 8.600000e+01, double 6.200000e+01, double 5.400000e+01, double 8.600000e+01, double 1.740000e+02, double 1.340000e+02, double 4.200000e+01, double 6.200000e+01, double 1.340000e+02, double 1.060000e+02]
@.str = [28 x i8] c"OVERALL FAILURE, %i errors\0A\00"
@.str.1 = [28 x i8] c"OVERALL SUCCESS, no errors\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x double]
%4 = alloca [4 x double]
%5 = alloca [9 x double]
%6 = alloca [16 x double]
store i32 0, i32* %1
store i32 0, i32* %2
%7 = bitcast [4 x double]* %3 to i8*
%8 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%9 = call i64 @test(i32 2, double* %8, i32 0)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %9
%13 = trunc i64 %12 to i32
store i32 %13, i32* %2
%14 = bitcast [4 x double]* %4 to i8*
%15 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 0
%16 = call i64 @test(i32 2, double* %15, i32 1)
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
%21 = bitcast [9 x double]* %5 to i8*
%22 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
%23 = call i64 @test(i32 3, double* %22, i32 0)
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %2
%28 = bitcast [16 x double]* %6 to i8*
%29 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 0
%30 = call i64 @test(i32 4, double* %29, i32 0)
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = add nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %2
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %0
%38 = load i32, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %38)
store i32 1, i32* %1
br label %42
40: ; preds = %0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %40, %37
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@__const.main.m0 = [4 x double] [double 1.000000e+00, double 1.000000e+00, double 0.000000e+00, double 1.000000e+00]
@__const.main.ms = [4 x double] [double 1.000000e+00, double 3.000000e+00, double 1.000000e+00, double 3.000000e+00]
@__const.main.m1 = [9 x double] [double 2.500000e+01, double 1.500000e+01, double -5.000000e+00, double 1.500000e+01, double 1.800000e+01, double 0.000000e+00, double -5.000000e+00, double 0.000000e+00, double 1.100000e+01]
@__const.main.m2 = [16 x double] [double 1.800000e+01, double 2.200000e+01, double 5.400000e+01, double 4.200000e+01, double 2.200000e+01, double 7.000000e+01, double 8.600000e+01, double 6.200000e+01, double 5.400000e+01, double 8.600000e+01, double 1.740000e+02, double 1.340000e+02, double 4.200000e+01, double 6.200000e+01, double 1.340000e+02, double 1.060000e+02]
@.str = [28 x i8] c"OVERALL FAILURE, %i errors\0A\00"
@str = [27 x i8] c"OVERALL SUCCESS, no errors\00"
define i32 @main() {
%1 = alloca [4 x double]
%2 = alloca [4 x double]
%3 = alloca [9 x double]
%4 = alloca [16 x double]
%5 = bitcast [4 x double]* %1 to i8*
%6 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%7 = call i64 @test(i32 2, double* %6, i32 0)
%8 = bitcast [4 x double]* %2 to i8*
%9 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%10 = call i64 @test(i32 2, double* %9, i32 1)
%11 = add i64 %10, %7
%12 = bitcast [9 x double]* %3 to i8*
%13 = getelementptr inbounds [9 x double], [9 x double]* %3, i64 0, i64 0
%14 = call i64 @test(i32 3, double* %13, i32 0)
%15 = add i64 %11, %14
%16 = bitcast [16 x double]* %4 to i8*
%17 = getelementptr inbounds [16 x double], [16 x double]* %4, i64 0, i64 0
%18 = call i64 @test(i32 4, double* %17, i32 0)
%19 = add i64 %15, %18
%20 = trunc i64 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %26
24: ; preds = %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ 1, %22 ], [ 0, %24 ]
ret i32 %27
}