#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*/ strcat(char *, char *);
const char *caps(int bits) {
  static char res[4 * 3 + 1];
  res[0] = '\0';
  strcat(res, "  ");
  strcat(res, (bits & 8 ? "X" : " "));
  strcat(res, "  ");
  strcat(res, (bits & 4 ? "X" : " "));
  strcat(res, "  ");
  strcat(res, (bits & 2 ? "X" : " "));
  strcat(res, "  ");
  strcat(res, (bits & 1 ? "X" : " "));
  return res;
}


x86 assembly (clang, -O0):
<caps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f07(%rip)
lea    0x2f00(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x4(%rbp),%ecx
and    $0x8,%ecx
lea    0xebf(%rip),%rsi
lea    0xeba(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0x2ed2(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2ec6(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x4(%rbp),%ecx
and    $0x4,%ecx
lea    0xe85(%rip),%rsi
lea    0xe80(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0x2e98(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2e8c(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x4(%rbp),%ecx
and    $0x2,%ecx
lea    0xe4b(%rip),%rsi
lea    0xe46(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0x2e5e(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2e52(%rip),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x4(%rbp),%ecx
and    $0x1,%ecx
lea    0xe11(%rip),%rsi
lea    0xe0c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0x2e24(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2e18(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<caps>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebp
movb   $0x0,0x2f08(%rip)
lea    0x2f01(%rip),%r15
lea    0xed1(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
test   $0x8,%bpl
lea    0xebc(%rip),%r12
lea    0xeb7(%rip),%rbx
mov    %rbx,%rsi
cmove  %r12,%rsi
mov    %r15,%rdi
call   1030 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
test   $0x4,%bpl
mov    %rbx,%rsi
cmove  %r12,%rsi
mov    %r15,%rdi
call   1030 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
test   $0x2,%bpl
mov    %rbx,%rsi
cmove  %r12,%rsi
mov    %r15,%rdi
call   1030 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
test   $0x1,%bpl
cmove  %r12,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcat@plt>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@caps.res = internal global [13 x i8] zeroinitializer
@.str = [3 x i8] c" \00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c" \00"
define i8* @caps(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0)
%3 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = and i32 %4, 8
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %8)
%10 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = and i32 %11, 4
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %15)
%17 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = and i32 %18, 2
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%23 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %22)
%24 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = and i32 %25, 1
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%30 = call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %29)
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0)
}

LLVM IR (-O2):
@caps.res = internal global [13 x i8] zeroinitializer
@.str = [3 x i8] c" \00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c" \00"
define i8* @caps(i32 %0) {
store i8 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0)
%2 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = and i32 %0, 8
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%6 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %5)
%7 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = and i32 %0, 4
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %10)
%12 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = and i32 %0, 2
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%16 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %15)
%17 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = and i32 %0, 1
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%21 = tail call i32 @strcat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0), i8* %20)
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @caps.res, i64 0, i64 0)
}