#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*/ WriteUART(unsigned char);
void ResultOutput(unsigned char res) {
  unsigned char rr[4], c;
  char i = 0;
  for (i = 0; i < 3; i++) {
    c = res % 10;
    c |= 0x30;
    rr[i] = c;
    res /= 10;
    if (res == 0)
      break;
  }
  for (; i >= 0; i--)
    WriteUART(rr[i]);
}


x86 assembly (clang, -O0):
<ResultOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x0,-0x7(%rbp)
movb   $0x0,-0x7(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x3,%eax
jge    118d <ResultOutput+0x7d>
movzbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x6(%rbp)
movzbl -0x6(%rbp),%eax
or     $0x30,%eax
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%cl
movsbq -0x7(%rbp),%rax
mov    %cl,-0x5(%rbp,%rax,1)
movzbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    117b <ResultOutput+0x6b>
jmp    118d <ResultOutput+0x7d>
jmp    1180 <ResultOutput+0x70>
mov    -0x7(%rbp),%al
add    $0x1,%al
mov    %al,-0x7(%rbp)
jmp    1126 <ResultOutput+0x16>
jmp    1192 <ResultOutput+0x82>
movsbl -0x7(%rbp),%eax
cmp    $0x0,%eax
jl     11bb <ResultOutput+0xab>
movsbq -0x7(%rbp),%rax
movzbl -0x5(%rbp,%rax,1),%edi
call   1030 <WriteUART@plt>
mov    -0x7(%rbp),%al
add    $0xff,%al
mov    %al,-0x7(%rbp)
jmp    1192 <ResultOutput+0x82>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ResultOutput>:
push   %rbx
sub    $0x10,%rsp
imul   $0xcd,%edi,%eax
shr    $0xb,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %edi,%edx
sub    %cl,%dl
or     $0x30,%dl
mov    %dl,0xc(%rsp)
cmp    $0xa,%dil
jae    1139 <ResultOutput+0x29>
xor    %ebx,%ebx
jmp    1180 <ResultOutput+0x70>
movzbl %al,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
or     $0x30,%al
mov    %al,0xd(%rsp)
mov    $0x1,%ebx
cmp    $0x64,%dil
jb     1180 <ResultOutput+0x70>
movzbl %dil,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%eax
shr    $0xc,%eax
or     $0x30,%al
mov    %al,0xe(%rsp)
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl 0xc(%rsp,%rbx,1),%edi
call   1030 <WriteUART@plt>
add    $0xffffffffffffffff,%rbx
jb     1180 <ResultOutput+0x70>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @ResultOutput(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca [4 x i8]
%4 = alloca i8
%5 = alloca i8
store i8 %0, i8* %2
store i8 0, i8* %5
store i8 0, i8* %5
br label %6
6: ; preds = %32, %1
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %35
10: ; preds = %6
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = srem i32 %12, 10
%14 = trunc i32 %13 to i8
store i8 %14, i8* %4
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = or i32 %16, 48
%18 = trunc i32 %17 to i8
store i8 %18, i8* %4
%19 = load i8, i8* %4
%20 = load i8, i8* %5
%21 = sext i8 %20 to i64
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %21
store i8 %19, i8* %22
%23 = load i8, i8* %2
%24 = zext i8 %23 to i32
%25 = sdiv i32 %24, 10
%26 = trunc i32 %25 to i8
store i8 %26, i8* %2
%27 = load i8, i8* %2
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %10
br label %35
31: ; preds = %10
br label %32
32: ; preds = %31
%33 = load i8, i8* %5
%34 = add i8 %33, 1
store i8 %34, i8* %5
br label %6
35: ; preds = %30, %6
br label %36
36: ; preds = %46, %35
%37 = load i8, i8* %5
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = load i8, i8* %5
%42 = sext i8 %41 to i64
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @WriteUART(i8 zeroext %44)
br label %46
46: ; preds = %40
%47 = load i8, i8* %5
%48 = add i8 %47, -1
store i8 %48, i8* %5
br label %36
49: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @ResultOutput(i8 zeroext %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = urem i8 %0, 10
%5 = udiv i8 %0, 10
%6 = or i8 %4, 48
store i8 %6, i8* %3
%7 = icmp ult i8 %0, 10
br i1 %7, label %17, label %8
8: ; preds = %1
%9 = urem i8 %5, 10
%10 = or i8 %9, 48
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
store i8 %10, i8* %11
%12 = icmp ult i8 %0, 100
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = udiv i8 %0, 100
%15 = or i8 %14, 48
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
store i8 %15, i8* %16
br label %17
17: ; preds = %1, %8, %13
%18 = phi i64 [ 2, %13 ], [ 1, %8 ], [ 0, %1 ]
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %24, %19 ], [ %18, %17 ]
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = tail call i32 @WriteUART(i8 zeroext %22)
%24 = add nsw i64 %20, -1
%25 = icmp eq i64 %20, 0
br i1 %25, label %26, label %19
26: ; preds = %19
ret void
}