#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();
unsigned int mz_rawout(unsigned char b) {
  unsigned int cs = 0;
  unsigned char i = 0;
  for (i = 0xff; i; i /= 2) {
    if (b & 0x80) {
      lp();
      cs++;
    } else
      sp();
    b *= 2;
  }
  lp();
  return cs;
}


x86 assembly (clang, -O0):
<mz_rawout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movb   $0xff,-0x9(%rbp)
cmpb   $0x0,-0x9(%rbp)
je     1193 <mz_rawout+0x73>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     116e <mz_rawout+0x4e>
mov    $0x0,%al
call   1040 <lp@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1175 <mz_rawout+0x55>
mov    $0x0,%al
call   1030 <sp@plt>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
movzbl -0x9(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0x9(%rbp)
jmp    113d <mz_rawout+0x1d>
mov    $0x0,%al
call   1040 <lp@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mz_rawout>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %bpl,%bpl
js     1135 <mz_rawout+0x15>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <sp@plt>
jmp    1141 <mz_rawout+0x21>
xor    %eax,%eax
call   1040 <lp@plt>
mov    $0x1,%ebx
xor    %eax,%eax
test   $0x40,%bpl
jne    1150 <mz_rawout+0x30>
call   1030 <sp@plt>
jmp    1158 <mz_rawout+0x38>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x20,%bpl
jne    1167 <mz_rawout+0x47>
call   1030 <sp@plt>
jmp    116f <mz_rawout+0x4f>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x10,%bpl
jne    117e <mz_rawout+0x5e>
call   1030 <sp@plt>
jmp    1186 <mz_rawout+0x66>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x8,%bpl
jne    1195 <mz_rawout+0x75>
call   1030 <sp@plt>
jmp    119d <mz_rawout+0x7d>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x4,%bpl
jne    11ac <mz_rawout+0x8c>
call   1030 <sp@plt>
jmp    11b4 <mz_rawout+0x94>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x2,%bpl
jne    11c3 <mz_rawout+0xa3>
call   1030 <sp@plt>
jmp    11cb <mz_rawout+0xab>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
test   $0x1,%bpl
jne    11da <mz_rawout+0xba>
call   1030 <sp@plt>
jmp    11e2 <mz_rawout+0xc2>
call   1040 <lp@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <lp@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @mz_rawout(i8 zeroext %0) {
%2 = icmp sgt i8 %0, -1
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 (...) @lp()
br label %7
5: ; preds = %1
%6 = tail call i32 (...) @sp()
br label %7
7: ; preds = %5, %3
%8 = phi i32 [ 1, %3 ], [ 0, %5 ]
%9 = and i8 %0, 64
%10 = icmp eq i8 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 (...) @lp()
%13 = add nuw nsw i32 %8, 1
br label %16
14: ; preds = %7
%15 = tail call i32 (...) @sp()
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %13, %11 ], [ %8, %14 ]
%18 = and i8 %0, 32
%19 = icmp eq i8 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 (...) @lp()
%22 = add nuw nsw i32 %17, 1
br label %25
23: ; preds = %16
%24 = tail call i32 (...) @sp()
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ %22, %20 ], [ %17, %23 ]
%27 = and i8 %0, 16
%28 = icmp eq i8 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = tail call i32 (...) @lp()
%31 = add nuw nsw i32 %26, 1
br label %34
32: ; preds = %25
%33 = tail call i32 (...) @sp()
br label %34
34: ; preds = %32, %29
%35 = phi i32 [ %31, %29 ], [ %26, %32 ]
%36 = and i8 %0, 8
%37 = icmp eq i8 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = tail call i32 (...) @lp()
%40 = add nuw nsw i32 %35, 1
br label %43
41: ; preds = %34
%42 = tail call i32 (...) @sp()
br label %43
43: ; preds = %41, %38
%44 = phi i32 [ %40, %38 ], [ %35, %41 ]
%45 = and i8 %0, 4
%46 = icmp eq i8 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %43
%48 = tail call i32 (...) @lp()
%49 = add nuw nsw i32 %44, 1
br label %52
50: ; preds = %43
%51 = tail call i32 (...) @sp()
br label %52
52: ; preds = %50, %47
%53 = phi i32 [ %49, %47 ], [ %44, %50 ]
%54 = and i8 %0, 2
%55 = icmp eq i8 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %52
%57 = tail call i32 (...) @lp()
%58 = add nuw nsw i32 %53, 1
br label %61
59: ; preds = %52
%60 = tail call i32 (...) @sp()
br label %61
61: ; preds = %59, %56
%62 = phi i32 [ %58, %56 ], [ %53, %59 ]
%63 = and i8 %0, 1
%64 = icmp eq i8 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %61
%66 = tail call i32 (...) @lp()
%67 = add nuw nsw i32 %62, 1
br label %70
68: ; preds = %61
%69 = tail call i32 (...) @sp()
br label %70
70: ; preds = %68, %65
%71 = phi i32 [ %67, %65 ], [ %62, %68 ]
%72 = tail call i32 (...) @lp()
ret i32 %71
}