#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 */
scalar_t__ is_prime(long);
scalar_t__ malloc(int);
long p(int, long *, long *);
long euler_problem_76() {
  long pcnt = 200;
  long *primes = (long *)malloc(sizeof(long) * pcnt);
  primes[0] = 2;
  long count = 1;
  for (long i = 3; count < pcnt; i += 2) {
    if (is_prime(i)) {
      primes[count] = i;
      ++count;
    }
  }
  long *pcache = (long *)malloc(sizeof(long) * 101);
  for (long i = 0; i < 101; ++i) {
    pcache[i] = 0;
  }
  pcache[0] = 1;
  pcache[1] = 1;
  return p(100, primes, pcache) - 1;
}


x86 assembly (clang, -O0):
<euler_problem_76>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0xc8,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x2,(%rax)
movq   $0x1,-0x18(%rbp)
movq   $0x3,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11c1 <euler_problem_76+0x91>
mov    -0x20(%rbp),%rdi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11ab <euler_problem_76+0x7b>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <euler_problem_76+0x80>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    116e <euler_problem_76+0x3e>
mov    $0x328,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x65,-0x30(%rbp)
jge    1203 <euler_problem_76+0xd3>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11d7 <euler_problem_76+0xa7>
mov    -0x28(%rbp),%rax
movq   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x64,%edi
call   1030 <p@plt>
sub    $0x1,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euler_problem_76>:
push   %r15
push   %r14
push   %rbx
mov    $0x640,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
movq   $0x2,(%rax)
mov    $0x3,%ebx
mov    $0x1,%r15d
jmp    117d <euler_problem_76+0x3d>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%rbx
cmp    $0xc8,%r15
jge    1194 <euler_problem_76+0x54>
mov    %rbx,%rdi
call   1050 <is_prime@plt>
test   %rax,%rax
je     1170 <euler_problem_76+0x30>
mov    %rbx,(%r14,%r15,8)
add    $0x1,%r15
jmp    1170 <euler_problem_76+0x30>
mov    $0x328,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x328,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movaps 0xe49(%rip),%xmm0
movups %xmm0,(%rbx)
mov    $0x64,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <p@plt>
add    $0xffffffffffffffff,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @euler_problem_76() {
%1 = alloca i64
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
store i64 200, i64* %1
%7 = load i64, i64* %1
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i64*
store i64* %11, i64** %2
%12 = load i64*, i64** %2
%13 = getelementptr inbounds i64, i64* %12, i64 0
store i64 2, i64* %13
store i64 1, i64* %3
store i64 3, i64* %4
br label %14
14: ; preds = %30, %0
%15 = load i64, i64* %3
%16 = load i64, i64* %1
%17 = icmp slt i64 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i64, i64* %4
%20 = call i64 @is_prime(i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i64, i64* %4
%24 = load i64*, i64** %2
%25 = load i64, i64* %3
%26 = getelementptr inbounds i64, i64* %24, i64 %25
store i64 %23, i64* %26
%27 = load i64, i64* %3
%28 = add nsw i64 %27, 1
store i64 %28, i64* %3
br label %29
29: ; preds = %22, %18
br label %30
30: ; preds = %29
%31 = load i64, i64* %4
%32 = add nsw i64 %31, 2
store i64 %32, i64* %4
br label %14
33: ; preds = %14
%34 = call i64 @malloc(i32 808)
%35 = inttoptr i64 %34 to i64*
store i64* %35, i64** %5
store i64 0, i64* %6
br label %36
36: ; preds = %43, %33
%37 = load i64, i64* %6
%38 = icmp slt i64 %37, 101
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i64*, i64** %5
%41 = load i64, i64* %6
%42 = getelementptr inbounds i64, i64* %40, i64 %41
store i64 0, i64* %42
br label %43
43: ; preds = %39
%44 = load i64, i64* %6
%45 = add nsw i64 %44, 1
store i64 %45, i64* %6
br label %36
46: ; preds = %36
%47 = load i64*, i64** %5
%48 = getelementptr inbounds i64, i64* %47, i64 0
store i64 1, i64* %48
%49 = load i64*, i64** %5
%50 = getelementptr inbounds i64, i64* %49, i64 1
store i64 1, i64* %50
%51 = load i64*, i64** %2
%52 = load i64*, i64** %5
%53 = call i64 @p(i32 100, i64* %51, i64* %52)
%54 = sub nsw i64 %53, 1
ret i64 %54
}

LLVM IR (-O2):
define i64 @euler_problem_76() {
%1 = tail call i64 @malloc(i32 1600)
%2 = inttoptr i64 %1 to i64*
store i64 2, i64* %2
br label %10
3: ; preds = %18
%4 = tail call i64 @malloc(i32 808)
%5 = inttoptr i64 %4 to i64*
%6 = inttoptr i64 %4 to i8*
%7 = inttoptr i64 %4 to <2 x i64>*
store <2 x i64> <i64 1, i64 1>, <2 x i64>* %7
%8 = tail call i64 @p(i32 100, i64* %2, i64* %5)
%9 = add nsw i64 %8, -1
ret i64 %9
10: ; preds = %0, %18
%11 = phi i64 [ 1, %0 ], [ %19, %18 ]
%12 = phi i64 [ 3, %0 ], [ %20, %18 ]
%13 = tail call i64 @is_prime(i64 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = getelementptr inbounds i64, i64* %2, i64 %11
store i64 %12, i64* %16
%17 = add nsw i64 %11, 1
br label %18
18: ; preds = %10, %15
%19 = phi i64 [ %17, %15 ], [ %11, %10 ]
%20 = add nuw nsw i64 %12, 2
%21 = icmp slt i64 %19, 200
br i1 %21, label %10, label %3
}