#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*/ GPS_Diag(char *, unsigned char);
scalar_t__ isalnum(unsigned char);
void DiagS(void *buf, size_t sz) {
  unsigned char *cbuf = (unsigned char *)buf;
  while (sz--) {
    unsigned char c = *cbuf++;
    GPS_Diag("%c", isalnum(c) ? c : '.');
  }
}


x86 assembly (clang, -O0):
<DiagS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11a8 <DiagS+0x88>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     1184 <DiagS+0x64>
movzbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1191 <DiagS+0x71>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    1191 <DiagS+0x71>
mov    -0x20(%rbp),%eax
lea    0xe65(%rip),%rdi
movzbl %al,%esi
call   1040 <GPS_Diag@plt>
jmp    1138 <DiagS+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiagS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1176 <DiagS+0x56>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
mov    $0x2e,%r13d
lea    0xebb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r14,%rbx,1),%ebp
mov    %ebp,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
cmove  %r13d,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <GPS_Diag@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <DiagS+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @DiagS(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %23, %2
%9 = load i64, i64* %4
%10 = add i64 %9, -1
store i64 %10, i64* %4
%11 = icmp ne i64 %9, 0
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8, i8* %13
store i8 %15, i8* %6
%16 = load i8, i8* %6
%17 = call i64 @isalnum(i8 zeroext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8, i8* %6
%21 = zext i8 %20 to i32
br label %23
22: ; preds = %12
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 46, %22 ]
%25 = trunc i32 %24 to i8
%26 = call i32 @GPS_Diag(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %25)
br label %8
27: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @DiagS(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %15, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %7, %4 ], [ %1, %2 ]
%6 = phi i8* [ %8, %4 ], [ %0, %2 ]
%7 = add i64 %5, -1
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = load i8, i8* %6
%10 = tail call i64 @isalnum(i8 zeroext %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8 46, i8 %9
%13 = tail call i32 @GPS_Diag(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %12)
%14 = icmp eq i64 %7, 0
br i1 %14, label %15, label %4
15: ; preds = %4, %2
ret void
}