#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 */
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void psw(uint16_t sw) {
  printf("SW:  C3 TopC2C1C0\n");
  printf("SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\n",
         sw & (1 << 15) ? 'B' : 'b', !!(sw & (1 << 14)), (sw & 0x3800) >> 11,
         !!(sw & (1 << 10)), !!(sw & (1 << 9)), !!(sw & (1 << 8)),
         (sw & (1 << 7)) ? 'S' : 's', (sw & (1 << 6)) ? 'F' : 'f',
         (sw & (1 << 5)) ? 'P' : 'p', (sw & (1 << 4)) ? 'U' : 'u',
         (sw & (1 << 3)) ? 'O' : 'o', (sw & (1 << 2)) ? 'Z' : 'z',
         (sw & (1 << 1)) ? 'D' : 'd', (sw & (1 << 0)) ? 'I' : 'i');
}


x86 assembly (clang, -O0):
<psw>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edi,-0x2c(%rbp)
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%ecx
and    $0x8000,%ecx
mov    $0x62,%esi
mov    $0x42,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0x2c(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
mov    -0x2c(%rbp),%ecx
and    $0x3800,%ecx
sar    $0xb,%ecx
mov    -0x2c(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%r8d
mov    -0x2c(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%r9d
mov    -0x2c(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
and    $0x80,%edi
mov    $0x73,%r13d
mov    $0x53,%eax
cmp    $0x0,%edi
cmovne %eax,%r13d
mov    -0x2c(%rbp),%edi
and    $0x40,%edi
mov    $0x66,%r12d
mov    $0x46,%eax
cmp    $0x0,%edi
cmovne %eax,%r12d
mov    -0x2c(%rbp),%edi
and    $0x20,%edi
mov    $0x70,%r15d
mov    $0x50,%eax
cmp    $0x0,%edi
cmovne %eax,%r15d
mov    -0x2c(%rbp),%edi
and    $0x10,%edi
mov    $0x75,%r14d
mov    $0x55,%eax
cmp    $0x0,%edi
cmovne %eax,%r14d
mov    -0x2c(%rbp),%edi
and    $0x8,%edi
mov    $0x6f,%ebx
mov    $0x4f,%eax
cmp    $0x0,%edi
cmovne %eax,%ebx
mov    -0x2c(%rbp),%edi
and    $0x4,%edi
mov    $0x7a,%r11d
mov    $0x5a,%eax
cmp    $0x0,%edi
cmovne %eax,%r11d
mov    -0x2c(%rbp),%edi
and    $0x2,%edi
mov    $0x64,%r10d
mov    $0x44,%eax
cmp    $0x0,%edi
cmovne %eax,%r10d
mov    -0x2c(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    $0x69,%edi
mov    $0x49,%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
cmp    $0x0,%eax
mov    -0x38(%rbp),%eax
cmovne %eax,%edi
mov    -0x34(%rbp),%eax
mov    %edi,-0x30(%rbp)
lea    0xd83(%rip),%rdi
mov    %eax,(%rsp)
mov    -0x30(%rbp),%eax
mov    %r13d,0x8(%rsp)
mov    %r12d,0x10(%rsp)
mov    %r15d,0x18(%rsp)
mov    %r14d,0x20(%rsp)
mov    %ebx,0x28(%rsp)
mov    %r11d,0x30(%rsp)
mov    %r10d,0x38(%rsp)
mov    %eax,0x40(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<psw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
movd   %r14d,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xeb4(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xeb8(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%ebx
mov    %ebx,%edi
and    $0x2,%dil
shr    %dil
mov    %ebx,%r12d
and    $0x4,%r12b
shr    $0x2,%r12b
mov    %ebx,%r13d
and    $0x8,%r13b
shr    $0x3,%r13b
mov    %ebx,%eax
and    $0x10,%al
shr    $0x4,%al
mov    %ebx,%r10d
shr    $0x6,%r10b
mov    %ebx,%ecx
shr    $0x7,%cl
movzbl %cl,%esi
shl    $0x5,%esi
or     $0x42,%esi
mov    %r14d,%edx
shr    $0xe,%edx
and    $0x1,%edx
mov    %r14d,%ecx
shr    $0xb,%ecx
and    $0x7,%ecx
mov    %r14d,%r8d
shr    $0xa,%r8d
and    $0x1,%r8d
mov    %r14d,%r9d
shr    $0x9,%r9d
and    $0x1,%r9d
mov    %r14d,%ebp
shr    $0x8,%ebp
and    $0x1,%ebp
mov    %rbp,(%rsp)
movzbl %r10b,%r11d
shl    $0x5,%r11d
or     $0x53,%r11d
mov    %ebx,%r15d
and    $0x20,%r15d
or     $0x46,%r15d
and    $0x20,%r14d
xor    $0x70,%r14d
movzbl %al,%r10d
shl    $0x5,%r10d
or     $0x55,%r10d
movzbl %r13b,%r13d
shl    $0x5,%r13d
or     $0x4f,%r13d
movzbl %r12b,%r12d
shl    $0x5,%r12d
or     $0x5a,%r12d
movzbl %dil,%ebp
shl    $0x5,%ebp
or     $0x44,%ebp
and    $0x1,%ebx
shl    $0x5,%ebx
or     $0x49,%ebx
sub    $0x8,%rsp
lea    0xddf(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %rbp
push   %r12
push   %r13
push   %r10
push   %r14
push   %r15
push   %r11
push   0x48(%rsp)
call   1040 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"SW: C3 TopC2C1C0\0A\00"
@.str.1 = [48 x i8] c"SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\0A\00"
define void @psw(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = and i32 %4, 32768
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 66, i32 98
%9 = load i32, i32* %2
%10 = and i32 %9, 16384
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
%13 = xor i1 %12, true
%14 = zext i1 %13 to i32
%15 = load i32, i32* %2
%16 = and i32 %15, 14336
%17 = ashr i32 %16, 11
%18 = load i32, i32* %2
%19 = and i32 %18, 1024
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
%24 = load i32, i32* %2
%25 = and i32 %24, 512
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = xor i1 %27, true
%29 = zext i1 %28 to i32
%30 = load i32, i32* %2
%31 = and i32 %30, 256
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
%34 = xor i1 %33, true
%35 = zext i1 %34 to i32
%36 = load i32, i32* %2
%37 = and i32 %36, 128
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 83, i32 115
%41 = load i32, i32* %2
%42 = and i32 %41, 64
%43 = icmp ne i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 70, i32 102
%46 = load i32, i32* %2
%47 = and i32 %46, 32
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 80, i32 112
%51 = load i32, i32* %2
%52 = and i32 %51, 16
%53 = icmp ne i32 %52, 0
%54 = zext i1 %53 to i64
%55 = select i1 %53, i32 85, i32 117
%56 = load i32, i32* %2
%57 = and i32 %56, 8
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i64
%60 = select i1 %58, i32 79, i32 111
%61 = load i32, i32* %2
%62 = and i32 %61, 4
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, i32 90, i32 122
%66 = load i32, i32* %2
%67 = and i32 %66, 2
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i32 68, i32 100
%71 = load i32, i32* %2
%72 = and i32 %71, 1
%73 = icmp ne i32 %72, 0
%74 = zext i1 %73 to i64
%75 = select i1 %73, i32 73, i32 105
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %14, i32 %17, i32 %23, i32 %29, i32 %35, i32 %40, i32 %45, i32 %50, i32 %55, i32 %60, i32 %65, i32 %70, i32 %75)
ret void
}

LLVM IR (-O2):
@.str.1 = [48 x i8] c"SW: %c %d %3d %d %d %d %c %c %c %c %c %c %c %c\0A\00"
@str = [18 x i8] c"SW: C3 TopC2C1C0\00"
define void @psw(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%3 = insertelement <8 x i32> poison, i32 %0, i64 0
%4 = shufflevector <8 x i32> %3, <8 x i32> poison, <8 x i32> zeroinitializer
%5 = and <8 x i32> %4, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 64, i32 128, i32 32768>
%6 = icmp eq <8 x i32> %5, zeroinitializer
%7 = extractelement <8 x i1> %6, i64 7
%8 = select i1 %7, i32 98, i32 66
%9 = lshr i32 %0, 14
%10 = and i32 %9, 1
%11 = lshr i32 %0, 11
%12 = and i32 %11, 7
%13 = lshr i32 %0, 10
%14 = and i32 %13, 1
%15 = lshr i32 %0, 9
%16 = and i32 %15, 1
%17 = lshr i32 %0, 8
%18 = and i32 %17, 1
%19 = extractelement <8 x i1> %6, i64 6
%20 = select i1 %19, i32 115, i32 83
%21 = extractelement <8 x i1> %6, i64 5
%22 = select i1 %21, i32 102, i32 70
%23 = and i32 %0, 32
%24 = xor i32 %23, 112
%25 = extractelement <8 x i1> %6, i64 4
%26 = select i1 %25, i32 117, i32 85
%27 = extractelement <8 x i1> %6, i64 3
%28 = select i1 %27, i32 111, i32 79
%29 = extractelement <8 x i1> %6, i64 2
%30 = select i1 %29, i32 122, i32 90
%31 = extractelement <8 x i1> %6, i64 1
%32 = select i1 %31, i32 100, i32 68
%33 = extractelement <8 x i1> %6, i64 0
%34 = select i1 %33, i32 105, i32 73
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22, i32 %24, i32 %26, i32 %28, i32 %30, i32 %32, i32 %34)
ret void
}