#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*/ freopen(char *, char *, int /*<<< orphan*/);
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void get_prime_table() {
  int i, count = 0;
  freopen("output.txt", "w", stdout);
  for (i = 2; i < 10001; i++) {
    if (is_prime(i)) {
      if (i % 10 == 1) {
        printf("%d,", i);
        count++;
        if (count % 10 == 0) {
          printf("\\\n");
        }
      }
    }
  }
  printf("100001\ncount = %d\n", count);
}


x86 assembly (clang, -O0):
<get_prime_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
lea    0xeb1(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <freopen@plt>
movl   $0x2,-0x4(%rbp)
cmpl   $0x2711,-0x4(%rbp)
jge    11ee <get_prime_table+0xbe>
mov    -0x4(%rbp),%edi
call   1050 <is_prime@plt>
cmp    $0x0,%rax
je     11db <get_prime_table+0xab>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11d6 <get_prime_table+0xa6>
mov    -0x4(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d1 <get_prime_table+0xa1>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d6 <get_prime_table+0xa6>
jmp    11db <get_prime_table+0xab>
jmp    11e0 <get_prime_table+0xb0>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1162 <get_prime_table+0x32>
mov    -0x8(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prime_table>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
lea    0xea9(%rip),%rdi
lea    0xead(%rip),%rsi
call   1050 <freopen@plt>
mov    $0x2,%ebx
lea    0xe9e(%rip),%r14
lea    0xeae(%rip),%r15
xor    %ebp,%ebp
jmp    118b <get_prime_table+0x4b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x2711,%ebx
je     11e3 <get_prime_table+0xa3>
mov    %ebx,%edi
call   1060 <is_prime@plt>
test   %rax,%rax
je     1180 <get_prime_table+0x40>
movzwl %bx,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%eax
neg    %eax
add    %ebx,%eax
add    $0x1,%eax
cmp    $0x2,%ax
jne    1180 <get_prime_table+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
imul   $0xcccccccd,%ebp,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     1180 <get_prime_table+0x40>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1180 <get_prime_table+0x40>
lea    0xe27(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%d,\00"
@.str.3 = [3 x i8] c"\\\0A\00"
@.str.4 = [19 x i8] c"100001\0Acount = %d\0A\00"
define void @get_prime_table() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = load i32, i32* @stdout
%4 = call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %3)
store i32 2, i32* %1
br label %5
5: ; preds = %29, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 10001
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = load i32, i32* %1
%10 = call i64 @is_prime(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %1
%14 = srem i32 %13, 10
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %16
br label %27
27: ; preds = %26, %12
br label %28
28: ; preds = %27, %8
br label %29
29: ; preds = %28
%30 = load i32, i32* %1
%31 = add nsw i32 %30, 1
store i32 %31, i32* %1
br label %5
32: ; preds = %5
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%d,\00"
@.str.4 = [19 x i8] c"100001\0Acount = %d\0A\00"
@str = [2 x i8] c"\\\00"
define void @get_prime_table() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @freopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %3
3: ; preds = %0, %19
%4 = phi i32 [ 0, %0 ], [ %20, %19 ]
%5 = phi i32 [ 2, %0 ], [ %21, %19 ]
%6 = tail call i64 @is_prime(i32 %5)
%7 = icmp ne i64 %6, 0
%8 = trunc i32 %5 to i16
%9 = urem i16 %8, 10
%10 = icmp eq i16 %9, 1
%11 = and i1 %7, %10
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%14 = add nsw i32 %4, 1
%15 = srem i32 %14, 10
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %3, %12, %17
%20 = phi i32 [ %14, %17 ], [ %14, %12 ], [ %4, %3 ]
%21 = add nuw nsw i32 %5, 1
%22 = icmp eq i32 %21, 10001
br i1 %22, label %23, label %3
23: ; preds = %19
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %20)
ret void
}