#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 *, double *);
int /*<<< orphan*/ system(char *);
int main() {
  int contador = 0;
  double carga = 0, acumulador = 0;
  printf("\nExecutar 5 viagens\n");
  while (contador < 5) {
    printf("\nInforme a carga da viagem %d:", (contador + 1));
    scanf("%lf", &carga);
    contador = contador + 1;
    acumulador = acumulador + carga;
  }
  printf("\nFim de expediente. ");
  printf("\nNúmero de viagens : %d ", contador);
  printf("\nCarga total transportada : %6.2lf ", acumulador);
  printf("\nCarga média por viagem:%6.2lf\n", acumulador / contador);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x5,-0x8(%rbp)
jge    11af <main+0x7f>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1164 <main+0x34>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xf4c(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rbx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
xorpd  %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde9(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf0(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
divsd  0xd7d(%rip),%xmm0
lea    0xdf4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe07(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AExecutar 5 viagens\0A\00"
@.str.1 = [31 x i8] c"\0AInforme a carga da viagem %d:\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [21 x i8] c"\0AFim de expediente. \00"
@.str.4 = [26 x i8] c"\0AN\C3\BAmero de viagens : %d \00"
@.str.5 = [36 x i8] c"\0ACarga total transportada : %6.2lf \00"
@.str.6 = [33 x i8] c"\0ACarga m\C3\A9dia por viagem:%6.2lf\0A\00"
@.str.7 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load double, double* %4
%17 = load double, double* %3
%18 = fadd double %16, %17
store double %18, double* %4
br label %6
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = load double, double* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), double %23)
%25 = load double, double* %4
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %28)
%30 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"\0AInforme a carga da viagem %d:\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [21 x i8] c"\0AFim de expediente. \00"
@.str.4 = [26 x i8] c"\0AN\C3\BAmero de viagens : %d \00"
@.str.5 = [36 x i8] c"\0ACarga total transportada : %6.2lf \00"
@.str.6 = [33 x i8] c"\0ACarga m\C3\A9dia por viagem:%6.2lf\0A\00"
@.str.7 = [6 x i8] c"pause\00"
@str = [20 x i8] c"\0AExecutar 5 viagens\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 1)
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%6 = load double, double* %1
%7 = fadd double %6, 0.000000e+00
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 2)
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%10 = load double, double* %1
%11 = fadd double %7, %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 3)
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%14 = load double, double* %1
%15 = fadd double %11, %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 4)
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%18 = load double, double* %1
%19 = fadd double %15, %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 5)
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%22 = load double, double* %1
%23 = fadd double %19, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 5)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), double %23)
%27 = fdiv double %23, 5.000000e+00
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %27)
%29 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}