#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 lire_entier();
int /*<<< orphan*/ printf(char *, double);
int main() {
  int a = 0, n = 0, s = 0;
  double m;
  while (a >= 0) {
    a = lire_entier();
    if (a >= 0) {
      n++;
      s += a;
    }
  }
  m = (float)s / n;
  printf("%d nombres positifs ont été tapspé à la suite! \n", n);
  printf("La moyenne de cette suite est %.2f \n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1179 <main+0x59>
mov    $0x0,%al
call   1040 <lire_entier@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1174 <main+0x54>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <main+0x24>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <lire_entier@plt>
mov    %eax,%ecx
not    %ecx
shr    $0x1f,%ecx
add    %ecx,%ebx
test   %eax,%eax
mov    $0x0,%ecx
cmovns %eax,%ecx
add    %ecx,%ebp
test   %eax,%eax
jns    1130 <main+0x10>
cvtsi2ss %ebp,%xmm0
cvtsi2ss %ebx,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
movsd  (%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"%d nombres positifs ont \C3\A9t\C3\A9 tapsp\C3\A9 \C3\A0 la suite! \0A\00"
@.str.1 = [37 x i8] c"La moyenne de cette suite est %.2f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = call i32 (...) @lire_entier()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = add nsw i32 %17, %16
store i32 %18, i32* %4
br label %19
19: ; preds = %13, %9
br label %6
20: ; preds = %6
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to float
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
%26 = fpext float %25 to double
store double %26, double* %5
%27 = load i32, i32* %3
%28 = sitofp i32 %27 to double
%29 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %28)
%30 = load double, double* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [53 x i8] c"%d nombres positifs ont \C3\A9t\C3\A9 tapsp\C3\A9 \C3\A0 la suite! \0A\00"
@.str.1 = [37 x i8] c"La moyenne de cette suite est %.2f \0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %10, %1 ]
%3 = phi i32 [ 0, %0 ], [ %7, %1 ]
%4 = tail call i32 (...) @lire_entier()
%5 = xor i32 %4, -1
%6 = lshr i32 %5, 31
%7 = add nuw nsw i32 %6, %3
%8 = icmp sgt i32 %4, 0
%9 = select i1 %8, i32 %4, i32 0
%10 = add nuw nsw i32 %9, %2
%11 = icmp sgt i32 %4, -1
br i1 %11, label %1, label %12
12: ; preds = %1
%13 = sitofp i32 %10 to float
%14 = sitofp i32 %7 to float
%15 = fdiv float %13, %14
%16 = fpext float %15 to double
%17 = sitofp i32 %7 to double
%18 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %16)
ret i32 0
}