#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 */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pthread_exit(void *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void *fn_thread(void *inutile) {
  char chaine[128];
  int i = 0;
  fprintf(stdout, "Thread : entrez un nombre :");
  while (fgets(chaine, 128, stdin) != NULL)
    if (sscanf(chaine, "%d", &i) != 1)
      fprintf(stdout, "un nombre svp :");
    else
      break;
  pthread_exit((void *)(intptr_t)i);
}


x86 assembly (clang, -O0):
<fn_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x94(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11d9 <fn_thread+0x99>
lea    -0x90(%rbp),%rdi
lea    0xe7c(%rip),%rsi
lea    -0x94(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11cf <fn_thread+0x8f>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11d4 <fn_thread+0x94>
jmp    11d9 <fn_thread+0x99>
jmp    116e <fn_thread+0x2e>
movslq -0x94(%rbp),%rdi
call   1050 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn_thread>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movl   $0x0,0xc(%rsp)
mov    0x2e78(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e71(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     11eb <fn_thread+0xab>
lea    0xe87(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
lea    0xe79(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11e4 <fn_thread+0xa4>
mov    0x0(%r13),%edi
mov    %r12,%rsi
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1030 <fgets@plt>
test   %rax,%rax
jne    11b0 <fn_thread+0x70>
movslq 0xc(%rsp),%rdi
jmp    11ed <fn_thread+0xad>
xor    %edi,%edi
call   1050 <pthread_exit@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [28 x i8] c"Thread : entrez un nombre :\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"un nombre svp :\00"
define i8* @fn_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [128 x i8]
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
%6 = load i32, i32* @stdout
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %21, %1
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %9, i32 128, i32 %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %21
20: ; preds = %13
br label %22
21: ; preds = %17
br label %8
22: ; preds = %20, %8
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
%26 = call i32 @pthread_exit(i8* %25)
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [28 x i8] c"Thread : entrez un nombre :\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"un nombre svp :\00"
define noalias i8* @fn_thread(i8* nocapture readnone %0) {
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %4, i32 128, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %24, label %11
11: ; preds = %1, %14
%12 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i32* @fgets(i8* %4, i32 128, i32 %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %11
20: ; preds = %11, %14
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
br label %24
24: ; preds = %20, %1
%25 = phi i8* [ %23, %20 ], [ null, %1 ]
%26 = call i32 @pthread_exit(i8* %25)
ret i8* undef
}