#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 main() {
  int somaPositivos = 0, somaNegativos = 0, negativos = 0;
  for (int i = 0; i < 20; i++) {
    printf("\nDigite um numero");
    int numero;
    scanf("%d", &numero);
    if (numero < 0) {
      somaNegativos += numero;
      negativos++;
    } else
      somaPositivos += numero;
  }
  printf("A media dos numeros negativos é de:  %f\n",
         (float)somaNegativos / negativos);
  printf("A soma dos numeros positivos é: %d\n", somaPositivos);
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11b0 <main+0x90>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jge    1194 <main+0x74>
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119d <main+0x7d>
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11a2 <main+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <main+0x2b>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%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
mov    $0x14,%ebp
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%r12
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
mov    %eax,%ecx
mov    $0x0,%edx
cmovs  %edx,%ecx
add    %ecx,%ebx
mov    %eax,%ecx
sar    $0x1f,%ecx
and    %eax,%ecx
add    %ecx,%r14d
shr    $0x1f,%eax
add    %eax,%r13d
add    $0xffffffff,%ebp
jne    1150 <main+0x30>
cvtsi2ss %r14d,%xmm0
cvtsi2ss %r13d,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0ADigite um numero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"A media dos numeros negativos \C3\A9 de: %f\0A\00"
@.str.3 = [37 x i8] c"A soma dos numeros positivos \C3\A9: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %26, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = add nsw i32 %17, %16
store i32 %18, i32* %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %25
21: ; preds = %10
%22 = load i32, i32* %6
%23 = load i32, i32* %2
%24 = add nsw i32 %23, %22
store i32 %24, i32* %2
br label %25
25: ; preds = %21, %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %7
29: ; preds = %7
%30 = load i32, i32* %3
%31 = sitofp i32 %30 to float
%32 = load i32, i32* %4
%33 = sitofp i32 %32 to float
%34 = fdiv float %31, %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0ADigite um numero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"A media dos numeros negativos \C3\A9 de: %f\0A\00"
@.str.3 = [37 x i8] c"A soma dos numeros positivos \C3\A9: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %10
3: ; preds = %10
%4 = sitofp i32 %22 to float
%5 = sitofp i32 %24 to float
%6 = fdiv float %4, %5
%7 = fpext float %6 to double
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %20)
ret i32 0
10: ; preds = %0, %10
%11 = phi i32 [ 0, %0 ], [ %25, %10 ]
%12 = phi i32 [ 0, %0 ], [ %24, %10 ]
%13 = phi i32 [ 0, %0 ], [ %22, %10 ]
%14 = phi i32 [ 0, %0 ], [ %20, %10 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 0
%19 = select i1 %18, i32 0, i32 %17
%20 = add nuw nsw i32 %19, %14
%21 = select i1 %18, i32 %17, i32 0
%22 = add nsw i32 %21, %13
%23 = lshr i32 %17, 31
%24 = add nuw nsw i32 %23, %12
%25 = add nuw nsw i32 %11, 1
%26 = icmp eq i32 %25, 20
br i1 %26, label %3, label %10
}