#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 */
typedef int /*<<< orphan*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
char *kml_gc_mkstar(int rating) {
  static char tmp[40];
  if (0 == rating % 10) {
    snprintf(tmp, sizeof(tmp), "stars%d", rating / 10);
  } else {
    snprintf(tmp, sizeof(tmp), "stars%d_%d", rating / 10, rating % 10);
  }
  return tmp;
}


x86 assembly (clang, -O0):
<kml_gc_mkstar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    115c <kml_gc_mkstar+0x4c>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
lea    0x2efc(%rip),%rdi
mov    $0x28,%esi
lea    0xeb0(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1191 <kml_gc_mkstar+0x81>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    %edx,%r8d
lea    0x2ec2(%rip),%rdi
mov    $0x28,%esi
lea    0xe7e(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2ea8(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kml_gc_mkstar>:
push   %rax
movslq %edi,%r8
imul   $0x66666667,%r8,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,4),%eax
lea    0x2f0b(%rip),%rdi
sub    %eax,%r8d
je     114f <kml_gc_mkstar+0x3f>
lea    0xec7(%rip),%rdx
mov    $0x28,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1162 <kml_gc_mkstar+0x52>
lea    0xeaa(%rip),%rdx
mov    $0x28,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2ed7(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@kml_gc_mkstar.tmp = internal global [40 x i8] zeroinitializer
@.str = [8 x i8] c"stars%d\00"
@.str.1 = [11 x i8] c"stars%d_%d\00"
define i8* @kml_gc_mkstar(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 10
%5 = icmp eq i32 0, %4
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 10
%9 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %16
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 10
%13 = load i32, i32* %2
%14 = srem i32 %13, 10
%15 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14)
br label %16
16: ; preds = %10, %6
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0)
}

LLVM IR (-O2):
@kml_gc_mkstar.tmp = internal global [40 x i8] zeroinitializer
@.str = [8 x i8] c"stars%d\00"
@.str.1 = [11 x i8] c"stars%d_%d\00"
define i8* @kml_gc_mkstar(i32 %0) {
%2 = srem i32 %0, 10
%3 = icmp eq i32 %2, 0
%4 = sdiv i32 %0, 10
br i1 %3, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %2)
br label %9
9: ; preds = %7, %5
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @kml_gc_mkstar.tmp, i64 0, i64 0)
}