#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 values[100];
  int count = 0;
  int num;
  int i;
  float sum = 0;
  do {
    printf("Digite o número [%d] (-1 para sair): \n", (count + 1));
    scanf("%d", &num);
    values[count] = num;
    count++;
  } while (num != -1);
  printf("Os números digitados foram: \n");
  for (i = 0; i < (count - 1); i++)
    printf("[%d] ", values[i]);
  printf("\nGerando a média dos números: \n");
  for (i = 0; i < (count - 1); i++)
    sum += values[i];
  printf("\nA soma dos números foi: %f\n", sum);
  printf("\nA média dos números foi: %f\n", (sum / (count - 1)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1b0(%rbp)
ff
mov    -0x1a4(%rbp),%esi
add    $0x1,%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
cmpl   $0xffffffff,-0x1a8(%rbp)
jne    1147 <main+0x27>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
mov    -0x1a4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1200 <main+0xe0>
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    11b9 <main+0x99>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
mov    -0x1a4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1263 <main+0x143>
movslq -0x1ac(%rbp),%rax
cvtsi2ssl -0x1a0(%rbp,%rax,4),%xmm0
ff ff
addss  -0x1b0(%rbp),%xmm0
ff
movss  %xmm0,-0x1b0(%rbp)
ff
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    1218 <main+0xf8>
movss  -0x1b0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xdfc(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1b0(%rbp),%xmm0
ff
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a0,%rsp
mov    $0xffffffffffffffff,%r13
mov    $0x1,%ebx
lea    0xead(%rip),%r14
lea    0xece(%rip),%r15
lea    0xc(%rsp),%r12
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x14(%rsp,%r13,4)
add    $0x1,%r13
add    $0x1,%ebx
cmp    $0xffffffff,%eax
jne    1160 <main+0x30>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
test   %r13d,%r13d
je     11e9 <main+0xb9>
mov    %r13d,%r15d
lea    0xe84(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <main+0x80>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
test   %r13d,%r13d
je     11f5 <main+0xc5>
add    $0xffffffffffffffff,%r15
cmp    $0x3,%r15
jae    11fd <main+0xcd>
xorps  %xmm3,%xmm3
xor    %eax,%eax
jmp    124d <main+0x11d>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm3,%xmm3
jmp    1285 <main+0x155>
mov    %r13d,%ecx
mov    %r13d,%eax
and    $0x3,%eax
sub    %rax,%rcx
xorps  %xmm3,%xmm3
xor    %eax,%eax
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rsp,%rax,4),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x14(%rsp,%rax,4),%xmm1
addss  %xmm3,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ssl 0x18(%rsp,%rax,4),%xmm2
addss  %xmm0,%xmm1
xorps  %xmm3,%xmm3
cvtsi2ssl 0x1c(%rsp,%rax,4),%xmm3
addss  %xmm1,%xmm2
addss  %xmm2,%xmm3
add    $0x4,%rax
cmp    %rax,%rcx
jne    1210 <main+0xe0>
test   $0x3,%r13b
je     1285 <main+0x155>
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
mov    %r13d,%ecx
and    $0x3,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2ssl (%rax,%rdx,4),%xmm0
addss  %xmm0,%xmm3
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1270 <main+0x140>
movss  %xmm3,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xd8f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Digite o n\C3\BAmero [%d] (-1 para sair): \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Os n\C3\BAmeros digitados foram: \0A\00"
@.str.3 = [6 x i8] c"[%d] \00"
@.str.4 = [34 x i8] c"\0AGerando a m\C3\A9dia dos n\C3\BAmeros: \0A\00"
@.str.5 = [30 x i8] c"\0AA soma dos n\C3\BAmeros foi: %f\0A\00"
@.str.6 = [32 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros foi: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store float 0.000000e+00, float* %6
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %14
store i32 %12, i32* %15
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %7
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, -1
br i1 %20, label %7, label %21
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %23
23: ; preds = %34, %21
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %23
37: ; preds = %23
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %39
39: ; preds = %52, %37
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = sub nsw i32 %41, 1
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %55
44: ; preds = %39
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = sitofp i32 %48 to float
%50 = load float, float* %6
%51 = fadd float %50, %49
store float %51, float* %6
br label %52
52: ; preds = %44
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %39
55: ; preds = %39
%56 = load float, float* %6
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), double %57)
%59 = load float, float* %6
%60 = load i32, i32* %3
%61 = sub nsw i32 %60, 1
%62 = sitofp i32 %61 to float
%63 = fdiv float %59, %62
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), double %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"Digite o n\C3\BAmero [%d] (-1 para sair): \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"[%d] \00"
@.str.5 = [30 x i8] c"\0AA soma dos n\C3\BAmeros foi: %f\0A\00"
@.str.6 = [32 x i8] c"\0AA m\C3\A9dia dos n\C3\BAmeros foi: %f\0A\00"
@str = [30 x i8] c"Os n\C3\BAmeros digitados foram: \00"
@str.7 = [33 x i8] c"\0AGerando a m\C3\A9dia dos n\C3\BAmeros: \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %7, %5 ], [ 0, %0 ]
%7 = add nuw i64 %6, 1
%8 = trunc i64 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %6
store i32 %11, i32* %12
%13 = icmp eq i32 %11, -1
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = trunc i64 %6 to i32
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%17 = icmp eq i32 %15, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
br label %79
20: ; preds = %14
%21 = and i64 %6, 4294967295
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 0, %20 ], [ %27, %22 ]
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %21
br i1 %28, label %29, label %22
29: ; preds = %22
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
br i1 %17, label %79, label %31
31: ; preds = %29
%32 = add nsw i64 %21, -1
%33 = and i64 %6, 3
%34 = icmp ult i64 %32, 3
br i1 %34, label %63, label %35
35: ; preds = %31
%36 = sub nsw i64 %21, %33
br label %37
37: ; preds = %37, %35
%38 = phi i64 [ 0, %35 ], [ %60, %37 ]
%39 = phi float [ 0.000000e+00, %35 ], [ %59, %37 ]
%40 = phi i64 [ 0, %35 ], [ %61, %37 ]
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %38
%42 = load i32, i32* %41
%43 = sitofp i32 %42 to float
%44 = fadd float %39, %43
%45 = or i64 %38, 1
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = sitofp i32 %47 to float
%49 = fadd float %44, %48
%50 = or i64 %38, 2
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = sitofp i32 %52 to float
%54 = fadd float %49, %53
%55 = or i64 %38, 3
%56 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = sitofp i32 %57 to float
%59 = fadd float %54, %58
%60 = add nuw nsw i64 %38, 4
%61 = add i64 %40, 4
%62 = icmp eq i64 %61, %36
br i1 %62, label %63, label %37
63: ; preds = %37, %31
%64 = phi float [ undef, %31 ], [ %59, %37 ]
%65 = phi i64 [ 0, %31 ], [ %60, %37 ]
%66 = phi float [ 0.000000e+00, %31 ], [ %59, %37 ]
%67 = icmp eq i64 %33, 0
br i1 %67, label %79, label %68
68: ; preds = %63, %68
%69 = phi i64 [ %76, %68 ], [ %65, %63 ]
%70 = phi float [ %75, %68 ], [ %66, %63 ]
%71 = phi i64 [ %77, %68 ], [ 0, %63 ]
%72 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %69
%73 = load i32, i32* %72
%74 = sitofp i32 %73 to float
%75 = fadd float %70, %74
%76 = add nuw nsw i64 %69, 1
%77 = add i64 %71, 1
%78 = icmp eq i64 %77, %33
br i1 %78, label %79, label %68
79: ; preds = %63, %68, %18, %29
%80 = phi float [ 0.000000e+00, %29 ], [ 0.000000e+00, %18 ], [ %64, %63 ], [ %75, %68 ]
%81 = fpext float %80 to double
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), double %81)
%83 = sitofp i32 %15 to float
%84 = fdiv float %80, %83
%85 = fpext float %84 to double
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), double %85)
ret i32 0
}