#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 exp(double);
double sqrt(int);
unsigned char classify(int y, int Cr, unsigned char *copper,
                       unsigned char *silver, int k) {
  double index1 = 0.0000, index2 = 0.0000;
  double del_1Y, del_1Cr, del_2Y, del_2Cr;
  double prob1, prob2;
  del_1Y = y - 82;
  del_1Cr = Cr - 143;
  del_2Y = y - 110;
  del_2Cr = Cr - 131;
  index1 = (1.0 / (1.0 - (15876.0 / (485 * 53)))) *
           (del_1Y * del_1Y / 485 + del_1Cr * del_1Cr / 53 -
            2 * (126.0 / (485 * 53)) * del_1Y * del_1Cr);
  index2 = (1.0 / (1.0 - (16.0 / (414 * 7)))) *
           (del_2Y * del_2Y / 414 + del_2Cr * del_2Cr / 7 -
            2 * (4.0 / (414 * 7)) * del_2Y * del_2Cr);
  prob1 = (1.0 / 2.0 * 3.14159265359) /
          sqrt(485 * 53 * (1.0 - (15876.0 / (485 * 53))) * exp(index1));
  prob2 = (1.0 / 2.0 * 3.14159265359) /
          sqrt(414 * 7 * (1.0 - (16.0 / (414 * 7))) * exp(index2));
  if (prob1 < prob2) {
    silver[k] = 1;
    return 2;
  } else {
    copper[k] = 1;
    return 1;
  }
}


