#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 scanf(char *, int *);
int main(void) {
  int odd_num, even_num, integer, even, odd;
  odd_num = even_num = even = odd = 0;
  double even_aver, odd_aver;
  printf("Please enter an integer (0 to quit):\n");
  while (scanf("%d", &integer) == 1 && integer != 0) {
    if (integer % 2 == 0) {
      even += integer;
      even_num++;
    } else {
      odd += integer;
      odd_num++;
    }
    printf("Please enter another integer (0 to quit):\n");
  }
  even_aver = (double)even / even_num;
  odd_aver = (double)odd / odd_num;
  even_num <= 1 ? printf("You've entered %d even integer\n", even_num)
                : printf("You've entered %d even integers\n", even_num);
  if (even_num != 0)
    printf("The average value of the even numbers is %f\n", even_aver);
  odd_num <= 1 ? printf("You've entered %d odd integer\n", odd_num)
               : printf("You've entered %d odd integers\n", odd_num);
  if (odd_num != 0)
    printf("The average value of the odd numbers is %f\n", odd_aver);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x29(%rbp)
jne    1183 <main+0x63>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1193 <main+0x73>
jmp    11e3 <main+0xc3>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11be <main+0x9e>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d0 <main+0xb0>
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1159 <main+0x39>
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     1229 <main+0x109>
mov    -0xc(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
mov    -0xc(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1257 <main+0x137>
movsd  -0x20(%rbp),%xmm0
lea    0xe45(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jg     1277 <main+0x157>
mov    -0x8(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1288 <main+0x168>
mov    -0x8(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     12a5 <main+0x185>
movsd  -0x28(%rbp),%xmm0
lea    0xe63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r14d,%r14d
cmp    $0x1,%eax
jne    120e <main+0xde>
mov    0x4(%rsp),%eax
mov    $0x0,%r13d
mov    $0x0,%ebp
mov    $0x0,%ebx
test   %eax,%eax
je     11da <main+0xaa>
xor    %ebx,%ebx
lea    0xe7b(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   $0x1,%al
jne    11b0 <main+0x80>
add    %eax,%r14d
add    $0x1,%ebp
jmp    11b6 <main+0x86>
nopl   0x0(%rax)
add    %eax,%r13d
add    $0x1,%ebx
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11da <main+0xaa>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    11a0 <main+0x70>
cmp    $0x2,%ebp
jge    121a <main+0xea>
lea    0xe1d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jne    122a <main+0xfa>
cmp    $0x2,%ebx
jge    124a <main+0x11a>
lea    0xe72(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jne    125a <main+0x12a>
jmp    127b <main+0x14b>
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
cmp    $0x2,%ebp
jl     11df <main+0xaf>
lea    0xe02(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2sd %r14d,%xmm0
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
lea    0xe06(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x2,%ebx
jl     11f8 <main+0xc8>
lea    0xe3f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
lea    0xe3c(%rip),%rdi
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 = [38 x i8] c"Please enter an integer (0 to quit):\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Please enter another integer (0 to quit):\0A\00"
@.str.3 = [32 x i8] c"You've entered %d even integer\0A\00"
@.str.4 = [33 x i8] c"You've entered %d even integers\0A\00"
@.str.5 = [45 x i8] c"The average value of the even numbers is %f\0A\00"
@.str.6 = [31 x i8] c"You've entered %d odd integer\0A\00"
@.str.7 = [32 x i8] c"You've entered %d odd integers\0A\00"
@.str.8 = [44 x i8] c"The average value of the odd numbers is %f\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 double
%8 = alloca double
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %3
store i32 0, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %34, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %36
18: ; preds = %16
%19 = load i32, i32* %4
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = add nsw i32 %24, %23
store i32 %25, i32* %5
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %34
28: ; preds = %18
%29 = load i32, i32* %4
%30 = load i32, i32* %6
%31 = add nsw i32 %30, %29
store i32 %31, i32* %6
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %34
34: ; preds = %28, %22
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %10
36: ; preds = %16
%37 = load i32, i32* %5
%38 = sitofp i32 %37 to double
%39 = load i32, i32* %3
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
store double %41, double* %7
%42 = load i32, i32* %6
%43 = sitofp i32 %42 to double
%44 = load i32, i32* %2
%45 = sitofp i32 %44 to double
%46 = fdiv double %43, %45
store double %46, double* %8
%47 = load i32, i32* %3
%48 = icmp sle i32 %47, 1
br i1 %48, label %49, label %52
49: ; preds = %36
%50 = load i32, i32* %3
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %50)
br label %55
52: ; preds = %36
%53 = load i32, i32* %3
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %52, %49
%56 = phi i32 [ %51, %49 ], [ %54, %52 ]
%57 = load i32, i32* %3
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load double, double* %7
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), double %60)
br label %62
62: ; preds = %59, %55
%63 = load i32, i32* %2
%64 = icmp sle i32 %63, 1
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i32, i32* %2
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %71
68: ; preds = %62
%69 = load i32, i32* %2
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %68, %65
%72 = phi i32 [ %67, %65 ], [ %70, %68 ]
%73 = load i32, i32* %2
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = load double, double* %8
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), double %76)
br label %78
78: ; preds = %75, %71
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"You've entered %d even integer\0A\00"
@.str.4 = [33 x i8] c"You've entered %d even integers\0A\00"
@.str.5 = [45 x i8] c"The average value of the even numbers is %f\0A\00"
@.str.6 = [31 x i8] c"You've entered %d odd integer\0A\00"
@.str.7 = [32 x i8] c"You've entered %d odd integers\0A\00"
@.str.8 = [44 x i8] c"The average value of the odd numbers is %f\0A\00"
@str = [37 x i8] c"Please enter an integer (0 to quit):\00"
@str.9 = [42 x i8] c"Please enter another integer (0 to quit):\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %34
9: ; preds = %0, %23
%10 = phi i32 [ %31, %23 ], [ %6, %0 ]
%11 = phi i32 [ %27, %23 ], [ 0, %0 ]
%12 = phi i32 [ %26, %23 ], [ 0, %0 ]
%13 = phi i32 [ %25, %23 ], [ 0, %0 ]
%14 = phi i32 [ %24, %23 ], [ 0, %0 ]
%15 = and i32 %10, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = add nsw i32 %10, %14
%19 = add nsw i32 %12, 1
br label %23
20: ; preds = %9
%21 = add nsw i32 %10, %13
%22 = add nsw i32 %11, 1
br label %23
23: ; preds = %20, %17
%24 = phi i32 [ %18, %17 ], [ %14, %20 ]
%25 = phi i32 [ %13, %17 ], [ %21, %20 ]
%26 = phi i32 [ %19, %17 ], [ %12, %20 ]
%27 = phi i32 [ %11, %17 ], [ %22, %20 ]
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.9, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%30 = icmp eq i32 %29, 1
%31 = load i32, i32* %1
%32 = icmp ne i32 %31, 0
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %9, label %34
34: ; preds = %23, %0
%35 = phi i32 [ 0, %0 ], [ %24, %23 ]
%36 = phi i32 [ 0, %0 ], [ %25, %23 ]
%37 = phi i32 [ 0, %0 ], [ %26, %23 ]
%38 = phi i32 [ 0, %0 ], [ %27, %23 ]
%39 = sitofp i32 %35 to double
%40 = sitofp i32 %37 to double
%41 = fdiv double %39, %40
%42 = sitofp i32 %36 to double
%43 = sitofp i32 %38 to double
%44 = fdiv double %42, %43
%45 = icmp slt i32 %37, 2
br i1 %45, label %48, label %46
46: ; preds = %34
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %51
48: ; preds = %34
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%50 = icmp eq i32 %37, 0
br i1 %50, label %53, label %51
51: ; preds = %46, %48
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), double %41)
br label %53
53: ; preds = %51, %48
%54 = icmp slt i32 %38, 2
br i1 %54, label %57, label %55
55: ; preds = %53
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %60
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%59 = icmp eq i32 %38, 0
br i1 %59, label %62, label %60
60: ; preds = %55, %57
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), double %44)
br label %62
62: ; preds = %60, %57
ret i32 0
}