#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 scalar_t__ wchar_t;

/* Variables and functions */
wchar_t *buffer_shift(wchar_t *buffer, int buffer_len) {
  int i = 0;
  int char_idx = 0;
  while (1) {
    if (buffer[0] == 0) {
      buffer++;
    } else {
      return buffer;
    }
    if (i == buffer_len - 1) {
      break;
    }
    i++;
  }
  return buffer;
}


x86 assembly (clang, -O0):
<buffer_shift>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1138 <buffer_shift+0x38>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1145 <buffer_shift+0x45>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1171 <buffer_shift+0x71>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    115b <buffer_shift+0x5b>
jmp    1169 <buffer_shift+0x69>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1119 <buffer_shift+0x19>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<buffer_shift>:
cmpq   $0x0,(%rdi)
je     110a <buffer_shift+0xa>
mov    %rdi,%rax
ret
add    $0xffffffff,%esi
lea    (%rdi,%rsi,8),%rcx
add    $0x8,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
sub    $0x1,%esi
jb     1134 <buffer_shift+0x34>
lea    0x8(%rdi),%rax
cmpq   $0x0,0x8(%rdi)
mov    %rax,%rdi
je     1120 <buffer_shift+0x20>
ret
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i64* @buffer_shift(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %2, %24
%9 = load i64*, i64** %4
%10 = getelementptr inbounds i64, i64* %9, i64 0
%11 = load i64, i64* %10
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i64*, i64** %4
%15 = getelementptr inbounds i64, i64* %14, i32 1
store i64* %15, i64** %4
br label %18
16: ; preds = %8
%17 = load i64*, i64** %4
store i64* %17, i64** %3
br label %29
18: ; preds = %13
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, 1
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %18
br label %27
24: ; preds = %18
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %8
27: ; preds = %23
%28 = load i64*, i64** %4
store i64* %28, i64** %3
br label %29
29: ; preds = %27, %16
%30 = load i64*, i64** %3
ret i64* %30
}

LLVM IR (-O2):
define i64* @buffer_shift(i64* %0, i32 %1) {
%3 = load i64, i64* %0
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = add i32 %1, -1
%7 = zext i32 %6 to i64
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr i64, i64* %0, i64 %8
br label %14
10: ; preds = %14
%11 = add nuw nsw i32 %15, 1
%12 = load i64, i64* %17
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %5, %10
%15 = phi i32 [ 0, %5 ], [ %11, %10 ]
%16 = phi i64* [ %0, %5 ], [ %17, %10 ]
%17 = getelementptr inbounds i64, i64* %16, i64 1
%18 = icmp eq i32 %15, %6
br i1 %18, label %19, label %10
19: ; preds = %10, %14, %2
%20 = phi i64* [ %0, %2 ], [ %17, %10 ], [ %9, %14 ]
ret i64* %20
}