#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*/ fputc(char const, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ isprint(char const);
int /*<<< orphan*/ stdout;
void print_host(const char *restrict host, int len) {
  const char *last;
  int width = 0;
  if (len > 16)
    len = 16;
  last = host + len;
  for (; host < last; host++) {
    if (isprint(*host) && *host != ' ') {
      fputc(*host, stdout);
      ++width;
    } else {
      break;
    }
  }
  if (width < 16)
    fputs("-               " + width, stdout);
}


x86 assembly (clang, -O0):
<print_host>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0xc(%rbp)
jle    1157 <print_host+0x27>
movl   $0x10,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11da <print_host+0xaa>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     11bf <print_host+0x8f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11bf <print_host+0x8f>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    0x2e39(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c4 <print_host+0x94>
jmp    11da <print_host+0xaa>
jmp    11c9 <print_host+0x99>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1166 <print_host+0x36>
cmpl   $0x10,-0x1c(%rbp)
jge    1200 <print_host+0xd0>
movslq -0x1c(%rbp),%rax
lea    0xe11(%rip),%rdi
add    %rax,%rdi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_host>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x10,%esi
mov    $0x10,%eax
cmovl  %esi,%eax
test   %esi,%esi
jle    11a6 <print_host+0x76>
mov    %rdi,%r14
movslq %eax,%r15
add    %rdi,%r15
xor    %ebx,%ebx
mov    0x2e87(%rip),%r12
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1195 <print_host+0x65>
movzbl (%r14,%rbx,1),%eax
cmp    $0x20,%al
je     1195 <print_host+0x65>
mov    (%r12),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
lea    (%r14,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    %r15,%rax
jb     1160 <print_host+0x30>
cmp    $0xf,%ebx
jbe    11a8 <print_host+0x78>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %ebx,%ebx
mov    %ebx,%eax
lea    0xe4f(%rip),%rdi
add    %rax,%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fputs@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [17 x i8] c"- \00"
define void @print_host(i8* noalias %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 16
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 16, i32* %4
br label %10
10: ; preds = %9, %2
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8* %14, i8** %5
br label %15
15: ; preds = %38, %10
%16 = load i8*, i8** %3
%17 = load i8*, i8** %5
%18 = icmp ult i8* %16, %17
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = call i64 @isprint(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 32
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = load i32, i32* @stdout
%33 = call i32 @fputc(i8 signext %31, i32 %32)
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %37
36: ; preds = %24, %19
br label %41
37: ; preds = %29
br label %38
38: ; preds = %37
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %3
br label %15
41: ; preds = %36, %15
%42 = load i32, i32* %6
%43 = icmp slt i32 %42, 16
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %46
%48 = load i32, i32* @stdout
%49 = call i32 @fputs(i8* %47, i32 %48)
br label %50
50: ; preds = %44, %41
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [17 x i8] c"- \00"
define void @print_host(i8* noalias %0, i32 %1) {
%3 = icmp slt i32 %1, 16
%4 = select i1 %3, i32 %1, i32 16
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %26
8: ; preds = %2, %17
%9 = phi i32 [ %20, %17 ], [ 0, %2 ]
%10 = phi i8* [ %21, %17 ], [ %0, %2 ]
%11 = load i8, i8* %10
%12 = tail call i64 @isprint(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %8
%15 = load i8, i8* %10
%16 = icmp eq i8 %15, 32
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputc(i8 signext %15, i32 %18)
%20 = add nuw nsw i32 %9, 1
%21 = getelementptr inbounds i8, i8* %10, i64 1
%22 = icmp ult i8* %21, %6
br i1 %22, label %8, label %23
23: ; preds = %17, %14, %8
%24 = phi i32 [ %20, %17 ], [ %9, %14 ], [ %9, %8 ]
%25 = icmp ult i32 %24, 16
br i1 %25, label %26, label %32
26: ; preds = %2, %23
%27 = phi i32 [ %24, %23 ], [ 0, %2 ]
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %28
%30 = load i32, i32* @stdout
%31 = tail call i32 @fputs(i8* %29, i32 %30)
br label %32
32: ; preds = %26, %23
ret void
}