#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 main() {
  const unsigned short int FIRST_CAR_LENGTH = 10;
  const unsigned short int NORMAL_CAR_LENGTH = 8;
  const unsigned short int CAR_CAPACITY = 4;
  float tracklength = 0;
  unsigned short int maxtrainlength = 10;
  printf("Enter the total length of track in feet:\n> ");
  scanf("%f", &tracklength);
  printf("Enter the maximum length of a train in feet:\n> ");
  scanf("%hd", &maxtrainlength);
  unsigned short int numcars =
      (maxtrainlength - FIRST_CAR_LENGTH) / NORMAL_CAR_LENGTH;
  numcars++;
  unsigned short int truetrainlength =
      (numcars - 1) * NORMAL_CAR_LENGTH + FIRST_CAR_LENGTH;
  unsigned short int numtrains = (tracklength / truetrainlength) * 0.25;
  unsigned short int maxnumpassengers = numcars * CAR_CAPACITY * numtrains;
  printf("Your ride can have at most %hd people on it at one time.\n",
         maxnumpassengers);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0xa,-0x6(%rbp)
movw   $0x8,-0x8(%rbp)
movw   $0x4,-0xa(%rbp)
movl   $0x0,-0x10(%rbp)
movw   $0xa,-0x12(%rbp)
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1b(%rbp)
call   1030 <printf@plt>
mov    -0x1b(%rbp),%al
lea    0xecb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1b(%rbp),%al
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1b(%rbp),%al
lea    0xedc(%rip),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <scanf@plt>
movzwl -0x12(%rbp),%ecx
mov    %ecx,%eax
add    $0xfffffff6,%eax
add    $0xfffffffd,%ecx
test   %eax,%eax
cmovs  %ecx,%eax
shr    $0x3,%eax
mov    %ax,-0x14(%rbp)
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
movzwl -0x14(%rbp),%ecx
mov    %ecx,%eax
lea    0x2(,%rax,8),%eax
mov    %ax,-0x16(%rbp)
movss  -0x10(%rbp),%xmm0
movzwl -0x16(%rbp),%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1a(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x18(%rbp)
movzwl -0x14(%rbp),%eax
shl    $0x2,%eax
movzwl -0x18(%rbp),%ecx
imul   %ecx,%eax
mov    %ax,-0x1a(%rbp)
movzwl -0x1a(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
movw   $0xa,0x2(%rsp)
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0x2(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzwl 0x2(%rsp),%eax
lea    -0xa(%rax),%ecx
add    $0xfffffffd,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x3,%eax
lea    0xa(,%rax,8),%ecx
movzwl %cx,%ecx
cvtsi2ss %ecx,%xmm0
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe54(%rip),%xmm0
cvttsd2si %xmm0,%ecx
add    $0x1,%eax
imul   %eax,%ecx
shl    $0x2,%ecx
movzwl %cx,%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter the total length of track in feet:\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [48 x i8] c"Enter the maximum length of a train in feet:\0A> \00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [58 x i8] c"Your ride can have at most %hd people on it at one time.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca float
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
store i32 0, i32* %1
store i16 10, i16* %2
store i16 8, i16* %3
store i16 4, i16* %4
store float 0.000000e+00, float* %5
store i16 10, i16* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %6)
%15 = load i16, i16* %6
%16 = zext i16 %15 to i32
%17 = sub nsw i32 %16, 10
%18 = sdiv i32 %17, 8
%19 = trunc i32 %18 to i16
store i16 %19, i16* %7
%20 = load i16, i16* %7
%21 = add i16 %20, 1
store i16 %21, i16* %7
%22 = load i16, i16* %7
%23 = zext i16 %22 to i32
%24 = sub nsw i32 %23, 1
%25 = mul nsw i32 %24, 8
%26 = add nsw i32 %25, 10
%27 = trunc i32 %26 to i16
store i16 %27, i16* %8
%28 = load float, float* %5
%29 = load i16, i16* %8
%30 = zext i16 %29 to i32
%31 = sitofp i32 %30 to float
%32 = fdiv float %28, %31
%33 = fpext float %32 to double
%34 = fmul double %33, 2.500000e-01
%35 = fptoui double %34 to i16
store i16 %35, i16* %9
%36 = load i16, i16* %7
%37 = zext i16 %36 to i32
%38 = mul nsw i32 %37, 4
%39 = load i16, i16* %9
%40 = zext i16 %39 to i32
%41 = mul nsw i32 %38, %40
%42 = trunc i32 %41 to i16
store i16 %42, i16* %10
%43 = load i16, i16* %10
%44 = zext i16 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Enter the total length of track in feet:\0A> \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [48 x i8] c"Enter the maximum length of a train in feet:\0A> \00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [58 x i8] c"Your ride can have at most %hd people on it at one time.\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i16
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = bitcast i16* %2 to i8*
store i16 10, i16* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %2)
%9 = load i16, i16* %2
%10 = zext i16 %9 to i32
%11 = add nsw i32 %10, -10
%12 = sdiv i32 %11, 8
%13 = add nsw i32 %12, 1
%14 = shl nuw nsw i32 %13, 3
%15 = load float, float* %1
%16 = and i32 %14, 65528
%17 = or i32 %16, 2
%18 = sitofp i32 %17 to float
%19 = fdiv float %15, %18
%20 = fpext float %19 to double
%21 = fmul double %20, 2.500000e-01
%22 = fptoui double %21 to i16
%23 = trunc i32 %13 to i16
%24 = shl nuw nsw i16 %23, 2
%25 = mul i16 %24, %22
%26 = zext i16 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i32 %26)
ret i32 0
}