#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*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int x, contador = 1, acumulador = 0;
  float media;
  while (contador <= 10) {
    printf("\nDigite o %dº número: ", contador);
    scanf("%d", &x);
    if (x == -1)
      break;
    else if (x > 0) {
      acumulador = acumulador + x;
      contador++;
    }
  }
  media = (acumulador / (contador - 1));
  printf("\nA média dos números digitados é %.2f.\n\n", media);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     11ad <main+0x7d>
cvtsi2ssl -0xc(%rbp),%xmm0
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1187 <main+0x57>
jmp    11ad <main+0x7d>
cmpl   $0x0,-0x8(%rbp)
jle    11a3 <main+0x73>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x78>
jmp    114d <main+0x1d>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r13d,%r13d
mov    $0x1,%ebp
lea    0xeb6(%rip),%r14
lea    0xec8(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
je     119c <main+0x6c>
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r13d,%eax
setg   %cl
add    %eax,%ebx
add    %ecx,%ebp
cmp    $0xb,%ebp
jb     1160 <main+0x30>
mov    $0xb,%ebp
add    $0xffffffff,%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0ADigite o %d\C2\BA n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [44 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 %.2f.\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 0, i32* %1
store i32 1, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %27, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to float
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), float %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %9
br label %28
17: ; preds = %9
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = add nsw i32 %21, %22
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %26
26: ; preds = %20, %17
br label %27
27: ; preds = %26
br label %6
28: ; preds = %16, %6
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 1
%32 = sdiv i32 %29, %31
%33 = sitofp i32 %32 to float
store float %33, float* %5
%34 = load float, float* %5
%35 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), float %34)
%36 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0ADigite o %d\C2\BA n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [44 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 %.2f.\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %11
%4 = phi i32 [ 1, %0 ], [ %16, %11 ]
%5 = phi i32 [ 0, %0 ], [ %14, %11 ]
%6 = sitofp i32 %4 to float
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), float %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, -1
br i1 %10, label %18, label %11
11: ; preds = %3
%12 = icmp sgt i32 %9, 0
%13 = select i1 %12, i32 %9, i32 0
%14 = add nuw nsw i32 %13, %5
%15 = zext i1 %12 to i32
%16 = add nuw nsw i32 %4, %15
%17 = icmp ult i32 %16, 11
br i1 %17, label %3, label %18
18: ; preds = %3, %11
%19 = phi i32 [ %5, %3 ], [ %14, %11 ]
%20 = phi i32 [ %4, %3 ], [ 11, %11 ]
%21 = add nsw i32 %20, -1
%22 = sdiv i32 %19, %21
%23 = sitofp i32 %22 to float
%24 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), float %23)
%25 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}