#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int get_prime_factors(int /*<<< orphan*/, int /*<<< orphan*/ *,
                      int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
void print_prime_factors(uint64_t n, pthread_mutex_t *mutexEcran) {
  uint64_t factors[64];
  int j, k;
  k = get_prime_factors(0, factors, n);
  pthread_mutex_lock(mutexEcran);
  printf("%ju: ", n);
  for (j = 0; j <= k; j++) {
    printf("%ju ", factors[j]);
  }
  printf("\n");
  pthread_mutex_unlock(mutexEcran);
}


x86 assembly (clang, -O0):
<print_prime_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rsi
mov    -0x4(%rbp),%edx
xor    %edi,%edi
call   1040 <get_prime_factors@plt>
mov    %eax,-0x118(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    -0x4(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x118(%rbp),%eax
jg     11cf <print_prime_factors+0x8f>
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    118d <print_prime_factors+0x4d>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prime_factors>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
mov    %ebp,%edx
call   1050 <get_prime_factors@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <pthread_mutex_lock@plt>
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     11b6 <print_prime_factors+0x66>
add    $0x1,%ebx
lea    0xe70(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <print_prime_factors+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <pthread_mutex_unlock@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%ju: \00"
@.str.1 = [5 x i8] c"%ju \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_prime_factors(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [64 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @get_prime_factors(i32 0, i32* %8, i32 %9)
store i32 %10, i32* %7
%11 = load i32*, i32** %4
%12 = call i32 @pthread_mutex_lock(i32* %11)
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %25, %2
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %19
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %15
28: ; preds = %15
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32*, i32** %4
%31 = call i32 @pthread_mutex_unlock(i32* %30)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%ju: \00"
@.str.1 = [5 x i8] c"%ju \00"
define void @print_prime_factors(i32 %0, i32* %1) {
%3 = alloca [64 x i32]
%4 = bitcast [64 x i32]* %3 to i8*
%5 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%6 = call i32 @get_prime_factors(i32 0, i32* %5, i32 %0)
%7 = call i32 @pthread_mutex_lock(i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
%9 = icmp slt i32 %6, 0
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = add nuw i32 %6, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %18, %13 ]
%15 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %12
br i1 %19, label %20, label %13
20: ; preds = %13, %2
%21 = call i32 @putchar(i32 10)
%22 = call i32 @pthread_mutex_unlock(i32* %1)
ret void
}