#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*/ uartPutc(char);
void sendUartData(unsigned int data) {
  char num[10];
  int i = 0;
  while (1) {
    num[i++] = data % 10 + '0';
    data /= 10;
    if (data == 0)
      break;
  }
  for (i -= 1; i >= 0; --i) {
    uartPutc(num[i]);
  }
  uartPutc('\n');
  return;
}


x86 assembly (clang, -O0):
<sendUartData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1162 <sendUartData+0x52>
jmp    1167 <sendUartData+0x57>
jmp    1122 <sendUartData+0x12>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1196 <sendUartData+0x86>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1030 <uartPutc@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <sendUartData+0x60>
mov    $0xa,%edi
call   1030 <uartPutc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendUartData>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %r15d,%r15d
mov    $0xcccccccd,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edi,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %edi,%esi
sub    %edx,%esi
or     $0x30,%sil
mov    %sil,0x6(%rsp,%r15,1)
add    $0x1,%r15
cmp    $0x9,%edi
mov    %ecx,%edi
ja     1130 <sendUartData+0x20>
add    $0xffffffffffffffff,%r15
mov    %r15d,%eax
lea    (%rsp,%rax,1),%r14
add    $0x6,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <uartPutc@plt>
lea    -0x1(%rbx),%rax
add    %r15d,%ebx
test   %ebx,%ebx
mov    %rax,%rbx
jg     1170 <sendUartData+0x60>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <uartPutc@plt>

LLVM IR (-O0):
define void @sendUartData(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %1, %19
%6 = load i32, i32* %2
%7 = urem i32 %6, 10
%8 = add i32 %7, 48
%9 = trunc i32 %8 to i8
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
store i32 %11, i32* %4
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %12
store i8 %9, i8* %13
%14 = load i32, i32* %2
%15 = udiv i32 %14, 10
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %5
br label %20
19: ; preds = %5
br label %5
20: ; preds = %18
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %32, %20
%24 = load i32, i32* %4
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @uartPutc(i8 signext %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
br label %23
35: ; preds = %23
%36 = call i32 @uartPutc(i8 signext 10)
ret void
}

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