#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 /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int num, cont, acm;
  cont = acm = 0;
  float res;
  while (num != -1) {
    printf("\nDigite um inteiro positivo: ");
    scanf("%d", &num);
    if (num > 0) {
      acm = acm + num;
      cont++;
    }
  }
  res = (acm / cont);
  printf("\nA média dos números digitados é de: %.2f.\n\n", res);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1196 <main+0x66>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1191 <main+0x61>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x1d>
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe8d(%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   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%r14
lea    0xed4(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
mov    $0x0,%edx
cmovg  %eax,%edx
setg   %cl
add    %edx,%ebp
add    %ecx,%ebx
cmp    $0xffffffff,%eax
jne    1160 <main+0x30>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0ADigite um inteiro positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 de: %.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 0, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%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 sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = add nsw i32 %15, %16
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %14, %9
br label %6
21: ; preds = %6
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = sdiv i32 %22, %23
%25 = sitofp i32 %24 to float
store float %25, float* %5
%26 = load float, float* %5
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = 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 = [30 x i8] c"\0ADigite um inteiro positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros digitados \C3\A9 de: %.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, %3
%4 = phi i32 [ %13, %3 ], [ 0, %0 ]
%5 = phi i32 [ %11, %3 ], [ 0, %0 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%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 sgt i32 %8, 0
%10 = select i1 %9, i32 %8, i32 0
%11 = add nuw nsw i32 %10, %5
%12 = zext i1 %9 to i32
%13 = add nuw nsw i32 %4, %12
%14 = icmp eq i32 %8, -1
br i1 %14, label %15, label %3
15: ; preds = %3
%16 = udiv i32 %11, %13
%17 = sitofp i32 %16 to float
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}