#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 *);
main() {
  int i;
  int menu[5] = {100, 200, 300, 400, 500};
  int count[5] = {};
  int total = 0;
  while (1) {
    scanf("%d", &i);
    count[i] += 1;
    if (i == -1) {
      break;
    }
  }
  for (i = 0; i < 5; i++) {
    printf("menu:%d %d %d %6d\n", i, menu[i], count[i], count[i] * menu[i]);
    total += count[i] * menu[i];
  }
  printf("Total: %d\n", total);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
lea    0xe98(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11a3 <main+0x73>
jmp    11a8 <main+0x78>
jmp    1175 <main+0x45>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1212 <main+0xe2>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%r8d
movslq -0x8(%rbp),%rax
imul   -0x20(%rbp,%rax,4),%r8d
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
movslq -0x8(%rbp),%rcx
imul   -0x20(%rbp,%rcx,4),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11af <main+0x7f>
mov    -0x44(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
lea    0xed4(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
addl   $0x1,0x10(%rsp,%rax,4)
cmp    $0xffffffffffffffff,%rax
jne    1150 <main+0x30>
movl   $0x0,0xc(%rsp)
lea    0xe86(%rip),%r15
lea    0xe96(%rip),%r14
xor    %ebx,%ebx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movslq %eax,%rsi
mov    (%r15,%rsi,4),%edx
mov    0x10(%rsp,%rsi,4),%ecx
mov    %ecx,%r8d
imul   %edx,%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rcx
mov    (%r15,%rcx,4),%eax
imul   0x10(%rsp,%rcx,4),%eax
add    %eax,%ebx
lea    0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x4,%rcx
jl     1190 <main+0x70>
lea    0xe5a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.menu = [5 x i32] [i32 100, i32 200, i32 300, i32 400, i32 500]
@.str = [3 x i8] c"%d\00"
@.str.1 = [19 x i8] c"menu:%d %d %d %6d\0A\00"
@.str.2 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca [5 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [5 x i32]* %3 to i8*
%7 = bitcast [5 x i32]* %4 to i8*
store i32 0, i32* %5
br label %8
8: ; preds = %0, %18
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %12
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %8
br label %19
18: ; preds = %8
br label %8
19: ; preds = %17
store i32 0, i32* %2
br label %20
20: ; preds = %54, %19
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 5
br i1 %22, label %23, label %57
23: ; preds = %20
%24 = load i32, i32* %2
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = mul nsw i32 %36, %40
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %28, i32 %32, i32 %41)
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = mul nsw i32 %46, %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, %51
store i32 %53, i32* %5
br label %54
54: ; preds = %23
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %20
57: ; preds = %20
%58 = load i32, i32* %5
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@__const.main.menu = [5 x i32] [i32 100, i32 200, i32 300, i32 400, i32 500]
@.str = [3 x i8] c"%d\00"
@.str.1 = [19 x i8] c"menu:%d %d %d %6d\0A\00"
@.str.2 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %9
%12 = icmp eq i32 %7, -1
br i1 %12, label %13, label %5
13: ; preds = %5
store i32 0, i32* %1
br label %14
14: ; preds = %13, %14
%15 = phi i32 [ 0, %13 ], [ %31, %14 ]
%16 = phi i32 [ 0, %13 ], [ %32, %14 ]
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.menu, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %17
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, %19
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %19, i32 %21, i32 %22)
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.menu, i64 0, i64 %25
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, %27
%31 = add nsw i32 %30, %15
%32 = add nsw i32 %24, 1
store i32 %32, i32* %1
%33 = icmp slt i32 %24, 4
br i1 %33, label %14, label %34
34: ; preds = %14
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %31)
ret i32 0
}