#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 WALK_CAL = 5, STAND_CAL = 2, DRINK_CAL = 20,
                       FOOD_CAL = 40, CALS_PER_POUND = 3500;
  unsigned short walked = 0, stood = 0, drank = 0, 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;
  if (pounds > 0.000001)
    printf("You lost %.3f pounds today!\n", pounds);
  else if (pounds < -0.000001)
    printf("You gained %.3f pounds today!\n", pounds * -1);
  else
    printf("Your weight stayed EXACTLY the same today!\n");
  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    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%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  0xdfb(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1255 <main+0x135>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12a7 <main+0x187>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xda2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1294 <main+0x174>
movss  0xd9c(%rip),%xmm0
mulss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x182>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a7 <main+0x187>
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    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefc(%rip),%rbx
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeec(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf04(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xa(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf1c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <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,%xmm1
divss  0xe06(%rip),%xmm1
cvtss2sd %xmm1,%xmm0
ucomisd 0xe02(%rip),%xmm0
jbe    1211 <main+0xe1>
lea    0xeee(%rip),%rdi
jmp    1234 <main+0x104>
movsd  0xdf7(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    123d <main+0x10d>
xorps  0xdfa(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xee6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1249 <main+0x119>
lea    0xef5(%rip),%rdi
call   1030 <puts@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"
@.str.6 = [31 x i8] c"You gained %.3f pounds today!\0A\00"
@.str.7 = [44 x i8] c"Your weight stayed EXACTLY the same 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 = fcmp ogt double %40, 0x3EB0C6F7A0B5ED8D
br i1 %41, label %42, label %46
42: ; preds = %0
%43 = load float, float* %12
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %44)
br label %58
46: ; preds = %0
%47 = load float, float* %12
%48 = fpext float %47 to double
%49 = fcmp olt double %48, 0xBEB0C6F7A0B5ED8D
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load float, float* %12
%52 = fmul float %51, -1.000000e+00
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %53)
br label %57
55: ; preds = %46
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %57
57: ; preds = %55, %50
br label %58
58: ; preds = %57, %42
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"
@.str.6 = [31 x i8] c"You gained %.3f pounds today!\0A\00"
@str = [43 x i8] c"Your weight stayed EXACTLY the same today!\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 = fcmp ogt double %34, 0x3EB0C6F7A0B5ED8D
br i1 %35, label %36, label %38
36: ; preds = %0
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %34)
br label %46
38: ; preds = %0
%39 = fcmp olt double %34, 0xBEB0C6F7A0B5ED8D
br i1 %39, label %40, label %44
40: ; preds = %38
%41 = fneg float %33
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %42)
br label %46
44: ; preds = %38
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %46
46: ; preds = %40, %44, %36
ret i32 0
}