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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_prime_factors(int /*<<< orphan*/);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
void workEntry(pthread_mutex_t *mutex) {
  FILE *fichier = fopen("nombre premier.txt", "r");
  uint64_t lecture = 0;
  int fin;
  while (1) {
    pthread_mutex_lock(mutex);
    fin = fscanf(fichier, "%ju", &lecture);
    pthread_mutex_unlock(mutex);
    if (fin <= 0) {
      break;
    }
    print_prime_factors(lecture);
  }
  fclose(fichier);
}


x86 assembly (clang, -O0):
<workEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <pthread_mutex_lock@plt>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
cmpl   $0x0,-0x18(%rbp)
jg     11c2 <workEntry+0x62>
jmp    11cf <workEntry+0x6f>
mov    -0x14(%rbp),%edi
call   1060 <print_prime_factors@plt>
jmp    118a <workEntry+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<workEntry>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe8a(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
movl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
call   1080 <pthread_mutex_lock@plt>
lea    0xe79(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
call   1040 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
test   %ebp,%ebp
jle    11fd <workEntry+0x9d>
lea    0xe57(%rip),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%edi
call   1060 <print_prime_factors@plt>
mov    %rbx,%rdi
call   1080 <pthread_mutex_lock@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
test   %ebp,%ebp
jg     11d0 <workEntry+0x70>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"nombre premier.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ju\00"
define void @workEntry(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
store i32 0, i32* %4
br label %7
7: ; preds = %1, %17
%8 = load i32*, i32** %2
%9 = call i32 @pthread_mutex_lock(i32* %8)
%10 = load i32*, i32** %3
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %4)
store i32 %11, i32* %5
%12 = load i32*, i32** %2
%13 = call i32 @pthread_mutex_unlock(i32* %12)
%14 = load i32, i32* %5
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %7
br label %20
17: ; preds = %7
%18 = load i32, i32* %4
%19 = call i32 @print_prime_factors(i32 %18)
br label %7
20: ; preds = %16
%21 = load i32*, i32** %3
%22 = call i32 @fclose(i32* %21)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"nombre premier.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ju\00"
define void @workEntry(i32* %0) {
%2 = alloca i32
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = call i32 @pthread_mutex_lock(i32* %0)
%6 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = call i32 @pthread_mutex_unlock(i32* %0)
%8 = icmp slt i32 %6, 1
br i1 %8, label %16, label %9
9: ; preds = %1, %9
%10 = load i32, i32* %2
%11 = call i32 @print_prime_factors(i32 %10)
%12 = call i32 @pthread_mutex_lock(i32* %0)
%13 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = call i32 @pthread_mutex_unlock(i32* %0)
%15 = icmp slt i32 %13, 1
br i1 %15, label %16, label %9
16: ; preds = %9, %1
%17 = call i32 @fclose(i32* %3)
ret void
}