#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*/ do_putc(int);
void send_packet_noack(unsigned char *pkt, int len) {
  unsigned char cksum = 0;
  do_putc(':');
  while (len-- > 0) {
    cksum += *pkt;
    do_putc(*pkt++);
  }
  do_putc(0x100 - cksum);
}


x86 assembly (clang, -O0):
<send_packet_noack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
mov    $0x3a,%edi
call   1030 <do_putc@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    116d <send_packet_noack+0x5d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
movzbl -0xd(%rbp),%eax
add    %ecx,%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%edi
call   1030 <do_putc@plt>
jmp    112d <send_packet_noack+0x1d>
movzbl -0xd(%rbp),%eax
mov    $0x100,%edi
sub    %eax,%edi
call   1030 <do_putc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_packet_noack>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x3a,%edi
call   1030 <do_putc@plt>
test   %r14d,%r14d
jle    1155 <send_packet_noack+0x45>
add    $0x1,%r14d
xor    %ebp,%ebp
nop
movzbl (%rbx),%edi
add    %edi,%ebp
add    $0x1,%rbx
call   1030 <do_putc@plt>
movzbl %bpl,%ebp
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
ja     1130 <send_packet_noack+0x20>
mov    $0x100,%edi
sub    %ebp,%edi
jmp    115a <send_packet_noack+0x4a>
mov    $0x100,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <do_putc@plt>

LLVM IR (-O0):
define void @send_packet_noack(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8 0, i8* %5
%6 = call i32 @do_putc(i32 58)
br label %7
7: ; preds = %11, %2
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = load i8, i8* %5
%16 = zext i8 %15 to i32
%17 = add nsw i32 %16, %14
%18 = trunc i32 %17 to i8
store i8 %18, i8* %5
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
%22 = zext i8 %21 to i32
%23 = call i32 @do_putc(i32 %22)
br label %7
24: ; preds = %7
%25 = load i8, i8* %5
%26 = zext i8 %25 to i32
%27 = sub nsw i32 256, %26
%28 = call i32 @do_putc(i32 %27)
ret void
}

LLVM IR (-O2):
define void @send_packet_noack(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @do_putc(i32 58)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %19
5: ; preds = %2, %5
%6 = phi i32 [ %15, %5 ], [ 0, %2 ]
%7 = phi i32 [ %9, %5 ], [ %1, %2 ]
%8 = phi i8* [ %13, %5 ], [ %0, %2 ]
%9 = add nsw i32 %7, -1
%10 = load i8, i8* %8
%11 = zext i8 %10 to i32
%12 = add nuw nsw i32 %6, %11
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = tail call i32 @do_putc(i32 %11)
%15 = and i32 %12, 255
%16 = icmp ugt i32 %7, 1
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = sub nuw nsw i32 256, %15
br label %19
19: ; preds = %17, %2
%20 = phi i32 [ 256, %2 ], [ %18, %17 ]
%21 = tail call i32 @do_putc(i32 %20)
ret void
}