#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 volatile);
void sendUartData(unsigned int data) {
  uartPutc(10);
  uartPutc(33);
  volatile char num[10];
  volatile 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]);
  }
  return;
}


x86 assembly (clang, -O0):
<sendUartData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xa,%edi
call   1030 <uartPutc@plt>
mov    $0x21,%edi
call   1030 <uartPutc@plt>
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    1176 <sendUartData+0x66>
jmp    117b <sendUartData+0x6b>
jmp    1136 <sendUartData+0x26>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    $0x0,%eax
jl     11af <sendUartData+0x9f>
mov    -0x14(%rbp),%eax
cltq
mov    -0xe(%rbp,%rax,1),%al
movsbl %al,%edi
call   1030 <uartPutc@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <sendUartData+0x74>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendUartData>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0xa,%edi
call   1030 <uartPutc@plt>
mov    $0x21,%edi
call   1030 <uartPutc@plt>
movl   $0x0,(%rsp)
mov    $0xcccccccd,%eax
nopw   0x0(%rax,%rax,1)
mov    %ebx,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ebx,%esi
sub    %edx,%esi
or     $0x30,%sil
movslq (%rsp),%rdx
lea    0x1(%rdx),%edi
mov    %edi,(%rsp)
mov    %sil,0x6(%rsp,%rdx,1)
cmp    $0x9,%ebx
mov    %ecx,%ebx
ja     1140 <sendUartData+0x30>
jmp    117e <sendUartData+0x6e>
movslq (%rsp),%rax
movsbl 0x6(%rsp,%rax,1),%edi
call   1030 <uartPutc@plt>
addl   $0xffffffff,(%rsp)
cmpl   $0x0,(%rsp)
jns    1170 <sendUartData+0x60>
add    $0x10,%rsp
pop    %rbx
ret

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

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