#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*/ xsendline(char);
int /*<<< orphan*/ zsendline(int);
void zsbh32(char *hdr, int type) {
  register int n;
  register long crc;
  xsendline('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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x43,%edi
call   1030 <xsendline@plt>
mov    -0xc(%rbp),%edi
call   1050 <zsendline@plt>
mov    $0xffffffff,%eax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <UPDC32@plt>
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jl     11ba <zsbh32+0x8a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
and    $0xff,%edi
mov    -0x18(%rbp),%rsi
call   1040 <UPDC32@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <zsendline@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1171 <zsbh32+0x41>
mov    -0x18(%rbp),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jl     11fb <zsbh32+0xcb>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1050 <zsendline@plt>
mov    -0x18(%rbp),%rax
sar    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    11cd <zsbh32+0x9d>
add    $0x20,%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 <xsendline@plt>
mov    %ebp,%edi
call   1050 <zsendline@plt>
mov    $0xffffffff,%esi
mov    %ebp,%edi
call   1040 <UPDC32@plt>
movzbl (%rbx),%edi
mov    %rax,%rsi
call   1040 <UPDC32@plt>
mov    %rax,%rbp
movsbl (%rbx),%edi
call   1050 <zsendline@plt>
movzbl 0x1(%rbx),%edi
mov    %rbp,%rsi
call   1040 <UPDC32@plt>
mov    %rax,%rbp
movsbl 0x1(%rbx),%edi
call   1050 <zsendline@plt>
movzbl 0x2(%rbx),%edi
mov    %rbp,%rsi
call   1040 <UPDC32@plt>
mov    %rax,%rbp
movsbl 0x2(%rbx),%edi
call   1050 <zsendline@plt>
movzbl 0x3(%rbx),%edi
mov    %rbp,%rsi
call   1040 <UPDC32@plt>
mov    %rax,%rbp
movsbl 0x3(%rbx),%edi
call   1050 <zsendline@plt>
not    %rbp
mov    %ebp,%edi
call   1050 <zsendline@plt>
mov    %rbp,%rdi
shr    $0x8,%rdi
call   1050 <zsendline@plt>
mov    %rbp,%rdi
shr    $0x10,%rdi
call   1050 <zsendline@plt>
shr    $0x18,%rbp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <zsendline@plt>

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

LLVM IR (-O2):
define void @zsbh32(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @xsendline(i8 signext 67)
%4 = tail call i32 @zsendline(i32 %1)
%5 = tail call i64 @UPDC32(i32 %1, i64 4294967295)
%6 = load i8, i8* %0
%7 = zext i8 %6 to i32
%8 = tail call i64 @UPDC32(i32 %7, i64 %5)
%9 = load i8, i8* %0
%10 = sext i8 %9 to i32
%11 = tail call i32 @zsendline(i32 %10)
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i64 @UPDC32(i32 %14, i64 %8)
%16 = load i8, i8* %12
%17 = sext i8 %16 to i32
%18 = tail call i32 @zsendline(i32 %17)
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call i64 @UPDC32(i32 %21, i64 %15)
%23 = load i8, i8* %19
%24 = sext i8 %23 to i32
%25 = tail call i32 @zsendline(i32 %24)
%26 = getelementptr inbounds i8, i8* %0, i64 3
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = tail call i64 @UPDC32(i32 %28, i64 %22)
%30 = load i8, i8* %26
%31 = sext i8 %30 to i32
%32 = tail call i32 @zsendline(i32 %31)
%33 = xor i64 %29, -1
%34 = trunc i64 %33 to i32
%35 = tail call i32 @zsendline(i32 %34)
%36 = lshr i64 %33, 8
%37 = trunc i64 %36 to i32
%38 = tail call i32 @zsendline(i32 %37)
%39 = lshr i64 %33, 16
%40 = trunc i64 %39 to i32
%41 = tail call i32 @zsendline(i32 %40)
%42 = lshr i64 %33, 24
%43 = trunc i64 %42 to i32
%44 = tail call i32 @zsendline(i32 %43)
ret void
}