#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(int);
int /*<<< orphan*/ printf(char *, int);
int sum_digits(int);
int main() {
  int i, count = 0;
  for (i = 2; i <= 9999; ++i) {
    if (is_prime(i) && is_prime(sum_digits(i))) {
      printf("%d\t", i);
      ++count;
    }
  }
  printf("\nVkupno: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0x270f,-0x8(%rbp)
jg     11b0 <main+0x80>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    -0x8(%rbp),%edi
call   1050 <sum_digits@plt>
mov    %eax,%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    -0x8(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a2 <main+0x72>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%ebp
xor    %ebx,%ebx
lea    0xebe(%rip),%r14
jmp    115b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x2710,%ebp
je     1189 <main+0x59>
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1150 <main+0x20>
mov    %ebp,%edi
call   1050 <sum_digits@plt>
mov    %eax,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1150 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
jmp    1150 <main+0x20>
lea    0xe74(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [13 x i8] c"\0AVkupno: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 2, i32* %2
br label %4
4: ; preds = %22, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 9999
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i64 @is_prime(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @sum_digits(i32 %12)
%14 = call i64 @is_prime(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %16, %11, %7
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %4
25: ; preds = %4
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [13 x i8] c"\0AVkupno: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ 0, %0 ], [ %14, %13 ]
%3 = phi i32 [ 2, %0 ], [ %15, %13 ]
%4 = tail call i64 @is_prime(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = tail call i32 @sum_digits(i32 %3)
%8 = tail call i64 @is_prime(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%12 = add nsw i32 %2, 1
br label %13
13: ; preds = %1, %6, %10
%14 = phi i32 [ %12, %10 ], [ %2, %6 ], [ %2, %1 ]
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 10000
br i1 %16, label %17, label %1
17: ; preds = %13
%18 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}