#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) {
  if (!src) {
    printf("char show <NULL>\n");
  } else {
    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)
cmpq   $0x0,-0x8(%rbp)
jne    113a <wchar8show+0x2a>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <wchar8show+0x91>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     119c <wchar8show+0x8c>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
lea    0xea5(%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    1150 <wchar8show+0x40>
jmp    11a1 <wchar8show+0x91>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wchar8show>:
test   %rdi,%rdi
je     1175 <wchar8show+0x55>
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%al
test   %al,%al
je     116f <wchar8show+0x4f>
lea    0xeb9(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
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
lea    0xe8e(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"char show <NULL>\0A\00"
@.str.1 = [11 x i8] c"char show\0A\00"
@.str.2 = [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 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %29
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %3
br label %10
10: ; preds = %14, %8
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i64, i64* %3
%16 = trunc i64 %15 to i32
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %19, i32 %22)
%24 = load i64, i64* %3
%25 = add i64 %24, 1
store i64 %25, i64* %3
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %2
br label %10
28: ; preds = %10
br label %29
29: ; preds = %28, %6
ret void
}

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