#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*/ lp();
int /*<<< orphan*/ sp();
void writecs(unsigned int cs) {
  unsigned char i = 0;
  int j = 0;
  cs &= 0xffff;
  for (j = 0x3; j; j /= 2) {
    for (i = 0xff; i; i /= 2) {
      if (cs & 0x8000)
        lp();
      else
        sp();
      cs *= 2;
    }
    lp();
  }
  lp();
}


x86 assembly (clang, -O0):
<writecs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x4(%rbp)
movl   $0x3,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11bb <writecs+0x9b>
movb   $0xff,-0x5(%rbp)
cmpb   $0x0,-0x5(%rbp)
je     11a1 <writecs+0x81>
mov    -0x4(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     117d <writecs+0x5d>
mov    $0x0,%al
call   1040 <lp@plt>
jmp    1184 <writecs+0x64>
mov    $0x0,%al
call   1030 <sp@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
movzbl -0x5(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0x5(%rbp)
jmp    1156 <writecs+0x36>
mov    $0x0,%al
call   1040 <lp@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1148 <writecs+0x28>
mov    $0x0,%al
call   1040 <lp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writecs>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
test   $0x8000,%edi
jne    1134 <writecs+0x14>
call   1030 <sp@plt>
jmp    1139 <writecs+0x19>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x4000,%ebx
jne    114a <writecs+0x2a>
call   1030 <sp@plt>
jmp    114f <writecs+0x2f>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x2000,%ebx
jne    1160 <writecs+0x40>
call   1030 <sp@plt>
jmp    1165 <writecs+0x45>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x1000,%ebx
jne    1176 <writecs+0x56>
call   1030 <sp@plt>
jmp    117b <writecs+0x5b>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x800,%ebx
jne    118c <writecs+0x6c>
call   1030 <sp@plt>
jmp    1191 <writecs+0x71>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x400,%ebx
jne    11a2 <writecs+0x82>
call   1030 <sp@plt>
jmp    11a7 <writecs+0x87>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x200,%ebx
jne    11b8 <writecs+0x98>
call   1030 <sp@plt>
jmp    11bd <writecs+0x9d>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x100,%ebx
jne    11ce <writecs+0xae>
call   1030 <sp@plt>
jmp    11d3 <writecs+0xb3>
call   1040 <lp@plt>
xor    %eax,%eax
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x80,%bl
jne    11e8 <writecs+0xc8>
call   1030 <sp@plt>
jmp    11ed <writecs+0xcd>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x40,%bl
jne    11fb <writecs+0xdb>
call   1030 <sp@plt>
jmp    1200 <writecs+0xe0>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x20,%bl
jne    120e <writecs+0xee>
call   1030 <sp@plt>
jmp    1213 <writecs+0xf3>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x10,%bl
jne    1221 <writecs+0x101>
call   1030 <sp@plt>
jmp    1226 <writecs+0x106>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    1234 <writecs+0x114>
call   1030 <sp@plt>
jmp    1239 <writecs+0x119>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x4,%bl
jne    1247 <writecs+0x127>
call   1030 <sp@plt>
jmp    124c <writecs+0x12c>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x2,%bl
jne    125a <writecs+0x13a>
call   1030 <sp@plt>
jmp    125f <writecs+0x13f>
call   1040 <lp@plt>
xor    %eax,%eax
test   $0x1,%bl
jne    126d <writecs+0x14d>
call   1030 <sp@plt>
jmp    1272 <writecs+0x152>
call   1040 <lp@plt>
xor    %eax,%eax
call   1040 <lp@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <lp@plt>

LLVM IR (-O0):
define void @writecs(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* %3
store i32 0, i32* %4
%5 = load i32, i32* %2
%6 = and i32 %5, 65535
store i32 %6, i32* %2
store i32 3, i32* %4
br label %7
7: ; preds = %32, %1
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %7
store i8 -1, i8* %3
br label %11
11: ; preds = %25, %10
%12 = load i8, i8* %3
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32, i32* %2
%16 = and i32 %15, 32768
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (...) @lp()
br label %22
20: ; preds = %14
%21 = call i32 (...) @sp()
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* %2
%24 = mul i32 %23, 2
store i32 %24, i32* %2
br label %25
25: ; preds = %22
%26 = load i8, i8* %3
%27 = zext i8 %26 to i32
%28 = sdiv i32 %27, 2
%29 = trunc i32 %28 to i8
store i8 %29, i8* %3
br label %11
30: ; preds = %11
%31 = call i32 (...) @lp()
br label %32
32: ; preds = %30
%33 = load i32, i32* %4
%34 = sdiv i32 %33, 2
store i32 %34, i32* %4
br label %7
35: ; preds = %7
%36 = call i32 (...) @lp()
ret void
}

LLVM IR (-O2):
define void @writecs(i32 %0) {
%2 = and i32 %0, 32768
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 (...) @lp()
br label %8
6: ; preds = %1
%7 = tail call i32 (...) @sp()
br label %8
8: ; preds = %6, %4
%9 = and i32 %0, 16384
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 (...) @lp()
br label %15
13: ; preds = %8
%14 = tail call i32 (...) @sp()
br label %15
15: ; preds = %13, %11
%16 = and i32 %0, 8192
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 (...) @lp()
br label %22
20: ; preds = %15
%21 = tail call i32 (...) @sp()
br label %22
22: ; preds = %20, %18
%23 = and i32 %0, 4096
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 (...) @lp()
br label %29
27: ; preds = %22
%28 = tail call i32 (...) @sp()
br label %29
29: ; preds = %27, %25
%30 = and i32 %0, 2048
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 (...) @lp()
br label %36
34: ; preds = %29
%35 = tail call i32 (...) @sp()
br label %36
36: ; preds = %34, %32
%37 = and i32 %0, 1024
%38 = icmp eq i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = tail call i32 (...) @lp()
br label %43
41: ; preds = %36
%42 = tail call i32 (...) @sp()
br label %43
43: ; preds = %41, %39
%44 = and i32 %0, 512
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 (...) @lp()
br label %50
48: ; preds = %43
%49 = tail call i32 (...) @sp()
br label %50
50: ; preds = %48, %46
%51 = and i32 %0, 256
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 (...) @lp()
br label %57
55: ; preds = %50
%56 = tail call i32 (...) @sp()
br label %57
57: ; preds = %55, %53
%58 = tail call i32 (...) @lp()
%59 = and i32 %0, 128
%60 = icmp eq i32 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %57
%62 = tail call i32 (...) @lp()
br label %65
63: ; preds = %57
%64 = tail call i32 (...) @sp()
br label %65
65: ; preds = %63, %61
%66 = and i32 %0, 64
%67 = icmp eq i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = tail call i32 (...) @lp()
br label %72
70: ; preds = %65
%71 = tail call i32 (...) @sp()
br label %72
72: ; preds = %70, %68
%73 = and i32 %0, 32
%74 = icmp eq i32 %73, 0
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = tail call i32 (...) @lp()
br label %79
77: ; preds = %72
%78 = tail call i32 (...) @sp()
br label %79
79: ; preds = %77, %75
%80 = and i32 %0, 16
%81 = icmp eq i32 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %79
%83 = tail call i32 (...) @lp()
br label %86
84: ; preds = %79
%85 = tail call i32 (...) @sp()
br label %86
86: ; preds = %84, %82
%87 = and i32 %0, 8
%88 = icmp eq i32 %87, 0
br i1 %88, label %91, label %89
89: ; preds = %86
%90 = tail call i32 (...) @lp()
br label %93
91: ; preds = %86
%92 = tail call i32 (...) @sp()
br label %93
93: ; preds = %91, %89
%94 = and i32 %0, 4
%95 = icmp eq i32 %94, 0
br i1 %95, label %98, label %96
96: ; preds = %93
%97 = tail call i32 (...) @lp()
br label %100
98: ; preds = %93
%99 = tail call i32 (...) @sp()
br label %100
100: ; preds = %98, %96
%101 = and i32 %0, 2
%102 = icmp eq i32 %101, 0
br i1 %102, label %105, label %103
103: ; preds = %100
%104 = tail call i32 (...) @lp()
br label %107
105: ; preds = %100
%106 = tail call i32 (...) @sp()
br label %107
107: ; preds = %105, %103
%108 = and i32 %0, 1
%109 = icmp eq i32 %108, 0
br i1 %109, label %112, label %110
110: ; preds = %107
%111 = tail call i32 (...) @lp()
br label %114
112: ; preds = %107
%113 = tail call i32 (...) @sp()
br label %114
114: ; preds = %112, %110
%115 = tail call i32 (...) @lp()
%116 = tail call i32 (...) @lp()
ret void
}