#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*/ printf(char *, ...);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
void print_prime_factors_iosync(uint64_t n, pthread_mutex_t *mutex) {
  uint64_t factors[64];
  int j, k;
  k = get_prime_factors(n, factors);
  if (mutex)
    pthread_mutex_lock(mutex);
  printf("%ju:", n);
  for (j = 0; j < k; j++) {
    printf(" %ju", factors[j]);
  }
  printf("\n");
  if (mutex)
    pthread_mutex_unlock(mutex);
}


x86 assembly (clang, -O0):
<print_prime_factors_iosync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1040 <get_prime_factors@plt>
mov    %eax,-0x118(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117b <print_prime_factors_iosync+0x3b>
mov    -0x10(%rbp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    -0x4(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x118(%rbp),%eax
jge    11d8 <print_prime_factors_iosync+0x98>
movslq -0x114(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1196 <print_prime_factors_iosync+0x56>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11fa <print_prime_factors_iosync+0xba>
mov    -0x10(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prime_factors_iosync>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    %rsp,%rsi
call   1050 <get_prime_factors@plt>
mov    %eax,%ebp
test   %r14,%r14
je     1179 <print_prime_factors_iosync+0x29>
mov    %r14,%rdi
call   1070 <pthread_mutex_lock@plt>
lea    0xe80(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11b6 <print_prime_factors_iosync+0x66>
mov    %ebp,%ebp
lea    0xe6f(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <print_prime_factors_iosync+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14,%r14
je     11cd <print_prime_factors_iosync+0x7d>
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 = [5 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_iosync(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 = load i32, i32* %3
%9 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%10 = call i32 @get_prime_factors(i32 %8, i32* %9)
store i32 %10, i32* %7
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** %4
%15 = call i32 @pthread_mutex_lock(i32* %14)
br label %16
16: ; preds = %13, %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 0, i32* %6
br label %19
19: ; preds = %29, %16
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32*, i32** %4
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32*, i32** %4
%38 = call i32 @pthread_mutex_unlock(i32* %37)
br label %39
39: ; preds = %36, %32
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ju:\00"
@.str.1 = [5 x i8] c" %ju\00"
define void @print_prime_factors_iosync(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)
%7 = icmp eq i32* %1, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @pthread_mutex_lock(i32* %1)
br label %10
10: ; preds = %8, %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%12 = icmp sgt i32 %6, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = zext i32 %6 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %20, %15 ]
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %22, label %15
22: ; preds = %15, %10
%23 = call i32 @putchar(i32 10)
br i1 %7, label %26, label %24
24: ; preds = %22
%25 = call i32 @pthread_mutex_unlock(i32* %1)
br label %26
26: ; preds = %24, %22
ret void
}