#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 a, i;
  float sum, avr;
  sum = 0;
  avr = 0;
  scanf("%d", &a);
  while (a >= 1 && a <= 9999) {
    for (i = 0; a >= 1; i++) {
      sum = sum + a % 10;
      a = a / 10;
      avr = sum;
    }
    avr = sum / i;
    if (avr > 7)
      printf("heavy");
    else
      printf("light");
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jl     116b <main+0x4b>
cmpl   $0x270f,-0x8(%rbp)
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    117b <main+0x5b>
jmp    121a <main+0xfa>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     11cf <main+0xaf>
movss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <main+0x62>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe11(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1209 <main+0xe9>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1215 <main+0xf5>
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x270e,%ecx
ja     11de <main+0xbe>
xor    %ecx,%ecx
xorps  %xmm1,%xmm1
mov    $0xcccccccd,%ebx
lea    0xea9(%rip),%r14
lea    0xea8(%rip),%r15
jmp    118f <main+0x6f>
nopw   0x0(%rax,%rax,1)
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%edx
mov    $0x0,%ecx
cmp    $0x270f,%edx
movss  0xc(%rsp),%xmm1
jae    11de <main+0xbe>
mov    %eax,%edx
mov    %eax,%eax
imul   %rbx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
addss  %xmm0,%xmm1
add    $0x1,%ecx
cmp    $0x9,%edx
ja     118f <main+0x6f>
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mov    %eax,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
divss  %xmm0,%xmm1
ucomiss 0xe2c(%rip),%xmm1
mov    %r14,%rdi
ja     1170 <main+0x50>
mov    %r15,%rdi
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"heavy\00"
@.str.2 = [6 x i8] c"light\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %42, %0
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp sle i32 %11, 9999
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ false, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %43
15: ; preds = %13
store i32 0, i32* %3
br label %16
16: ; preds = %28, %15
%17 = load i32, i32* %2
%18 = icmp sge i32 %17, 1
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load float, float* %4
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
%23 = sitofp i32 %22 to float
%24 = fadd float %20, %23
store float %24, float* %4
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 10
store i32 %26, i32* %2
%27 = load float, float* %4
store float %27, float* %5
br label %28
28: ; preds = %19
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %16
31: ; preds = %16
%32 = load float, float* %4
%33 = load i32, i32* %3
%34 = sitofp i32 %33 to float
%35 = fdiv float %32, %34
store float %35, float* %5
%36 = load float, float* %5
%37 = fcmp ogt float %36, 7.000000e+00
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %42
40: ; preds = %31
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
br label %7
43: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"heavy\00"
@.str.2 = [6 x i8] c"light\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = add i32 %4, -1
%6 = icmp ult i32 %5, 9999
br i1 %6, label %7, label %29
7: ; preds = %0, %17
%8 = phi float [ %13, %17 ], [ 0.000000e+00, %0 ]
%9 = phi i32 [ %18, %17 ], [ 0, %0 ]
%10 = phi i32 [ %19, %17 ], [ %4, %0 ]
%11 = urem i32 %10, 10
%12 = sitofp i32 %11 to float
%13 = fadd float %8, %12
%14 = udiv i32 %10, 10
%15 = add nuw nsw i32 %9, 1
%16 = icmp ult i32 %10, 10
br i1 %16, label %20, label %17
17: ; preds = %7, %20
%18 = phi i32 [ %15, %7 ], [ 0, %20 ]
%19 = phi i32 [ %14, %7 ], [ %26, %20 ]
br label %7
20: ; preds = %7
store i32 %14, i32* %1
%21 = sitofp i32 %15 to float
%22 = fdiv float %13, %21
%23 = fcmp ogt float %22, 7.000000e+00
%24 = select i1 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%25 = call i32 @printf(i8* dereferenceable(1) %24)
%26 = load i32, i32* %1
%27 = add i32 %26, -1
%28 = icmp ult i32 %27, 9999
br i1 %28, label %17, label %29
29: ; preds = %20, %0
ret i32 0
}