#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 main() {
  int sum = 0;
  int counter = 1;
  int input_number = 0;
  bool judge = true;
  do {
    printf("Enter the %d number,End with \"0\"", counter);
    scanf("%d", &input_number);
    sum = sum + input_number;
    judge = input_number;
    input_number = 0;
    counter++;
  } while (judge);
  printf("The average is:%d", sum / (counter - 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    114b <main+0x2b>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@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
movl   $0x0,0xc(%rsp)
xor    %ebp,%ebp
mov    $0xffffffff,%ebx
lea    0xebe(%rip),%r14
lea    0xee7(%rip),%r15
lea    0xc(%rsp),%r12
xchg   %ax,%ax
lea    0x2(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
add    %eax,%ebp
movl   $0x0,0xc(%rsp)
add    $0x1,%ebx
test   %eax,%eax
jne    1150 <main+0x30>
mov    %ebp,%eax
cltd
idiv   %ebx
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the %d number,End with \220\22\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The average is:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = add nsw i32 %10, %11
store i32 %12, i32* %2
%13 = load i32, i32* %4
store i32 %13, i32* %5
store i32 0, i32* %4
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %6
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 2
%23 = sdiv i32 %20, %22
%24 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter the %d number,End with \220\22\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"The average is:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %3, %0
%4 = phi i32 [ 0, %0 ], [ %9, %3 ]
%5 = phi i32 [ 1, %0 ], [ %10, %3 ]
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 = add nsw i32 %8, %4
store i32 0, i32* %1
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %8, 0
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = add nsw i32 %5, -1
%14 = sdiv i32 %9, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %14)
ret i32 0
}