#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 /*<<< orphan*/ printdigit(unsigned char *, int, int, int, unsigned char);
__attribute__((native)) void printscore(unsigned char *frame, int number, int x,
                                        int y, unsigned char color) {
  int tens, ones;
  tens = 0;
  while (number >= 10) {
    tens++;
    number -= 10;
  }
  printdigit(frame, tens, x, y, color);
  printdigit(frame, number, x + 5, y, color);
}


x86 assembly (clang, -O0):
<printscore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     1153 <printscore+0x43>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <printscore+0x22>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movzbl -0x15(%rbp),%r8d
call   1030 <printdigit@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x5,%edx
mov    -0x14(%rbp),%ecx
movzbl -0x15(%rbp),%r8d
call   1030 <printdigit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printscore>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%r15
xor    %esi,%esi
cmp    $0xa,%ebx
jl     1158 <printscore+0x48>
cmp    $0x13,%ebx
mov    $0x13,%eax
cmovl  %ebx,%eax
neg    %eax
add    %ebx,%eax
add    $0x9,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    0x1(%rcx),%esi
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
neg    %eax
add    %eax,%ebx
add    $0xfffffff6,%ebx
movzbl %r8b,%ebp
mov    %r15,%rdi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
call   1030 <printdigit@plt>
add    $0x5,%r12d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %ebp,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printdigit@plt>

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

LLVM IR (-O2):
define void @printscore(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4) {
%6 = icmp sgt i32 %1, 9
br i1 %6, label %7, label %16
7: ; preds = %5
%8 = add nuw i32 %1, 9
%9 = call i32 @llvm.smin.i32(i32 %1, i32 19)
%10 = sub nuw i32 %8, %9
%11 = udiv i32 %10, 10
%12 = add nuw nsw i32 %11, 1
%13 = mul nsw i32 %11, -10
%14 = add nsw i32 %1, -10
%15 = add nsw i32 %13, %14
br label %16
16: ; preds = %7, %5
%17 = phi i32 [ 0, %5 ], [ %12, %7 ]
%18 = phi i32 [ %1, %5 ], [ %15, %7 ]
%19 = tail call i32 @printdigit(i8* %0, i32 %17, i32 %2, i32 %3, i8 zeroext %4)
%20 = add nsw i32 %2, 5
%21 = tail call i32 @printdigit(i8* %0, i32 %18, i32 %20, i32 %3, i8 zeroext %4)
ret void
}