#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 */
scalar_t__ isAlphanumeric(char);
int /*<<< orphan*/ printf(char *, ...);
void dump_string(char *s) {
  int i;
  for (i = 0; s[i] != 0; i++) {
    if (isAlphanumeric(s[i])) {
      printf("%c", s[i]);
    } else {
      printf("[%d]", s[i]);
    }
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<dump_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11af <dump_string+0x8f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isAlphanumeric@plt>
cmp    $0x0,%rax
je     1182 <dump_string+0x62>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119c <dump_string+0x7c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <dump_string+0x81>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <dump_string+0x13>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_string>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     117f <dump_string+0x4f>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xeb8(%rip),%r14
jmp    1165 <dump_string+0x35>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117f <dump_string+0x4f>
movsbl %al,%edi
call   1050 <isAlphanumeric@plt>
movsbl -0x1(%rbx),%esi
test   %rax,%rax
je     1150 <dump_string+0x20>
mov    %esi,%edi
call   1030 <putchar@plt>
jmp    115a <dump_string+0x2a>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"[%d]\00"
define void @dump_string(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %16
%5 = phi i64 [ %17, %16 ], [ 0, %1 ]
%6 = phi i8 [ %19, %16 ], [ %2, %1 ]
%7 = phi i8* [ %18, %16 ], [ %0, %1 ]
%8 = tail call i64 @isAlphanumeric(i8 signext %6)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %7
%11 = sext i8 %10 to i32
br i1 %9, label %14, label %12
12: ; preds = %4
%13 = tail call i32 @putchar(i32 %11)
br label %16
14: ; preds = %4
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %16
16: ; preds = %12, %14
%17 = add nuw i64 %5, 1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %16, %1
%22 = tail call i32 @putchar(i32 10)
ret void
}