#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 getCharacterTime(int);
int getSpaceTime(int c_rate, int w_rate) {
  int t_total;
  int t_chars;
  int t_space;
  if (w_rate < 5)
    w_rate = 5;
  if (w_rate >= c_rate)
    return getCharacterTime(c_rate);
  t_total = getCharacterTime(w_rate) * 50;
  t_chars = getCharacterTime(c_rate) * 36;
  t_space = t_total - t_chars;
  return t_space / 14;
}


x86 assembly (clang, -O0):
<getSpaceTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    112f <getSpaceTime+0x1f>
movl   $0x5,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     114b <getSpaceTime+0x3b>
mov    -0x8(%rbp),%edi
call   1030 <getCharacterTime@plt>
mov    %eax,-0x4(%rbp)
jmp    117e <getSpaceTime+0x6e>
mov    -0xc(%rbp),%edi
call   1030 <getCharacterTime@plt>
imul   $0x32,%eax,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <getCharacterTime@plt>
imul   $0x24,%eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xe,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSpaceTime>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x6,%esi
mov    $0x5,%edi
cmovge %esi,%edi
cmp    %ebx,%edi
jge    115c <getSpaceTime+0x4c>
call   1030 <getCharacterTime@plt>
imul   $0x32,%eax,%ebp
mov    %ebx,%edi
call   1030 <getCharacterTime@plt>
shl    $0x2,%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebp
movslq %ebp,%rax
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x3,%eax
add    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <getCharacterTime@plt>

LLVM IR (-O0):
define i32 @getSpaceTime(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 5, i32* %5
br label %12
12: ; preds = %11, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %4
%18 = call i32 @getCharacterTime(i32 %17)
store i32 %18, i32* %3
br label %31
19: ; preds = %12
%20 = load i32, i32* %5
%21 = call i32 @getCharacterTime(i32 %20)
%22 = mul nsw i32 %21, 50
store i32 %22, i32* %6
%23 = load i32, i32* %4
%24 = call i32 @getCharacterTime(i32 %23)
%25 = mul nsw i32 %24, 36
store i32 %25, i32* %7
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = sub nsw i32 %26, %27
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = sdiv i32 %29, 14
store i32 %30, i32* %3
br label %31
31: ; preds = %19, %16
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @getSpaceTime(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 5
%4 = select i1 %3, i32 %1, i32 5
%5 = icmp slt i32 %4, %0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @getCharacterTime(i32 %0)
br label %15
8: ; preds = %2
%9 = tail call i32 @getCharacterTime(i32 %4)
%10 = mul nsw i32 %9, 50
%11 = tail call i32 @getCharacterTime(i32 %0)
%12 = mul i32 %11, -36
%13 = add i32 %12, %10
%14 = sdiv i32 %13, 14
br label %15
15: ; preds = %8, %6
%16 = phi i32 [ %7, %6 ], [ %14, %8 ]
ret i32 %16
}