#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 */
short oled_write(char);
short printNumber(long, int);
short printNumber_L(long n, int base) {
  int t = 0;
  if (base == 0) {
    return oled_write(n);
  } else if (base == 10) {
    if (n < 0) {
      t = oled_write('-');
      n = -n;
      return printNumber(n, 10) + t;
    }
    return printNumber(n, 10);
  } else {
    return printNumber(n, base);
  }
}


x86 assembly (clang, -O0):
<printNumber_L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1155 <printNumber_L+0x35>
mov    -0x10(%rbp),%rax
movsbl %al,%edi
call   1030 <oled_write@plt>
mov    %ax,-0x2(%rbp)
jmp    11c4 <printNumber_L+0xa4>
cmpl   $0xa,-0x14(%rbp)
jne    11b4 <printNumber_L+0x94>
cmpq   $0x0,-0x10(%rbp)
jge    119d <printNumber_L+0x7d>
mov    $0x2d,%edi
call   1030 <oled_write@plt>
cwtl
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <printNumber@plt>
cwtl
add    -0x18(%rbp),%eax
mov    %ax,-0x2(%rbp)
jmp    11c4 <printNumber_L+0xa4>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <printNumber@plt>
mov    %ax,-0x2(%rbp)
jmp    11c4 <printNumber_L+0xa4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <printNumber@plt>
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printNumber_L>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0xa,%esi
je     113d <printNumber_L+0x1d>
test   %esi,%esi
jne    114c <printNumber_L+0x2c>
movsbl %bl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <oled_write@plt>
test   %rbx,%rbx
js     115a <printNumber_L+0x3a>
mov    %rbx,%rdi
mov    $0xa,%esi
jmp    114f <printNumber_L+0x2f>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printNumber@plt>
mov    $0x2d,%edi
call   1030 <oled_write@plt>
mov    %eax,%ebp
neg    %rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <printNumber@plt>
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @printNumber_L(i64 %0, i32 %1) {
%3 = alloca i16
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i64, i64* %4
%11 = trunc i64 %10 to i8
%12 = call signext i16 @oled_write(i8 signext %11)
store i16 %12, i16* %3
br label %37
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i64, i64* %4
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = call signext i16 @oled_write(i8 signext 45)
%21 = sext i16 %20 to i32
store i32 %21, i32* %6
%22 = load i64, i64* %4
%23 = sub nsw i64 0, %22
store i64 %23, i64* %4
%24 = load i64, i64* %4
%25 = call signext i16 @printNumber(i64 %24, i32 10)
%26 = sext i16 %25 to i32
%27 = load i32, i32* %6
%28 = add nsw i32 %26, %27
%29 = trunc i32 %28 to i16
store i16 %29, i16* %3
br label %37
30: ; preds = %16
%31 = load i64, i64* %4
%32 = call signext i16 @printNumber(i64 %31, i32 10)
store i16 %32, i16* %3
br label %37
33: ; preds = %13
%34 = load i64, i64* %4
%35 = load i32, i32* %5
%36 = call signext i16 @printNumber(i64 %34, i32 %35)
store i16 %36, i16* %3
br label %37
37: ; preds = %33, %30, %19, %9
%38 = load i16, i16* %3
ret i16 %38
}

LLVM IR (-O2):
define signext i16 @printNumber_L(i64 %0, i32 %1) {
switch i32 %1, label %15 [
i32 0, label %3
i32 10, label %6
]
3: ; preds = %2
%4 = trunc i64 %0 to i8
%5 = tail call signext i16 @oled_write(i8 signext %4)
br label %17
6: ; preds = %2
%7 = icmp slt i64 %0, 0
br i1 %7, label %8, label %13
8: ; preds = %6
%9 = tail call signext i16 @oled_write(i8 signext 45)
%10 = sub nsw i64 0, %0
%11 = tail call signext i16 @printNumber(i64 %10, i32 10)
%12 = add i16 %11, %9
br label %17
13: ; preds = %6
%14 = tail call signext i16 @printNumber(i64 %0, i32 10)
br label %17
15: ; preds = %2
%16 = tail call signext i16 @printNumber(i64 %0, i32 %1)
br label %17
17: ; preds = %15, %13, %8, %3
%18 = phi i16 [ %5, %3 ], [ %12, %8 ], [ %14, %13 ], [ %16, %15 ]
ret i16 %18
}