#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*/ string;

/* Variables and functions */
int /*<<< orphan*/ says(char *);
void sayn(long num) {
  char string[sizeof(long) * 3 + 1];
  char *p = string + sizeof(string) - 1;
  *p = '\0';
  if (num == 0)
    *--p = '0';
  else
    while (num) {
      *--p = '0' + num % 10;
      num = num / 10;
    }
  says(p);
}


x86 assembly (clang, -O0):
<sayn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rax
add    $0x19,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    1156 <sayn+0x46>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x30,-0x1(%rax)
jmp    11a8 <sayn+0x98>
jmp    115b <sayn+0x4b>
cmpq   $0x0,-0x8(%rbp)
je     11a3 <sayn+0x93>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
jmp    115b <sayn+0x4b>
jmp    11a8 <sayn+0x98>
mov    -0x38(%rbp),%rdi
call   1030 <says@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sayn>:
sub    $0x28,%rsp
movb   $0x0,0x18(%rsp)
test   %rdi,%rdi
je     1169 <sayn+0x59>
mov    %rdi,%rcx
lea    0x18(%rsp),%rdi
movabs $0x6666666666666667,%r8
66 66 66
mov    %rcx,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%esi
sub    %eax,%esi
add    $0x30,%sil
mov    %sil,-0x1(%rdi)
add    $0xffffffffffffffff,%rdi
add    $0x9,%rcx
cmp    $0x12,%rcx
mov    %rdx,%rcx
ja     1130 <sayn+0x20>
jmp    1173 <sayn+0x63>
lea    0x17(%rsp),%rdi
movb   $0x30,0x17(%rsp)
call   1030 <says@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define void @sayn(i64 %0) {
%2 = alloca i64
%3 = alloca [25 x i8]
%4 = alloca i8*
store i64 %0, i64* %2
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds i8, i8* %5, i64 25
%7 = getelementptr inbounds i8, i8* %6, i64 -1
store i8* %7, i8** %4
%8 = load i8*, i8** %4
store i8 0, i8* %8
%9 = load i64, i64* %2
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 -1
store i8* %13, i8** %4
store i8 48, i8* %13
br label %28
14: ; preds = %1
br label %15
15: ; preds = %18, %14
%16 = load i64, i64* %2
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i64, i64* %2
%20 = srem i64 %19, 10
%21 = add nsw i64 48, %20
%22 = trunc i64 %21 to i8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
store i8 %22, i8* %24
%25 = load i64, i64* %2
%26 = sdiv i64 %25, 10
store i64 %26, i64* %2
br label %15
27: ; preds = %15
br label %28
28: ; preds = %27, %11
%29 = load i8*, i8** %4
%30 = call i32 @says(i8* %29)
ret void
}

LLVM IR (-O2):
define void @sayn(i64 %0) {
%2 = alloca [25 x i8]
%3 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 24
store i8 0, i8* %4
%5 = icmp eq i64 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 23
store i8 48, i8* %7
br label %18
8: ; preds = %1, %8
%9 = phi i8* [ %14, %8 ], [ %4, %1 ]
%10 = phi i64 [ %15, %8 ], [ %0, %1 ]
%11 = srem i64 %10, 10
%12 = trunc i64 %11 to i8
%13 = add nsw i8 %12, 48
%14 = getelementptr inbounds i8, i8* %9, i64 -1
store i8 %13, i8* %14
%15 = sdiv i64 %10, 10
%16 = add i64 %10, 9
%17 = icmp ult i64 %16, 19
br i1 %17, label %18, label %8
18: ; preds = %8, %6
%19 = phi i8* [ %7, %6 ], [ %14, %8 ]
%20 = call i32 @says(i8* %19)
ret void
}