#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 *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int i, number, negSum = 0, negCount = 0, posSum = 0, posCount = 0;
  printf("Enter numbers: \n");
  while (scanf("%d", &number) != 0 && number != -1) {
    if (number >= 0) {
      posSum += number;
      posCount++;
    } else {
      negSum += number;
      negCount++;
    }
  }
  printf("\nSum of all +ve numbers: %d \nMean of all +ve numbers: %.2f\n",
         posSum, ((float)posSum) / posCount);
  printf("\nSum of all -ve numbers: %d \nMean of all -ve numbers: %.2f\n",
         negSum, ((float)negSum) / negCount);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
je     1185 <main+0x65>
cmpl   $0xffffffff,-0xc(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1195 <main+0x75>
jmp    11cd <main+0xad>
cmpl   $0x0,-0xc(%rbp)
jl     11b6 <main+0x96>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0xa8>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <main+0x39>
mov    -0x18(%rbp),%esi
cvtsi2ssl -0x18(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%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
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     11c2 <main+0x92>
mov    0x4(%rsp),%eax
mov    $0x0,%r13d
mov    $0x0,%ebp
mov    $0x0,%ebx
cmp    $0xffffffff,%eax
je     11c9 <main+0x99>
xor    %ebx,%ebx
lea    0xe7e(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %r12d,%r12d
nop
test   %eax,%eax
js     11a0 <main+0x70>
add    %eax,%ebp
add    $0x1,%ebx
jmp    11a7 <main+0x77>
nopl   0x0(%rax,%rax,1)
add    %eax,%r12d
add    $0x1,%r13d
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11c9 <main+0x99>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
jne    1190 <main+0x60>
jmp    11c9 <main+0x99>
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
cvtsi2ss %ebp,%xmm0
cvtsi2ss %ebx,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe23(%rip),%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r12d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %r13d,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe37(%rip),%rdi
mov    %r12d,%esi
mov    $0x1,%al
call   1040 <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 = [17 x i8] c"Enter numbers: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [60 x i8] c"\0ASum of all +ve numbers: %d \0AMean of all +ve numbers: %.2f\0A\00"
@.str.3 = [60 x i8] c"\0ASum of all -ve numbers: %d \0AMean of all -ve numbers: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %32, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, -1
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %33
17: ; preds = %15
%18 = load i32, i32* %3
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %3
%22 = load i32, i32* %6
%23 = add nsw i32 %22, %21
store i32 %23, i32* %6
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %32
26: ; preds = %17
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = add nsw i32 %28, %27
store i32 %29, i32* %4
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %32
32: ; preds = %26, %20
br label %9
33: ; preds = %15
%34 = load i32, i32* %6
%35 = load i32, i32* %6
%36 = sitofp i32 %35 to float
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to float
%39 = fdiv float %36, %38
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %34, double %40)
%42 = load i32, i32* %4
%43 = load i32, i32* %4
%44 = sitofp i32 %43 to float
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to float
%47 = fdiv float %44, %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i32 %42, double %48)
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [60 x i8] c"\0ASum of all +ve numbers: %d \0AMean of all +ve numbers: %.2f\0A\00"
@.str.3 = [60 x i8] c"\0ASum of all -ve numbers: %d \0AMean of all -ve numbers: %.2f\0A\00"
@str = [16 x i8] c"Enter numbers: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp ne i64 %4, 0
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, -1
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %32
9: ; preds = %0, %22
%10 = phi i32 [ %29, %22 ], [ %6, %0 ]
%11 = phi i32 [ %26, %22 ], [ 0, %0 ]
%12 = phi i32 [ %25, %22 ], [ 0, %0 ]
%13 = phi i32 [ %24, %22 ], [ 0, %0 ]
%14 = phi i32 [ %23, %22 ], [ 0, %0 ]
%15 = icmp sgt i32 %10, -1
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = add nsw i32 %10, %12
%18 = add nsw i32 %11, 1
br label %22
19: ; preds = %9
%20 = add nsw i32 %10, %14
%21 = add nsw i32 %13, 1
br label %22
22: ; preds = %19, %16
%23 = phi i32 [ %14, %16 ], [ %20, %19 ]
%24 = phi i32 [ %13, %16 ], [ %21, %19 ]
%25 = phi i32 [ %17, %16 ], [ %12, %19 ]
%26 = phi i32 [ %18, %16 ], [ %11, %19 ]
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%28 = icmp ne i64 %27, 0
%29 = load i32, i32* %1
%30 = icmp ne i32 %29, -1
%31 = select i1 %28, i1 %30, i1 false
br i1 %31, label %9, label %32
32: ; preds = %22, %0
%33 = phi i32 [ 0, %0 ], [ %23, %22 ]
%34 = phi i32 [ 0, %0 ], [ %24, %22 ]
%35 = phi i32 [ 0, %0 ], [ %25, %22 ]
%36 = phi i32 [ 0, %0 ], [ %26, %22 ]
%37 = sitofp i32 %35 to float
%38 = sitofp i32 %36 to float
%39 = fdiv float %37, %38
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %35, double %40)
%42 = sitofp i32 %33 to float
%43 = sitofp i32 %34 to float
%44 = fdiv float %42, %43
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i32 %33, double %45)
ret i32 0
}