const char *lwo_lwIDToStr(unsigned int lwID) {
  static char lwIDStr[5];
  if (!lwID) {
    return "n/a";
  }
  lwIDStr[0] = (char)((lwID) >> 24);
  lwIDStr[1] = (char)((lwID) >> 16);
  lwIDStr[2] = (char)((lwID) >> 8);
  lwIDStr[3] = (char)((lwID));
  lwIDStr[4] = '\0';
  return lwIDStr;
}


x86 assembly (clang, -O0):
<lwo_lwIDToStr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1121 <lwo_lwIDToStr+0x21>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1160 <lwo_lwIDToStr+0x60>
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
mov    %al,0x2ef4(%rip)
mov    -0xc(%rbp),%eax
shr    $0x10,%eax
mov    %al,0x2ee9(%rip)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %al,0x2ede(%rip)
mov    -0xc(%rbp),%eax
mov    %al,0x2ed6(%rip)
movb   $0x0,0x2ed0(%rip)
lea    0x2ec5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lwo_lwIDToStr>:
test   %edi,%edi
je     1137 <lwo_lwIDToStr+0x37>
mov    %edi,%ecx
mov    %edi,%eax
shr    $0x18,%eax
mov    %al,0x2f10(%rip)
lea    0x2f09(%rip),%rax
mov    %edi,%edx
shr    $0x10,%edx
mov    %dl,0x2eff(%rip)
mov    %ch,0x2efa(%rip)
mov    %cl,0x2ef5(%rip)
movb   $0x0,0x2eef(%rip)
ret
lea    0xec2(%rip),%rax
ret

LLVM IR (-O0):
@lwo_lwIDToStr.lwIDStr = internal global [5 x i8] zeroinitializer
@.str = [4 x i8] c"n/a\00"
define i8* @lwo_lwIDToStr(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
7: ; preds = %1
%8 = load i32, i32* %3
%9 = lshr i32 %8, 24
%10 = trunc i32 %9 to i8
store i8 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 0)
%11 = load i32, i32* %3
%12 = lshr i32 %11, 16
%13 = trunc i32 %12 to i8
store i8 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 1)
%14 = load i32, i32* %3
%15 = lshr i32 %14, 8
%16 = trunc i32 %15 to i8
store i8 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 2)
%17 = load i32, i32* %3
%18 = trunc i32 %17 to i8
store i8 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 3)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 4)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %7, %6
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@lwo_lwIDToStr.lwIDStr = internal global [5 x i8] zeroinitializer
@.str = [4 x i8] c"n/a\00"
define i8* @lwo_lwIDToStr(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = lshr i32 %0, 24
%5 = trunc i32 %4 to i8
store i8 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 0)
%6 = lshr i32 %0, 16
%7 = trunc i32 %6 to i8
store i8 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 1)
%8 = lshr i32 %0, 8
%9 = trunc i32 %8 to i8
store i8 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 2)
%10 = trunc i32 %0 to i8
store i8 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 3)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 4)
br label %11
11: ; preds = %1, %3
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @lwo_lwIDToStr.lwIDStr, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %12
}