#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 const, ...);
void test(const double x[][2 + 1], const double y[], const double w[]) {
  double sigma, y_hat;
  for (int j = 0; j < 4; j++) {
    sigma = 0.;
    for (int i = 0; i < 2 + 1; i++)
      sigma += x[j][i] * w[i];
    y_hat = (sigma >= 0) ? 1 : 0;
    printf("Test %d - x: ", j);
    for (int i = 0; i < 2 + 1; i++)
      printf("%f ", x[j][i]);
    printf("\t - t: %f - y: %f\n", y[j], y_hat);
  }
  return;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    1238 <test+0x128>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    1193 <test+0x83>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1144 <test+0x34>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    120a <test+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe19(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cc <test+0xbc>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xdef(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112b <test+0x1b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x10,%rbx
xor    %r12d,%r12d
lea    0xeec(%rip),%r13
lea    0xee9(%rip),%rbp
nopl   0x0(%rax)
movsd  -0x10(%rbx),%xmm0
movsd  -0x8(%rbx),%xmm1
mulsd  (%r15),%xmm0
mulsd  0x8(%r15),%xmm1
addsd  0xeab(%rip),%xmm0
movsd  (%rbx),%xmm2
mulsd  0x10(%r15),%xmm2
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbx),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x8(%rbx),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rbx),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorpd  %xmm1,%xmm1
cmplesd (%rsp),%xmm1
movsd  0xe38(%rip),%xmm0
andpd  %xmm0,%xmm1
movsd  (%r14,%r12,8),%xmm0
mov    %rbp,%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x1,%r12
add    $0x18,%rbx
cmp    $0x4,%r12
jne    1140 <test+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Test %d - x: \00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [19 x i8] c"\09 - t: %f - y: %f\0A\00"
define void @test([3 x double]* %0, double* %1, double* %2) {
%4 = alloca [3 x double]*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store [3 x double]* %0, [3 x double]** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %9
br label %12
12: ; preds = %71, %3
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %74
15: ; preds = %12
store double 0.000000e+00, double* %7
store i32 0, i32* %10
br label %16
16: ; preds = %35, %15
%17 = load i32, i32* %10
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load [3 x double]*, [3 x double]** %4
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 %22
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 0, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %6
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double, double* %7
%34 = call double @llvm.fmuladd.f64(double %27, double %32, double %33)
store double %34, double* %7
br label %35
35: ; preds = %19
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %16
38: ; preds = %16
%39 = load double, double* %7
%40 = fcmp oge double %39, 0.000000e+00
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 1, i32 0
%43 = sitofp i32 %42 to double
store double %43, double* %8
%44 = load i32, i32* %9
%45 = sitofp i32 %44 to double
%46 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %45)
store i32 0, i32* %11
br label %47
47: ; preds = %60, %38
%48 = load i32, i32* %11
%49 = icmp slt i32 %48, 3
br i1 %49, label %50, label %63
50: ; preds = %47
%51 = load [3 x double]*, [3 x double]** %4
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [3 x double], [3 x double]* %51, i64 %53
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [3 x double], [3 x double]* %54, i64 0, i64 %56
%58 = load double, double* %57
%59 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %58)
br label %60
60: ; preds = %50
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %47
63: ; preds = %47
%64 = load double*, double** %5
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double, double* %8
%70 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %68, double %69)
br label %71
71: ; preds = %63
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %12
74: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Test %d - x: \00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [19 x i8] c"\09 - t: %f - y: %f\0A\00"
define void @test([3 x double]* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %2, i64 1
%5 = getelementptr inbounds double, double* %2, i64 2
br label %6
6: ; preds = %3, %6
%7 = phi i64 [ 0, %3 ], [ %34, %6 ]
%8 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %7, i64 0
%9 = load double, double* %8
%10 = load double, double* %2
%11 = tail call double @llvm.fmuladd.f64(double %9, double %10, double 0.000000e+00)
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %7, i64 1
%13 = load double, double* %12
%14 = load double, double* %4
%15 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %11)
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %7, i64 2
%17 = load double, double* %16
%18 = load double, double* %5
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %15)
%20 = fcmp oge double %19, 0.000000e+00
%21 = trunc i64 %7 to i32
%22 = sitofp i32 %21 to double
%23 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %22)
%24 = load double, double* %8
%25 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = load double, double* %12
%27 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %26)
%28 = load double, double* %16
%29 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = uitofp i1 %20 to double
%31 = getelementptr inbounds double, double* %1, i64 %7
%32 = load double, double* %31
%33 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %32, double %30)
%34 = add nuw nsw i64 %7, 1
%35 = icmp eq i64 %34, 4
br i1 %35, label %36, label %6
36: ; preds = %6
ret void
}