x86 assembly (clang, -O0):
<classify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x52,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x8f,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x6e,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x83,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xeb4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xe96(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe7e(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  0xe04(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xdec(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdb3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd8c(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd64(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd4d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd2d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1305 <classify+0x1e5>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
movb   $0x2,-0x1(%rbp)
jmp    1315 <classify+0x1f5>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
movb   $0x1,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<classify>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbp
mov    %rdx,%rbx
movd   %esi,%xmm0
movd   %edi,%xmm1
punpckldq %xmm0,%xmm1
movdqa 0xebb(%rip),%xmm0
paddd  %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
paddd  0xebb(%rip),%xmm1
cvtdq2pd %xmm1,%xmm3
movapd %xmm0,%xmm1
mulpd  %xmm0,%xmm1
divpd  0xeb7(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
movsd  0xed3(%rip),%xmm1
mulsd  %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xec3(%rip),%xmm0
movapd %xmm3,%xmm1
mulpd  %xmm3,%xmm1
divpd  0xe8b(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
movsd  0xea7(%rip),%xmm1
mulsd  %xmm3,%xmm1
unpckhpd %xmm3,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
mulsd  0xe97(%rip),%xmm3
movapd %xmm3,0x10(%rsp)
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe85(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <exp@plt>
imul   $0xb42,%eax,%edi
call   1040 <sqrt@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xe20(%rip),%xmm0
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
ucomisd %xmm0,%xmm1
seta   %al
cmova  %rbp,%rbx
movslq %r14d,%rcx
add    $0x1,%al
movb   $0x1,(%rbx,%rcx,1)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @classify(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 82
%22 = sitofp i32 %21 to double
store double %22, double* %14
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 143
%25 = sitofp i32 %24 to double
store double %25, double* %15
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 110
%28 = sitofp i32 %27 to double
store double %28, double* %16
%29 = load i32, i32* %8
%30 = sub nsw i32 %29, 131
%31 = sitofp i32 %30 to double
store double %31, double* %17
%32 = load double, double* %14
%33 = load double, double* %14
%34 = fmul double %32, %33
%35 = fdiv double %34, 4.850000e+02
%36 = load double, double* %15
%37 = load double, double* %15
%38 = fmul double %36, %37
%39 = fdiv double %38, 5.300000e+01
%40 = fadd double %35, %39
%41 = load double, double* %14
%42 = fmul double 0x3F8413E0E33A5EDF, %41
%43 = load double, double* %15
%44 = fneg double %42
%45 = call double @llvm.fmuladd.f64(double %44, double %43, double %40)
%46 = fmul double 0x4004EBF89A65A109, %45
store double %46, double* %12
%47 = load double, double* %16
%48 = load double, double* %16
%49 = fmul double %47, %48
%50 = fdiv double %49, 4.140000e+02
%51 = load double, double* %17
%52 = load double, double* %17
%53 = fmul double %51, %52
%54 = fdiv double %53, 7.000000e+00
%55 = fadd double %50, %54
%56 = load double, double* %16
%57 = fmul double 0x3F669D3D4E44322D, %56
%58 = load double, double* %17
%59 = fneg double %57
%60 = call double @llvm.fmuladd.f64(double %59, double %58, double %55)
%61 = fmul double 0x3FF016BD612D4D47, %60
store double %61, double* %13
%62 = load double, double* %12
%63 = call i32 @exp(double %62)
%64 = sitofp i32 %63 to double
%65 = fmul double 0x40C3328000000001, %64
%66 = fptosi double %65 to i32
%67 = call double @sqrt(i32 %66)
%68 = fdiv double 0x3FF921FB54442EEA, %67
store double %68, double* %18
%69 = load double, double* %13
%70 = call i32 @exp(double %69)
%71 = sitofp i32 %70 to double
%72 = fmul double 2.882000e+03, %71
%73 = fptosi double %72 to i32
%74 = call double @sqrt(i32 %73)
%75 = fdiv double 0x3FF921FB54442EEA, %74
store double %75, double* %19
%76 = load double, double* %18
%77 = load double, double* %19
%78 = fcmp olt double %76, %77
br i1 %78, label %79, label %84
79: ; preds = %5
%80 = load i8*, i8** %10
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
store i8 1, i8* %83
store i8 2, i8* %6
br label %89
84: ; preds = %5
%85 = load i8*, i8** %9
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
store i8 1, i8* %88
store i8 1, i8* %6
br label %89
89: ; preds = %84, %79
%90 = load i8, i8* %6
ret i8 %90
}

LLVM IR (-O2):
define zeroext i8 @classify(i32 %0, i32 %1, i8* nocapture writeonly %2, i8* nocapture writeonly %3, i32 %4) {
%6 = insertelement <2 x i32> poison, i32 %0, i64 0
%7 = insertelement <2 x i32> %6, i32 %1, i64 1
%8 = add nsw <2 x i32> %7, <i32 -82, i32 -143>
%9 = sitofp <2 x i32> %8 to <2 x double>
%10 = add nsw <2 x i32> %7, <i32 -110, i32 -131>
%11 = sitofp <2 x i32> %10 to <2 x double>
%12 = fmul <2 x double> %9, %9
%13 = fdiv <2 x double> %12, <double 4.850000e+02, double 5.300000e+01>
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%15 = fadd <2 x double> %13, %14
%16 = extractelement <2 x double> %15, i64 0
%17 = extractelement <2 x double> %9, i64 0
%18 = fmul double %17, 0xBF8413E0E33A5EDF
%19 = extractelement <2 x double> %9, i64 1
%20 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %16)
%21 = fmul double %20, 0x4004EBF89A65A109
%22 = fmul <2 x double> %11, %11
%23 = fdiv <2 x double> %22, <double 4.140000e+02, double 7.000000e+00>
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%25 = fadd <2 x double> %23, %24
%26 = extractelement <2 x double> %25, i64 0
%27 = extractelement <2 x double> %11, i64 0
%28 = fmul double %27, 0xBF669D3D4E44322D
%29 = extractelement <2 x double> %11, i64 1
%30 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %26)
%31 = fmul double %30, 0x3FF016BD612D4D47
%32 = tail call i32 @exp(double %21)
%33 = sitofp i32 %32 to double
%34 = fmul double %33, 0x40C3328000000001
%35 = fptosi double %34 to i32
%36 = tail call double @sqrt(i32 %35)
%37 = tail call i32 @exp(double %31)
%38 = mul i32 %37, 2882
%39 = tail call double @sqrt(i32 %38)
%40 = insertelement <2 x double> poison, double %36, i64 0
%41 = insertelement <2 x double> %40, double %39, i64 1
%42 = fdiv <2 x double> <double 0x3FF921FB54442EEA, double 0x3FF921FB54442EEA>, %41
%43 = extractelement <2 x double> %42, i64 0
%44 = extractelement <2 x double> %42, i64 1
%45 = fcmp olt double %43, %44
%46 = sext i32 %4 to i64
%47 = select i1 %45, i8* %3, i8* %2
%48 = select i1 %45, i8 2, i8 1
%49 = getelementptr inbounds i8, i8* %47, i64 %46
store i8 1, i8* %49
ret i8 %48
}