#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*/ asl(int, int);
scalar_t__ bcc();
scalar_t__ bne();
int /*<<< orphan*/ clc();
int /*<<< orphan*/ cmp(int, int);
int /*<<< orphan*/ lda(int, int);
int /*<<< orphan*/ ora(int /*<<< orphan*/, int);
int /*<<< orphan*/ ror(int, int);
int /*<<< orphan*/ sbc(int, int);
int /*<<< orphan*/ sec();
int /*<<< orphan*/ sta(int, int);
int /*<<< orphan*/ sty(int, int);
void div10() {
  sty(1, 0xff);
  lda(0, 0xa0);
  sta(1, 0xfa);
div10_loop:
  asl(1, 0xff);
  lda(1, 0xf8);
  cmp(1, 0xfa);
  if (bcc())
    goto less_than;
  sec();
  lda(1, 0xf8);
  sbc(1, 0xfa);
  sta(1, 0xf8);
  lda(1, 0xff);
  ora(0, 1);
  sta(1, 0xff);
less_than:
  clc();
  ror(1, 0xfa);
  lda(1, 0xfa);
  cmp(0, 0x5);
  if (bne())
    goto div10_loop;
  lda(1, 0xf8);
  sta(1, 0xfe);
}


x86 assembly (clang, -O0):
<div10>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%edi
mov    $0xff,%esi
call   1040 <sty@plt>
xor    %edi,%edi
mov    $0xa0,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1030 <sta@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   10c0 <asl@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1080 <cmp@plt>
mov    $0x0,%al
call   1090 <bcc@plt>
cmp    $0x0,%rax
je     1231 <div10+0x71>
jmp    128f <div10+0xcf>
mov    $0x0,%al
call   10a0 <sec@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1070 <sbc@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   1030 <sta@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   10d0 <lda@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <ora@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   1030 <sta@plt>
mov    $0x0,%al
call   10b0 <clc@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   10e0 <ror@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   10d0 <lda@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1080 <cmp@plt>
mov    $0x0,%al
call   1060 <bne@plt>
cmp    $0x0,%rax
je     12d6 <div10+0x116>
jmp    11ee <div10+0x2e>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfe,%esi
call   1030 <sta@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<div10>:
push   %rax
mov    $0x1,%edi
mov    $0xff,%esi
call   1040 <sty@plt>
xor    %edi,%edi
mov    $0xa0,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1030 <sta@plt>
jmp    1231 <div10+0x71>
nopl   (%rax)
xor    %eax,%eax
call   10b0 <clc@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   10e0 <ror@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   10d0 <lda@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1080 <cmp@plt>
xor    %eax,%eax
call   1060 <bne@plt>
test   %rax,%rax
je     12cd <div10+0x10d>
mov    $0x1,%edi
mov    $0xff,%esi
call   10c0 <asl@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1080 <cmp@plt>
xor    %eax,%eax
call   1090 <bcc@plt>
test   %rax,%rax
jne    11f0 <div10+0x30>
xor    %eax,%eax
call   10a0 <sec@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfa,%esi
call   1070 <sbc@plt>
mov    $0x1,%edi
mov    $0xf8,%esi
call   1030 <sta@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   10d0 <lda@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <ora@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   1030 <sta@plt>
jmp    11f0 <div10+0x30>
mov    $0x1,%edi
mov    $0xf8,%esi
call   10d0 <lda@plt>
mov    $0x1,%edi
mov    $0xfe,%esi
pop    %rax
jmp    1030 <sta@plt>

LLVM IR (-O0):
define void @div10() {
%1 = call i32 @sty(i32 1, i32 255)
%2 = call i32 @lda(i32 0, i32 160)
%3 = call i32 @sta(i32 1, i32 250)
br label %4
4: ; preds = %26, %0
%5 = call i32 @asl(i32 1, i32 255)
%6 = call i32 @lda(i32 1, i32 248)
%7 = call i32 @cmp(i32 1, i32 250)
%8 = call i64 (...) @bcc()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %4
br label %19
11: ; preds = %4
%12 = call i32 (...) @sec()
%13 = call i32 @lda(i32 1, i32 248)
%14 = call i32 @sbc(i32 1, i32 250)
%15 = call i32 @sta(i32 1, i32 248)
%16 = call i32 @lda(i32 1, i32 255)
%17 = call i32 @ora(i32 0, i32 1)
%18 = call i32 @sta(i32 1, i32 255)
br label %19
19: ; preds = %11, %10
%20 = call i32 (...) @clc()
%21 = call i32 @ror(i32 1, i32 250)
%22 = call i32 @lda(i32 1, i32 250)
%23 = call i32 @cmp(i32 0, i32 5)
%24 = call i64 (...) @bne()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
br label %4
27: ; preds = %19
%28 = call i32 @lda(i32 1, i32 248)
%29 = call i32 @sta(i32 1, i32 254)
ret void
}

LLVM IR (-O2):
define void @div10() {
%1 = tail call i32 @sty(i32 1, i32 255)
%2 = tail call i32 @lda(i32 0, i32 160)
%3 = tail call i32 @sta(i32 1, i32 250)
br label %4
4: ; preds = %18, %0
%5 = tail call i32 @asl(i32 1, i32 255)
%6 = tail call i32 @lda(i32 1, i32 248)
%7 = tail call i32 @cmp(i32 1, i32 250)
%8 = tail call i64 (...) @bcc()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %4
%11 = tail call i32 (...) @sec()
%12 = tail call i32 @lda(i32 1, i32 248)
%13 = tail call i32 @sbc(i32 1, i32 250)
%14 = tail call i32 @sta(i32 1, i32 248)
%15 = tail call i32 @lda(i32 1, i32 255)
%16 = tail call i32 @ora(i32 0, i32 1)
%17 = tail call i32 @sta(i32 1, i32 255)
br label %18
18: ; preds = %4, %10
%19 = tail call i32 (...) @clc()
%20 = tail call i32 @ror(i32 1, i32 250)
%21 = tail call i32 @lda(i32 1, i32 250)
%22 = tail call i32 @cmp(i32 0, i32 5)
%23 = tail call i64 (...) @bne()
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %4
25: ; preds = %18
%26 = tail call i32 @lda(i32 1, i32 248)
%27 = tail call i32 @sta(i32 1, i32 254)
ret void
}