#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isspace(char const);
void print_item(FILE *os, const char *s, unsigned len) {
  unsigned i;
  for (i = 0; i < len; ++i) {
    if (isspace(s[i])) {
      fprintf(os, "_");
    } else {
      switch (s[i]) {
      case '(':
      case ')':
      case '"':
        fprintf(os, "_");
        break;
      default:
        fprintf(os, "%c", s[i]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<print_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11f3 <print_item+0xd3>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1177 <print_item+0x57>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11e0 <print_item+0xc0>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x22,%eax
je     11a7 <print_item+0x87>
jmp    1193 <print_item+0x73>
mov    -0x1c(%rbp),%eax
add    $0xffffffd8,%eax
sub    $0x1,%eax
ja     11be <print_item+0x9e>
jmp    11a7 <print_item+0x87>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11db <print_item+0xbb>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%edx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11e0 <print_item+0xc0>
jmp    11e5 <print_item+0xc5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <print_item+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_item>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     1187 <print_item+0x67>
mov    %rsi,%r12
mov    %rdi,%r14
mov    %edx,%r15d
xor    %ebx,%ebx
movabs $0x30400000000,%r13
jmp    1161 <print_item+0x41>
mov    %eax,%edi
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     1187 <print_item+0x67>
movsbl (%r12,%rbx,1),%edi
call   1030 <isspace@plt>
mov    $0x5f,%edi
test   %rax,%rax
jne    1150 <print_item+0x30>
movsbl (%r12,%rbx,1),%eax
cmp    $0x29,%eax
ja     1144 <print_item+0x24>
bt     %rax,%r13
jb     1150 <print_item+0x30>
jmp    1144 <print_item+0x24>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @print_item(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %22, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %17
%8 = phi i64 [ 0, %5 ], [ %20, %17 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i8, i8* %9
%15 = sext i8 %14 to i32
switch i32 %15, label %16 [
i32 40, label %17
i32 41, label %17
i32 34, label %17
]
16: ; preds = %13
br label %17
17: ; preds = %13, %13, %13, %7, %16
%18 = phi i32 [ %15, %16 ], [ 95, %7 ], [ 95, %13 ], [ 95, %13 ], [ 95, %13 ]
%19 = tail call i32 @fputc(i32 %18, i32* %0)
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %17, %3
ret void
}