#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int x, contador = 1, acumulador = 0;
  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++;
    }
  }
  printf("\nA média dos números digitados é %d.\n\n",
         (acumulador / (contador - 1)));
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     11ab <main+0x7b>
mov    -0xc(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1185 <main+0x55>
jmp    11ab <main+0x7b>
cmpl   $0x0,-0x8(%rbp)
jle    11a1 <main+0x71>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a6 <main+0x76>
jmp    114d <main+0x1d>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
xor    %r13d,%r13d
lea    0xeb6(%rip),%r14
lea    0xec8(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
je     1197 <main+0x67>
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r13d,%eax
setg   %cl
add    %ecx,%ebx
add    %eax,%ebp
cmp    $0xb,%ebx
jb     1160 <main+0x30>
mov    $0xb,%ebx
add    $0xffffffff,%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
lea    0xe76(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xe92(%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 = [42 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 %d.\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
store i32 0, i32* %1
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %25, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 10
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %8
br label %26
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = add nsw i32 %19, %20
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %24
24: ; preds = %18, %15
br label %25
25: ; preds = %24
br label %5
26: ; preds = %14, %5
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 1
%30 = sdiv i32 %27, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = 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 = [42 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 %d.\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, %10
%4 = phi i32 [ 0, %0 ], [ %15, %10 ]
%5 = phi i32 [ 1, %0 ], [ %13, %10 ]
%6 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, -1
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = icmp sgt i32 %8, 0
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %5, %12
%14 = select i1 %11, i32 %8, i32 0
%15 = add nuw nsw i32 %14, %4
%16 = icmp ult i32 %13, 11
br i1 %16, label %3, label %17
17: ; preds = %3, %10
%18 = phi i32 [ %5, %3 ], [ 11, %10 ]
%19 = phi i32 [ %4, %3 ], [ %15, %10 ]
%20 = add nsw i32 %18, -1
%21 = sdiv i32 %19, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}