#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 */
char *allocateMemory(scalar_t__);
char *getWordsFor2DigitNumber(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *getWordsForScale(int number, int scaleValue, char *scaleName) {
  char *wordsForScale;
  int twoDigitScaleNumber = number / scaleValue;
  if (twoDigitScaleNumber > 0) {
    char *twoDigitScaleWord = getWordsFor2DigitNumber(twoDigitScaleNumber);
    wordsForScale =
        allocateMemory(strlen(twoDigitScaleWord) + strlen(scaleName) + 1);
    strcpy(wordsForScale, twoDigitScaleWord);
    strcat(wordsForScale, " ");
    strcat(wordsForScale, scaleName);
    strcat(wordsForScale, " ");
  } else {
    wordsForScale = "";
  }
  return wordsForScale;
}


x86 assembly (clang, -O0):
<getWordsForScale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11eb <getWordsForScale+0x9b>
mov    -0x1c(%rbp),%edi
call   1050 <getWordsFor2DigitNumber@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1070 <allocateMemory@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <strcat@plt>
jmp    11f6 <getWordsForScale+0xa6>
lea    0xe0f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWordsForScale>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %edi,%eax
cltd
idiv   %esi
test   %eax,%eax
jle    11c3 <getWordsForScale+0x73>
mov    %eax,%edi
call   1050 <getWordsFor2DigitNumber@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
call   1070 <allocateMemory@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe60(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
jmp    11ca <getWordsForScale+0x7a>
lea    0xe37(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @getWordsForScale(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = sdiv i32 %10, %11
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %3
%16 = load i32, i32* %8
%17 = call i8* @getWordsFor2DigitNumber(i32 %16)
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = call i64 @strlen(i8* %18)
%20 = load i8*, i8** %6
%21 = call i64 @strlen(i8* %20)
%22 = add nsw i64 %19, %21
%23 = add nsw i64 %22, 1
%24 = call i8* @allocateMemory(i64 %23)
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = load i8*, i8** %9
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %7
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %7
%31 = load i8*, i8** %6
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %36
35: ; preds = %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %36
36: ; preds = %35, %15
%37 = load i8*, i8** %7
ret i8* %37
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @getWordsForScale(i32 %0, i32 %1, i8* %2) {
%4 = sdiv i32 %0, %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = tail call i8* @getWordsFor2DigitNumber(i32 %4)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %7)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%10 = add i64 %8, 1
%11 = add i64 %10, %9
%12 = tail call i8* @allocateMemory(i64 %11)
%13 = tail call i32 @strcpy(i8* %12, i8* %7)
%14 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %12, i8* %2)
%16 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %3, %6
%18 = phi i8* [ %12, %6 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %3 ]
ret i8* %18
}