#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*/ printf(char *, ...);
void wchar8show(const char *src) {
  printf("char show\n");
  size_t srclen = 0;
  while (*src) {
    printf("%d %d %x\n", (int)srclen, *src, *src);
    srclen++;
    src++;
  }
}


x86 assembly (clang, -O0):
<wchar8show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117e <wchar8show+0x6e>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1132 <wchar8show+0x22>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wchar8show>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%al
test   %al,%al
je     116f <wchar8show+0x4f>
lea    0xebe(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <wchar8show+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"char show\0A\00"
@.str.1 = [10 x i8] c"%d %d %x\0A\00"
define void @wchar8show(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %5
5: ; preds = %9, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i64, i64* %3
%11 = trunc i64 %10 to i32
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14, i32 %17)
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"%d %d %x\0A\00"
@str = [10 x i8] c"char show\00"
define void @wchar8show(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %14, %5 ], [ %3, %1 ]
%7 = phi i64 [ %12, %5 ], [ 0, %1 ]
%8 = phi i8* [ %13, %5 ], [ %0, %1 ]
%9 = trunc i64 %7 to i32
%10 = sext i8 %6 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10, i32 %10)
%12 = add i64 %7, 1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %1
ret void
}