#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 */
struct modemchannel {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ putc(unsigned char const, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void pktput(struct modemchannel *chan, const unsigned char *data,
            unsigned int len) {
  unsigned int i;
  fprintf(stderr, "Data: ");
  for (i = 0; i < len; i++)
    if (data[i] >= ' ' && data[i] <= 0x7f)
      putc(data[i], stderr);
    else
      putc('.', stderr);
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<pktput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11c9 <pktput+0xa9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     11a3 <pktput+0x83>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jg     11a3 <pktput+0x83>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    0x2e4c(%rip),%rcx
mov    (%rcx),%esi
movzbl %al,%edi
call   1030 <putc@plt>
jmp    11b6 <pktput+0x96>
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
mov    $0x2e,%edi
call   1030 <putc@plt>
jmp    11bb <pktput+0x9b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114f <pktput+0x2f>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pktput>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r12
mov    0x2eab(%rip),%r15
mov    (%r15),%edi
lea    0xec1(%rip),%rsi
call   1040 <fprintf@plt>
test   %r14d,%r14d
je     117f <pktput+0x5f>
mov    %r14d,%ebp
xor    %ebx,%ebx
mov    $0x2e,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rbx,1),%eax
cmp    $0x20,%al
mov    (%r15),%esi
cmovl  %r14d,%eax
movzbl %al,%edi
call   1030 <putc@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <pktput+0x40>
mov    (%r15),%edi
lea    0xe7e(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.modemchannel = type { i32 }
@stderr = global i32 0
@.str = [7 x i8] c"Data: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @pktput(%struct.modemchannel* %0, i8* %1, i32 %2) {
%4 = alloca %struct.modemchannel*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store %struct.modemchannel* %0, %struct.modemchannel** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %10
10: ; preds = %42, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %45
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i32, i32* %7
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = icmp sge i32 %20, 32
br i1 %21, label %22, label %38
22: ; preds = %14
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp sle i32 %28, 127
br i1 %29, label %30, label %38
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = load i32, i32* @stderr
%37 = call i32 @putc(i8 zeroext %35, i32 %36)
br label %41
38: ; preds = %22, %14
%39 = load i32, i32* @stderr
%40 = call i32 @putc(i8 zeroext 46, i32 %39)
br label %41
41: ; preds = %38, %30
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add i32 %43, 1
store i32 %44, i32* %7
br label %10
45: ; preds = %10
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.modemchannel = type { i32 }
@stderr = global i32 0
@.str = [7 x i8] c"Data: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @pktput(%struct.modemchannel* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %2, 0
br i1 %6, label %19, label %7
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = icmp sgt i8 %12, 31
%14 = load i32, i32* @stderr
%15 = select i1 %13, i8 %12, i8 46
%16 = tail call i32 @putc(i8 zeroext %15, i32 %14)
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9, %3
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}