#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 size_t int32_t;

/* Variables and functions */
int32_t euler_totient_func(int32_t n, int32_t *primes) {
  double prod = 1.0;
  int32_t n_0 = n;
  for (int32_t i = 0; primes[i] && primes[i] <= n; i++) {
    if (n % primes[i] == 0) {
      prod *= (1 - 1 / (double)primes[i]);
      n /= primes[i];
    }
  }
  return (int32_t)(double)n_0 * prod;
}


x86 assembly (clang, -O0):
<euler_totient_func>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xeec(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0x29(%rbp)
je     1157 <euler_totient_func+0x57>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x8(%rbp),%rax
setbe  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1167 <euler_totient_func+0x67>
jmp    1203 <euler_totient_func+0x103>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
divq   (%rcx,%rsi,8)
cmp    $0x0,%rdx
jne    11ed <euler_totient_func+0xed>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movq   (%rax,%rcx,8),%xmm0
movaps 0xe79(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe7d(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe46(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe3a(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x8(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
jmp    11f2 <euler_totient_func+0xf2>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1129 <euler_totient_func+0x29>
movq   -0x20(%rbp),%xmm0
movaps 0xe01(%rip),%xmm3
punpckldq %xmm3,%xmm0
movapd 0xe05(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xdc7(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
movq   %rax,%xmm0
punpckldq %xmm3,%xmm0
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm2
unpckhpd %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movaps %xmm0,%xmm2
cvttsd2si %xmm2,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<euler_totient_func>:
mov    (%rsi),%rcx
lea    -0x1(%rcx),%rax
cmp    %rdi,%rax
jae    11ae <euler_totient_func+0xae>
add    $0x8,%rsi
movsd  0xee4(%rip),%xmm1
movdqa 0xeec(%rip),%xmm2
movapd 0xef4(%rip),%xmm3
mov    %rdi,%r8
movapd %xmm1,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r8,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11a0 <euler_totient_func+0xa0>
mov    %r8,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
jne    1189 <euler_totient_func+0x89>
movq   %rcx,%xmm4
punpckldq %xmm2,%xmm4
subpd  %xmm3,%xmm4
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
addsd  %xmm4,%xmm5
movapd %xmm1,%xmm4
divsd  %xmm5,%xmm4
movapd %xmm1,%xmm5
subsd  %xmm4,%xmm5
mulsd  %xmm5,%xmm0
mov    %rax,%r8
mov    (%rsi),%rcx
test   %rcx,%rcx
je     11b6 <euler_totient_func+0xb6>
add    $0x8,%rsi
cmp    %r8,%rcx
jbe    1140 <euler_totient_func+0x40>
jmp    11b6 <euler_totient_func+0xb6>
nopl   0x0(%rax)
mov    %r8d,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    1189 <euler_totient_func+0x89>
jmp    1159 <euler_totient_func+0x59>
movsd  0xe4a(%rip),%xmm0
movq   %rdi,%xmm1
movdqa 0xe4d(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xe51(%rip),%xmm3
subpd  %xmm3,%xmm1
movapd %xmm1,%xmm4
unpckhpd %xmm1,%xmm4
addsd  %xmm1,%xmm4
cvttsd2si %xmm4,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
movsd  0xe15(%rip),%xmm1
subsd  %xmm1,%xmm4
cvttsd2si %xmm4,%rdx
and    %rcx,%rdx
or     %rax,%rdx
movq   %rdx,%xmm4
punpckldq %xmm2,%xmm4
subpd  %xmm3,%xmm4
movapd %xmm4,%xmm2
unpckhpd %xmm4,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm0,%xmm2
cvttsd2si %xmm2,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
subsd  %xmm1,%xmm2
cvttsd2si %xmm2,%rax
and    %rdx,%rax
or     %rcx,%rax
ret

LLVM IR (-O0):
define i64 @euler_totient_func(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %3
store i64* %1, i64** %4
store double 1.000000e+00, double* %5
%8 = load i64, i64* %3
store i64 %8, i64* %6
store i64 0, i64* %7
br label %9
9: ; preds = %49, %2
%10 = load i64*, i64** %4
%11 = load i64, i64* %7
%12 = getelementptr inbounds i64, i64* %10, i64 %11
%13 = load i64, i64* %12
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = load i64*, i64** %4
%17 = load i64, i64* %7
%18 = getelementptr inbounds i64, i64* %16, i64 %17
%19 = load i64, i64* %18
%20 = load i64, i64* %3
%21 = icmp ule i64 %19, %20
br label %22
22: ; preds = %15, %9
%23 = phi i1 [ false, %9 ], [ %21, %15 ]
br i1 %23, label %24, label %52
24: ; preds = %22
%25 = load i64, i64* %3
%26 = load i64*, i64** %4
%27 = load i64, i64* %7
%28 = getelementptr inbounds i64, i64* %26, i64 %27
%29 = load i64, i64* %28
%30 = urem i64 %25, %29
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %48
32: ; preds = %24
%33 = load i64*, i64** %4
%34 = load i64, i64* %7
%35 = getelementptr inbounds i64, i64* %33, i64 %34
%36 = load i64, i64* %35
%37 = uitofp i64 %36 to double
%38 = fdiv double 1.000000e+00, %37
%39 = fsub double 1.000000e+00, %38
%40 = load double, double* %5
%41 = fmul double %40, %39
store double %41, double* %5
%42 = load i64*, i64** %4
%43 = load i64, i64* %7
%44 = getelementptr inbounds i64, i64* %42, i64 %43
%45 = load i64, i64* %44
%46 = load i64, i64* %3
%47 = udiv i64 %46, %45
store i64 %47, i64* %3
br label %48
48: ; preds = %32, %24
br label %49
49: ; preds = %48
%50 = load i64, i64* %7
%51 = add i64 %50, 1
store i64 %51, i64* %7
br label %9
52: ; preds = %22
%53 = load i64, i64* %6
%54 = uitofp i64 %53 to double
%55 = fptoui double %54 to i64
%56 = uitofp i64 %55 to double
%57 = load double, double* %5
%58 = fmul double %56, %57
%59 = fptoui double %58 to i64
ret i64 %59
}

LLVM IR (-O2):
define i64 @euler_totient_func(i64 %0, i64* nocapture %1) {
%3 = load i64, i64* %1
%4 = add i64 %3, -1
%5 = icmp ult i64 %4, %0
br i1 %5, label %13, label %6
6: ; preds = %26, %2
%7 = phi double [ 1.000000e+00, %2 ], [ %27, %26 ]
%8 = uitofp i64 %0 to double
%9 = fptoui double %8 to i64
%10 = uitofp i64 %9 to double
%11 = fmul double %7, %10
%12 = fptoui double %11 to i64
ret i64 %12
13: ; preds = %2, %26
%14 = phi i64 [ %31, %26 ], [ %3, %2 ]
%15 = phi i64 [ %29, %26 ], [ 0, %2 ]
%16 = phi i64 [ %28, %26 ], [ %0, %2 ]
%17 = phi double [ %27, %26 ], [ 1.000000e+00, %2 ]
%18 = urem i64 %16, %14
%19 = udiv i64 %16, %14
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %26
21: ; preds = %13
%22 = uitofp i64 %14 to double
%23 = fdiv double 1.000000e+00, %22
%24 = fsub double 1.000000e+00, %23
%25 = fmul double %17, %24
br label %26
26: ; preds = %13, %21
%27 = phi double [ %25, %21 ], [ %17, %13 ]
%28 = phi i64 [ %19, %21 ], [ %16, %13 ]
%29 = add i64 %15, 1
%30 = getelementptr inbounds i64, i64* %1, i64 %29
%31 = load i64, i64* %30
%32 = icmp eq i64 %31, 0
%33 = icmp ugt i64 %31, %28
%34 = select i1 %32, i1 true, i1 %33
br i1 %34, label %6, label %13
}