#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 *);
main() {
  int count = 0, sum = 0, value;
  char ch;
  float average;
  while (1) {
    printf("Enter integer: ");
    scanf("%d", &value);
    if (value == 0)
      break;
    sum = sum + value;
    count++;
  }
  average = sum / count;
  printf("The average of the values is %f\n", average);
  printf("Enter an integer from 32 to 127: ");
  scanf("%d", &value);
  ch = (char)value;
  printf("The ASCIII value for '%c' is %d.\n", ch, ch);
}


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)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    116a <main+0x4a>
jmp    1181 <main+0x61>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%esi
movsbl -0x11(%rbp),%edx
lea    0xe7b(%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   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecc(%rip),%r15
lea    0xc(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
add    %eax,%ebp
add    $0x1,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1160 <main+0x40>
mov    %ebp,%eax
cltd
idiv   %ebx
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movsbl 0xc(%rsp),%edx
lea    0xe8e(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
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 = [16 x i8] c"Enter integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"The average of the values is %f\0A\00"
@.str.3 = [34 x i8] c"Enter an integer from 32 to 127: \00"
@.str.4 = [34 x i8] c"The ASCIII value for '%c' is %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %0, %13
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%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* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
br label %19
13: ; preds = %7
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %14, %15
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %7
19: ; preds = %12
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = sdiv i32 %20, %21
%23 = sitofp i32 %22 to float
store float %23, float* %6
%24 = load float, float* %6
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%29 = load i32, i32* %4
%30 = trunc i32 %29 to i8
store i8 %30, i8* %5
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"The average of the values is %f\0A\00"
@.str.3 = [34 x i8] c"Enter an integer from 32 to 127: \00"
@.str.4 = [34 x i8] c"The ASCIII value for '%c' is %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ %15, %7 ], [ %5, %0 ]
%9 = phi i32 [ %12, %7 ], [ 0, %0 ]
%10 = phi i32 [ %11, %7 ], [ 0, %0 ]
%11 = add nsw i32 %8, %10
%12 = add nuw nsw i32 %9, 1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = sdiv i32 %11, %12
%19 = sitofp i32 %18 to float
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = shl i32 %24, 24
%26 = ashr exact i32 %25, 24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %26)
ret i32 0
}