#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 *, unsigned short *);
int main() {
  const unsigned short int WALK_CAL = 5;
  const unsigned short int STAND_CAL = 2;
  const unsigned short int DRINK_CAL = 20;
  const unsigned short int FOOD_CAL = 40;
  const unsigned short int CALS_PER_POUND = 3500;
  unsigned short int walked = 0;
  unsigned short int stood = 0;
  unsigned short int drank = 0;
  unsigned short int ate = 0;
  printf("Enter the number of minutes you spent walking:\n> ");
  scanf("%hd", &walked);
  printf("Enter the number of minutes you spent standing:\n> ");
  scanf("%hd", &stood);
  printf("Enter the number of minutes you spent drinking:\n> ");
  scanf("%hd", &drank);
  printf("Enter the number of minutes you spent eating:\n> ");
  scanf("%hd", &ate);
  float calories = walked * WALK_CAL + stood * STAND_CAL -
                   (drank * DRINK_CAL + ate * FOOD_CAL);
  float pounds = calories / CALS_PER_POUND;
  printf("You lost %.3f pounds today!\n", pounds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x5,-0x6(%rbp)
movw   $0x2,-0x8(%rbp)
movw   $0x14,-0xa(%rbp)
movw   $0x28,-0xc(%rbp)
movw   $0xdac,-0xe(%rbp)
movw   $0x0,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
movw   $0x0,-0x16(%rbp)
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
lea    -0x16(%rbp),%rsi
call   1040 <scanf@plt>
movzwl -0x10(%rbp),%eax
imul   $0x5,%eax,%eax
movzwl -0x12(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
movzwl -0x14(%rbp),%ecx
imul   $0x14,%ecx,%ecx
movzwl -0x16(%rbp),%edx
imul   $0x28,%edx,%edx
add    %edx,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xdeb(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movw   $0x0,0xe(%rsp)
movw   $0x0,0xc(%rsp)
movw   $0x0,0xa(%rsp)
movw   $0x0,0x8(%rsp)
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rbx
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xa(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xf00(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movzwl 0xe(%rsp),%eax
lea    (%rax,%rax,4),%eax
movzwl 0xc(%rsp),%ecx
movzwl 0xa(%rsp),%edx
shl    $0x2,%edx
lea    (%rdx,%rdx,4),%edx
movzwl 0x8(%rsp),%esi
shl    $0x3,%esi
lea    (%rsi,%rsi,4),%esi
lea    (%rax,%rcx,2),%eax
sub    %edx,%eax
sub    %esi,%eax
cvtsi2ss %eax,%xmm0
divss  0xe16(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xedc(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Enter the number of minutes you spent walking:\0A> \00"
@.str.1 = [4 x i8] c"%hd\00"
@.str.2 = [51 x i8] c"Enter the number of minutes you spent standing:\0A> \00"
@.str.3 = [51 x i8] c"Enter the number of minutes you spent drinking:\0A> \00"
@.str.4 = [49 x i8] c"Enter the number of minutes you spent eating:\0A> \00"
@.str.5 = [29 x i8] c"You lost %.3f pounds today!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca float
%12 = alloca float
store i32 0, i32* %1
store i16 5, i16* %2
store i16 2, i16* %3
store i16 20, i16* %4
store i16 40, i16* %5
store i16 3500, i16* %6
store i16 0, i16* %7
store i16 0, i16* %8
store i16 0, i16* %9
store i16 0, i16* %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %7)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %8)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %9)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %10)
%21 = load i16, i16* %7
%22 = zext i16 %21 to i32
%23 = mul nsw i32 %22, 5
%24 = load i16, i16* %8
%25 = zext i16 %24 to i32
%26 = mul nsw i32 %25, 2
%27 = add nsw i32 %23, %26
%28 = load i16, i16* %9
%29 = zext i16 %28 to i32
%30 = mul nsw i32 %29, 20
%31 = load i16, i16* %10
%32 = zext i16 %31 to i32
%33 = mul nsw i32 %32, 40
%34 = add nsw i32 %30, %33
%35 = sub nsw i32 %27, %34
%36 = sitofp i32 %35 to float
store float %36, float* %11
%37 = load float, float* %11
%38 = fdiv float %37, 3.500000e+03
store float %38, float* %12
%39 = load float, float* %12
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"Enter the number of minutes you spent walking:\0A> \00"
@.str.1 = [4 x i8] c"%hd\00"
@.str.2 = [51 x i8] c"Enter the number of minutes you spent standing:\0A> \00"
@.str.3 = [51 x i8] c"Enter the number of minutes you spent drinking:\0A> \00"
@.str.4 = [49 x i8] c"Enter the number of minutes you spent eating:\0A> \00"
@.str.5 = [29 x i8] c"You lost %.3f pounds today!\0A\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = bitcast i16* %1 to i8*
store i16 0, i16* %1
%6 = bitcast i16* %2 to i8*
store i16 0, i16* %2
%7 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%8 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %4)
%17 = load i16, i16* %1
%18 = zext i16 %17 to i32
%19 = mul nuw nsw i32 %18, 5
%20 = load i16, i16* %2
%21 = zext i16 %20 to i32
%22 = shl nuw nsw i32 %21, 1
%23 = load i16, i16* %3
%24 = zext i16 %23 to i32
%25 = mul nsw i32 %24, -20
%26 = load i16, i16* %4
%27 = zext i16 %26 to i32
%28 = mul nsw i32 %27, -40
%29 = add nuw nsw i32 %22, %19
%30 = add nsw i32 %29, %25
%31 = add nsw i32 %30, %28
%32 = sitofp i32 %31 to float
%33 = fdiv float %32, 3.500000e+03
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %34)
ret i32 0
}