#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__ compute(int);
int /*<<< orphan*/ printf(char *, int, int);
void *thr_func(void *arg) {
  int i;
  int count = 0;
  for (i = 3000000 + (int)arg; i <= 3000200; i += 5) {
    if (compute(i) == 0) {
      printf("[%d] %d is a primer.\n", (int)arg, i);
      count++;
    }
  }
  return (void *)count;
}


x86 assembly (clang, -O0):
<thr_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2dc6c0,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2dc788,-0xc(%rbp)
jg     118f <thr_func+0x6f>
mov    -0xc(%rbp),%edi
call   1040 <compute@plt>
cmp    $0x0,%rax
jne    117c <thr_func+0x5c>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    -0xc(%rbp),%edx
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1181 <thr_func+0x61>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <thr_func+0x1f>
movslq -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thr_func>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %ebx,%ebx
cmp    $0xc8,%r15d
jg     1179 <thr_func+0x59>
lea    0x2dc6bb(%r15),%ebp
xor    %ebx,%ebx
lea    0xebb(%rip),%r14
jmp    1158 <thr_func+0x38>
nopw   0x0(%rax,%rax,1)
cmp    $0x2dc784,%ebp
jge    1179 <thr_func+0x59>
add    $0x5,%ebp
mov    %ebp,%edi
call   1040 <compute@plt>
test   %rax,%rax
jne    1150 <thr_func+0x30>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
jmp    1150 <thr_func+0x30>
movslq %ebx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"[%d] %d is a primer.\0A\00"
define i8* @thr_func(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
%6 = ptrtoint i8* %5 to i32
%7 = add nsw i32 3000000, %6
store i32 %7, i32* %3
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 3000200
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = call i64 @compute(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = ptrtoint i8* %16 to i32
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %15, %11
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 5
store i32 %25, i32* %3
br label %8
26: ; preds = %8
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i8*
ret i8* %29
}

LLVM IR (-O2):
@.str = [22 x i8] c"[%d] %d is a primer.\0A\00"
define i8* @thr_func(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = icmp slt i32 %3, 201
br i1 %4, label %5, label %19
5: ; preds = %1
%6 = add nsw i32 %3, 3000000
br label %7
7: ; preds = %5, %15
%8 = phi i32 [ %16, %15 ], [ 0, %5 ]
%9 = phi i32 [ %17, %15 ], [ %6, %5 ]
%10 = tail call i64 @compute(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %9)
%14 = add nsw i32 %8, 1
br label %15
15: ; preds = %7, %12
%16 = phi i32 [ %14, %12 ], [ %8, %7 ]
%17 = add nsw i32 %9, 5
%18 = icmp slt i32 %9, 3000196
br i1 %18, label %7, label %19
19: ; preds = %15, %1
%20 = phi i32 [ 0, %1 ], [ %16, %15 ]
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
ret i8* %22
}