#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 */
long updc32(int, long);
int /*<<< orphan*/ xmchout(char);
int /*<<< orphan*/ zsendline(int);
void zsbh32(char *hdr, int type) {
  static int n;
  static long crc;
  xmchout('C');
  zsendline(type);
  crc = 0xFFFFFFFFL;
  crc = updc32(type, crc);
  for (n = 4; --n >= 0; ++hdr) {
    crc = updc32((0377 & *hdr), crc);
    zsendline(*hdr);
  }
  crc = ~crc;
  for (n = 4; --n >= 0;) {
    zsendline((int)crc);
    crc >>= 8;
  }
}


x86 assembly (clang, -O0):
<zsbh32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x43,%edi
call   1030 <xmchout@plt>
mov    -0xc(%rbp),%edi
call   1050 <zsendline@plt>
mov    $0xffffffff,%eax
mov    %rax,0x2eeb(%rip)
mov    -0xc(%rbp),%edi
mov    0x2ee1(%rip),%rsi
call   1040 <updc32@plt>
mov    %rax,0x2ed5(%rip)
movl   $0x4,0x2ec3(%rip)
mov    0x2ebd(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2eb4(%rip)
cmp    $0x0,%eax
jl     11d2 <zsbh32+0xa2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
and    $0xff,%edi
mov    0x2e9f(%rip),%rsi
call   1040 <updc32@plt>
mov    %rax,0x2e93(%rip)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <zsendline@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117d <zsbh32+0x4d>
mov    0x2e6f(%rip),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,0x2e64(%rip)
movl   $0x4,0x2e52(%rip)
mov    0x2e4c(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e43(%rip)
cmp    $0x0,%eax
jl     122b <zsbh32+0xfb>
mov    0x2e3b(%rip),%rax
mov    %eax,%edi
call   1050 <zsendline@plt>
mov    0x2e2d(%rip),%rax
sar    $0x8,%rax
mov    %rax,0x2e22(%rip)
jmp    11ee <zsbh32+0xbe>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zsbh32>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x43,%edi
call   1030 <xmchout@plt>
mov    %ebp,%edi
call   1050 <zsendline@plt>
mov    $0xffffffff,%eax
mov    %rax,0x2ef3(%rip)
mov    $0xffffffff,%esi
mov    %ebp,%edi
call   1040 <updc32@plt>
mov    %rax,0x2ee0(%rip)
movl   $0x3,0x2ece(%rip)
movzbl (%rbx),%edi
mov    %rax,%rsi
call   1040 <updc32@plt>
mov    %rax,0x2ec4(%rip)
movsbl (%rbx),%edi
call   1050 <zsendline@plt>
mov    0x2eae(%rip),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x2ea5(%rip)
test   %eax,%eax
jle    11e5 <zsbh32+0xb5>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e91(%rip),%rsi
movzbl (%rbx),%edi
call   1040 <updc32@plt>
mov    %rax,0x2e82(%rip)
movsbl (%rbx),%edi
call   1050 <zsendline@plt>
mov    0x2e6c(%rip),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x2e63(%rip)
add    $0x1,%rbx
test   %eax,%eax
jg     11b0 <zsbh32+0x80>
mov    0x2e5c(%rip),%rdi
not    %rdi
mov    %rdi,0x2e52(%rip)
movl   $0x3,0x2e40(%rip)
call   1050 <zsendline@plt>
mov    0x2e3c(%rip),%rdi
sar    $0x8,%rdi
mov    %rdi,0x2e31(%rip)
mov    0x2e23(%rip),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x2e1a(%rip)
test   %eax,%eax
jg     1200 <zsbh32+0xd0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@zsbh32.n = internal global i32 0
@zsbh32.crc = internal global i64 0
define void @zsbh32(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = call i32 @xmchout(i8 signext 67)
%6 = load i32, i32* %4
%7 = call i32 @zsendline(i32 %6)
store i64 4294967295, i64* @zsbh32.crc
%8 = load i32, i32* %4
%9 = load i64, i64* @zsbh32.crc
%10 = call i64 @updc32(i32 %8, i64 %9)
store i64 %10, i64* @zsbh32.crc
store i32 4, i32* @zsbh32.n
br label %11
11: ; preds = %26, %2
%12 = load i32, i32* @zsbh32.n
%13 = add nsw i32 %12, -1
store i32 %13, i32* @zsbh32.n
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = and i32 255, %18
%20 = load i64, i64* @zsbh32.crc
%21 = call i64 @updc32(i32 %19, i64 %20)
store i64 %21, i64* @zsbh32.crc
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 @zsendline(i32 %24)
br label %26
26: ; preds = %15
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
br label %11
29: ; preds = %11
%30 = load i64, i64* @zsbh32.crc
%31 = xor i64 %30, -1
store i64 %31, i64* @zsbh32.crc
store i32 4, i32* @zsbh32.n
br label %32
32: ; preds = %36, %29
%33 = load i32, i32* @zsbh32.n
%34 = add nsw i32 %33, -1
store i32 %34, i32* @zsbh32.n
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i64, i64* @zsbh32.crc
%38 = trunc i64 %37 to i32
%39 = call i32 @zsendline(i32 %38)
%40 = load i64, i64* @zsbh32.crc
%41 = ashr i64 %40, 8
store i64 %41, i64* @zsbh32.crc
br label %32
42: ; preds = %32
ret void
}

LLVM IR (-O2):
@zsbh32.n = internal unnamed_addr global i32 0
@zsbh32.crc = internal unnamed_addr global i64 0
define void @zsbh32(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @xmchout(i8 signext 67)
%4 = tail call i32 @zsendline(i32 %1)
store i64 4294967295, i64* @zsbh32.crc
%5 = tail call i64 @updc32(i32 %1, i64 4294967295)
store i64 %5, i64* @zsbh32.crc
store i32 3, i32* @zsbh32.n
%6 = load i8, i8* %0
%7 = zext i8 %6 to i32
%8 = tail call i64 @updc32(i32 %7, i64 %5)
store i64 %8, i64* @zsbh32.crc
%9 = load i8, i8* %0
%10 = sext i8 %9 to i32
%11 = tail call i32 @zsendline(i32 %10)
%12 = load i32, i32* @zsbh32.n
%13 = add nsw i32 %12, -1
store i32 %13, i32* @zsbh32.n
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %28
15: ; preds = %2, %15
%16 = phi i8* [ %17, %15 ], [ %0, %2 ]
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i64, i64* @zsbh32.crc
%19 = load i8, i8* %17
%20 = zext i8 %19 to i32
%21 = tail call i64 @updc32(i32 %20, i64 %18)
store i64 %21, i64* @zsbh32.crc
%22 = load i8, i8* %17
%23 = sext i8 %22 to i32
%24 = tail call i32 @zsendline(i32 %23)
%25 = load i32, i32* @zsbh32.n
%26 = add nsw i32 %25, -1
store i32 %26, i32* @zsbh32.n
%27 = icmp sgt i32 %25, 0
br i1 %27, label %15, label %28
28: ; preds = %15, %2
%29 = load i64, i64* @zsbh32.crc
%30 = xor i64 %29, -1
store i64 %30, i64* @zsbh32.crc
store i32 3, i32* @zsbh32.n
br label %31
31: ; preds = %28, %31
%32 = phi i64 [ %30, %28 ], [ %36, %31 ]
%33 = trunc i64 %32 to i32
%34 = tail call i32 @zsendline(i32 %33)
%35 = load i64, i64* @zsbh32.crc
%36 = ashr i64 %35, 8
store i64 %36, i64* @zsbh32.crc
%37 = load i32, i32* @zsbh32.n
%38 = add nsw i32 %37, -1
store i32 %38, i32* @zsbh32.n
%39 = icmp sgt i32 %37, 0
br i1 %39, label %31, label %40
40: ; preds = %31
ret void
}