#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*/);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int Saisie_Entier() {
  char entier[10 + 2];
  int ret, valeur;
  printf("> ");
  fgets(entier, 10 + 2, stdin);
  ret = sscanf(entier, "%d", &valeur);
  while (ret != 1 || entier[strlen(entier) - 1] != '\n') {
    if (entier[strlen(entier) - 1] != '\n') {
      while (getchar() != '\n')
        ;
      puts("Nombre trop grand.");
    } else {
      puts("Saisie invalide.");
    }
    printf("> ");
    fgets(entier, 10 + 2, stdin);
    ret = sscanf(entier, "%d", &valeur);
  }
  return valeur;
}


x86 assembly (clang, -O0):
<Saisie_Entier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1060 <fgets@plt>
lea    -0xc(%rbp),%rdi
lea    0xe6d(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
mov    %eax,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jne    11cd <Saisie_Entier+0x6d>
lea    -0xc(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xc(%rbp,%rax,1),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11dd <Saisie_Entier+0x7d>
jmp    1272 <Saisie_Entier+0x112>
lea    -0xc(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xc(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1227 <Saisie_Entier+0xc7>
jmp    11fe <Saisie_Entier+0x9e>
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1216 <Saisie_Entier+0xb6>
jmp    11fe <Saisie_Entier+0x9e>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
jmp    1233 <Saisie_Entier+0xd3>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc6(%rip),%rdi
call   1050 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2d9e(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1060 <fgets@plt>
lea    -0xc(%rbp),%rdi
lea    0xda2(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
mov    %eax,-0x10(%rbp)
jmp    11a2 <Saisie_Entier+0x42>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Saisie_Entier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x2e64(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0xe73(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe7d(%rip),%rbp
jmp    11ad <Saisie_Entier+0x4d>
xchg   %ax,%ax
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    11e2 <Saisie_Entier+0x82>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1214 <Saisie_Entier+0xb4>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
mov    %rbp,%rdi
je     11a0 <Saisie_Entier+0x40>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1200 <Saisie_Entier+0xa0>
lea    0xdf4(%rip),%rdi
jmp    11a0 <Saisie_Entier+0x40>
mov    0x8(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Nombre trop grand.\00"
@.str.3 = [17 x i8] c"Saisie invalide.\00"
define i32 @Saisie_Entier() {
%1 = alloca [12 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 12, i32 %6)
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %9, i32* %2
br label %10
10: ; preds = %43, %0
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 1
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br label %22
22: ; preds = %13, %10
%23 = phi i1 [ true, %10 ], [ %21, %13 ]
br i1 %23, label %24, label %50
24: ; preds = %22
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %41
33: ; preds = %24
br label %34
34: ; preds = %38, %33
%35 = call signext i8 (...) @getchar()
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %39
38: ; preds = %34
br label %34
39: ; preds = %34
%40 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %43
41: ; preds = %24
%42 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %39
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%45 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%46 = load i32, i32* @stdin
%47 = call i32 @fgets(i8* %45, i32 12, i32 %46)
%48 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%49 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %49, i32* %2
br label %10
50: ; preds = %22
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Nombre trop grand.\00"
@.str.3 = [17 x i8] c"Saisie invalide.\00"
define i32 @Saisie_Entier() {
%1 = alloca [12 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 12, i32 %7)
%9 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = call i32 @strlen(i8* %3)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %32, label %18
18: ; preds = %6, %11
%19 = call i32 @strlen(i8* %3)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %28, label %25
25: ; preds = %18, %25
%26 = call signext i8 (...) @getchar()
%27 = icmp eq i8 %26, 10
br i1 %27, label %28, label %25
28: ; preds = %25, %18
%29 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %25 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %6
32: ; preds = %11
%33 = load i32, i32* %2
ret i32 %33
}