#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 */
scalar_t__ log10(size_t const);
char *malloc(size_t);
int /*<<< orphan*/ snprintf(char *, size_t, char *, size_t const);
char *snakeInfo(const size_t score) {
  size_t allocated =
      sizeof("Score: ") + (score == 0 ? 1 : (int)log10(score) + 1);
  char *str = malloc(allocated);
  snprintf(str, allocated, "Score: %lu", score);
  return str;
}


x86 assembly (clang, -O0):
<snakeInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1154 <snakeInfo+0x24>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <snakeInfo+0x33>
mov    -0x8(%rbp),%rdi
call   1050 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cltq
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rcx
lea    0xe70(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snakeInfo>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1151 <snakeInfo+0x21>
mov    %r14,%rdi
call   1050 <log10@plt>
add    $0x1,%eax
movslq %eax,%rbx
add    $0x8,%rbx
jmp    1156 <snakeInfo+0x26>
mov    $0x9,%ebx
mov    %rbx,%rdi
call   1040 <malloc@plt>
mov    %rax,%r15
lea    0xe98(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Score: %lu\00"
define i8* @snakeInfo(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %13
8: ; preds = %1
%9 = load i64, i64* %2
%10 = call i64 @log10(i64 %9)
%11 = trunc i64 %10 to i32
%12 = add nsw i32 %11, 1
br label %13
13: ; preds = %8, %7
%14 = phi i32 [ 1, %7 ], [ %12, %8 ]
%15 = sext i32 %14 to i64
%16 = add i64 8, %15
store i64 %16, i64* %3
%17 = load i64, i64* %3
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = load i64, i64* %3
%21 = load i64, i64* %2
%22 = call i32 @snprintf(i8* %19, i64 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %21)
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
@.str = [11 x i8] c"Score: %lu\00"
define i8* @snakeInfo(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i64 @log10(i64 %0)
%5 = shl i64 %4, 32
%6 = add i64 %5, 4294967296
%7 = ashr exact i64 %6, 32
%8 = add nsw i64 %7, 8
br label %9
9: ; preds = %1, %3
%10 = phi i64 [ %8, %3 ], [ 9, %1 ]
%11 = tail call i8* @malloc(i64 %10)
%12 = tail call i32 @snprintf(i8* %11, i64 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %0)
ret i8* %11
}