#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*/ assert(int);
int /*<<< orphan*/ memshift(int, char *, int, int);
int /*<<< orphan*/ strcmp(char *, char *);
int TEST_memshift(void) {
  {
    char buf[] = "abc";
    memshift(-1, buf, sizeof(buf) - 1, sizeof(buf[0]));
    assert(!strcmp(buf, "bcc"));
  }
  {
    char buf[] = "abc";
    memshift(1, buf, sizeof(buf) - 1, sizeof(buf[0]));
    assert(!strcmp(buf, "aab"));
  }
  return 0;
}


x86 assembly (clang, -O0):
<TEST_memshift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xec2(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x3,%edx
mov    $0x1,%ecx
call   1030 <memshift@plt>
lea    -0x4(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0xe7f(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rsi
mov    $0x1,%ecx
mov    $0x3,%edx
mov    %ecx,%edi
call   1030 <memshift@plt>
lea    -0x8(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TEST_memshift>:
push   %rax
movl   $0x636261,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0xffffffff,%edi
mov    $0x3,%edx
mov    $0x1,%ecx
call   1030 <memshift@plt>
xor    %edi,%edi
cmpl   $0x636362,0x4(%rsp)
sete   %dil
call   1040 <assert@plt>
movl   $0x636261,(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x3,%edx
mov    $0x1,%ecx
call   1030 <memshift@plt>
xor    %edi,%edi
cmpl   $0x626161,(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.TEST_memshift.buf = [4 x i8] c"abc\00"
@.str = [4 x i8] c"bcc\00"
@__const.TEST_memshift.buf.1 = [4 x i8] c"abc\00"
@.str.2 = [4 x i8] c"aab\00"
define i32 @TEST_memshift() {
%1 = alloca [4 x i8]
%2 = alloca [4 x i8]
%3 = bitcast [4 x i8]* %1 to i8*
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%5 = call i32 @memshift(i32 -1, i8* %4, i32 3, i32 1)
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = bitcast [4 x i8]* %2 to i8*
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%14 = call i32 @memshift(i32 1, i8* %13, i32 3, i32 1)
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret i32 0
}

LLVM IR (-O2):
define i32 @TEST_memshift() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 6513249, i32* %1
%4 = call i32 @memshift(i32 -1, i8* %3, i32 3, i32 1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 6513506
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = bitcast i32* %2 to i8*
store i32 6513249, i32* %2
%10 = call i32 @memshift(i32 1, i8* %9, i32 3, i32 1)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 6447457
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
ret i32 0
}