#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char buf[] = "00001234";
  int i = 0, bufSize = sizeof(buf);
  char *lu8pBuf = buf;
  char tmpBuf[512] = {0};
  while (i < bufSize && (*lu8pBuf == '0')) {
    i++;
    lu8pBuf++;
    printf("lu8char: %c\n", *lu8pBuf);
  }
  memcpy(tmpBuf, buf + i, bufSize - i);
  printf("tmpbuf: %s\n", tmpBuf);
  memset(buf, 0, bufSize);
  memcpy(buf, tmpBuf, bufSize - i);
  printf("buf: %s\n", buf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xeb5(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x9,-0x18(%rbp)
lea    -0xd(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x221(%rbp)
jge    11a6 <main+0x76>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
sete   %al
mov    %al,-0x221(%rbp)
mov    -0x221(%rbp),%al
test   $0x1,%al
jne    11b9 <main+0x89>
jmp    11e8 <main+0xb8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117f <main+0x4f>
lea    -0x220(%rbp),%rdi
lea    -0xd(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
lea    -0x220(%rbp),%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd(%rbp),%rdi
mov    -0x18(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    -0xd(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
lea    -0xd(%rbp),%rsi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x218,%rsp
movabs $0x3433323130303030,%rax
32 33 34
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0x10(%rsp),%r14
mov    $0x200,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xea1(%rip),%rbx
mov    %rbx,%rdi
mov    $0x30,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x30,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x30,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x31,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
call   1050 <memcpy@plt>
lea    0xe59(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
lea    0xe29(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.buf = [9 x i8] c"00001234\00"
@.str = [13 x i8] c"lu8char: %c\0A\00"
@.str.1 = [12 x i8] c"tmpbuf: %s\0A\00"
@.str.2 = [9 x i8] c"buf: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [512 x i8]
store i32 0, i32* %1
%7 = bitcast [9 x i8]* %2 to i8*
store i32 0, i32* %3
store i32 9, i32* %4
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
store i8* %8, i8** %5
%9 = bitcast [512 x i8]* %6 to i8*
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 48
br label %19
19: ; preds = %14, %10
%20 = phi i1 [ false, %10 ], [ %18, %14 ]
br i1 %20, label %21, label %30
21: ; preds = %19
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %10
30: ; preds = %19
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i32, i32* %4
%37 = load i32, i32* %3
%38 = sub nsw i32 %36, %37
%39 = call i32 @memcpy(i8* %31, i8* %35, i32 %38)
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%43 = load i32, i32* %4
%44 = call i32 @memset(i8* %42, i32 0, i32 %43)
%45 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%47 = load i32, i32* %4
%48 = load i32, i32* %3
%49 = sub nsw i32 %47, %48
%50 = call i32 @memcpy(i8* %45, i8* %46, i32 %49)
%51 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@__const.main.buf = [9 x i8] c"00001234\00"
@.str = [13 x i8] c"lu8char: %c\0A\00"
@.str.1 = [12 x i8] c"tmpbuf: %s\0A\00"
@.str.2 = [9 x i8] c"buf: %s\0A\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 48)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 48)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 48)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 49)
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 4
%10 = call i32 @memcpy(i8* %4, i8* %9, i32 5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = call i32 @memset(i8* %3, i32 0, i32 9)
%13 = call i32 @memcpy(i8* %3, i8* %4, i32 5)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}