#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__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
void *primeThread(void *rank) {
  long argNumber = (long)rank;
  int i;
  printf("The prime number of a given number %d are: ", argNumber);
  for (i = 2; i <= argNumber; i++) {
    if (isPrime(i)) {
      printf("%d ", i);
    }
  }
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<primeThread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     119f <primeThread+0x6f>
mov    -0x1c(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     118c <primeThread+0x5c>
mov    -0x1c(%rbp),%esi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1191 <primeThread+0x61>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115d <primeThread+0x2d>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeThread>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xec1(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
cmp    $0x2,%r14
jge    1159 <primeThread+0x29>
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <pthread_exit@plt>
mov    $0x2,%ebx
lea    0xec7(%rip),%r15
jmp    1179 <primeThread+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r14,%rbx
jg     114d <primeThread+0x1d>
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1170 <primeThread+0x40>
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1170 <primeThread+0x40>

LLVM IR (-O0):
@.str = [44 x i8] c"The prime number of a given number %d are: \00"
@.str.1 = [4 x i8] c"%d \00"
define i8* @primeThread(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = ptrtoint i8* %6 to i64
store i64 %7, i64* %4
%8 = load i64, i64* %4
%9 = trunc i64 %8 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 2, i32* %5
br label %11
11: ; preds = %24, %1
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = load i64, i64* %4
%15 = icmp sle i64 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = load i32, i32* %5
%18 = call i64 @isPrime(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %16
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %11
27: ; preds = %11
%28 = call i32 @pthread_exit(i32* null)
%29 = load i8*, i8** %2
ret i8* %29
}

LLVM IR (-O2):
@.str = [44 x i8] c"The prime number of a given number %d are: \00"
@.str.1 = [4 x i8] c"%d \00"
define noalias i8* @primeThread(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i8* %0, inttoptr (i64 2 to i8*)
br i1 %5, label %16, label %6
6: ; preds = %1, %13
%7 = phi i64 [ %14, %13 ], [ 2, %1 ]
%8 = trunc i64 %7 to i32
%9 = tail call i64 @isPrime(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %13
13: ; preds = %6, %11
%14 = add nuw i64 %7, 1
%15 = icmp sgt i64 %14, %2
br i1 %15, label %16, label %6
16: ; preds = %13, %1
%17 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}