#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*/ lcd_putstr(char *);
void lcd_disp_2(unsigned int x) {
  char s[3];
  unsigned int y;
  if (x < 100) {
    y = x / 10;
    s[0] = (char)(y + 0x30);
    x -= (y * 10);
    s[1] = (char)(x + 0x30);
    s[2] = '\0';
    if (s[0] == '0') {
      s[0] = ' ';
    }
    lcd_putstr(s);
  } else {
    lcd_putstr("XX");
  }
}


x86 assembly (clang, -O0):
<lcd_disp_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jae    1175 <lcd_disp_2+0x65>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x7(%rbp)
imul   $0xa,-0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x6(%rbp)
movb   $0x0,-0x5(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x30,%eax
jne    1167 <lcd_disp_2+0x57>
movb   $0x20,-0x7(%rbp)
lea    -0x7(%rbp),%rdi
call   1030 <lcd_putstr@plt>
jmp    1181 <lcd_disp_2+0x71>
lea    0xe84(%rip),%rdi
call   1030 <lcd_putstr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_disp_2>:
cmp    $0x63,%edi
ja     1154 <lcd_disp_2+0x44>
push   %rax
movzbl %dil,%eax
imul   $0xcd,%eax,%ecx
shr    $0xb,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x5(%rsp)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edi
add    $0x30,%dil
mov    %dil,0x6(%rsp)
movb   $0x0,0x7(%rsp)
cmp    $0x9,%al
ja     1148 <lcd_disp_2+0x38>
movb   $0x20,0x5(%rsp)
lea    0x5(%rsp),%rdi
call   1030 <lcd_putstr@plt>
pop    %rax
ret
lea    0xea5(%rip),%rdi
jmp    1030 <lcd_putstr@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"XX\00"
define void @lcd_disp_2(i32 %0) {
%2 = alloca i32
%3 = alloca [3 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ult i32 %5, 100
br i1 %6, label %7, label %32
7: ; preds = %1
%8 = load i32, i32* %2
%9 = udiv i32 %8, 10
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = add i32 %10, 48
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 %12, i8* %13
%14 = load i32, i32* %4
%15 = mul i32 %14, 10
%16 = load i32, i32* %2
%17 = sub i32 %16, %15
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = add i32 %18, 48
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 %20, i8* %21
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %22
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 48
br i1 %26, label %27, label %29
27: ; preds = %7
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 32, i8* %28
br label %29
29: ; preds = %27, %7
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%31 = call i32 @lcd_putstr(i8* %30)
br label %34
32: ; preds = %1
%33 = call i32 @lcd_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"XX\00"
define void @lcd_disp_2(i32 %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = icmp ult i32 %0, 100
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = trunc i32 %0 to i8
%7 = udiv i8 %6, 10
%8 = zext i8 %7 to i32
%9 = add nuw nsw i8 %7, 48
store i8 %9, i8* %3
%10 = mul nsw i32 %8, -10
%11 = add nsw i32 %10, %0
%12 = trunc i32 %11 to i8
%13 = add i8 %12, 48
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 %13, i8* %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %15
%16 = icmp ult i8 %6, 10
br i1 %16, label %17, label %18
17: ; preds = %5
store i8 32, i8* %3
br label %18
18: ; preds = %17, %5
%19 = call i32 @lcd_putstr(i8* %3)
br label %22
20: ; preds = %1
%21 = tail call i32 @lcd_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
ret void
}