#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 */
char *getVideoPix();
int /*<<< orphan*/ memcpy(char *, char *, int);
void shiftVideo() {
  char *video = getVideoPix();
  memcpy(video, video + 3 * 1024 * 16, 3 * 1024 * (768 - 16));
  for (int i = 0; i < 3 * 16 * 1024; i++) {
    switch (i % 2) {
    case 0:
      *(video + i + 3 * 1024 * (768 - 16)) = 0;
      break;
    case 1:
      *(video + i + 3 * 1024 * (768 - 16)) = 0;
      break;
    case 2:
      *(video + i + 3 * 1024 * (768 - 16)) = 0;
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<shiftVideo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <getVideoPix@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xc000,%rsi
mov    $0x234000,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xc000,-0xc(%rbp)
jge    11f8 <shiftVideo+0xd8>
mov    -0xc(%rbp),%eax
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
je     11a1 <shiftVideo+0x81>
jmp    117f <shiftVideo+0x5f>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11b6 <shiftVideo+0x96>
jmp    1190 <shiftVideo+0x70>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11cb <shiftVideo+0xab>
jmp    11e0 <shiftVideo+0xc0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,0x234000(%rax,%rcx,1)
jmp    11e5 <shiftVideo+0xc5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,0x234000(%rax,%rcx,1)
jmp    11e5 <shiftVideo+0xc5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,0x234000(%rax,%rcx,1)
jmp    11e5 <shiftVideo+0xc5>
jmp    11e5 <shiftVideo+0xc5>
jmp    11ea <shiftVideo+0xca>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <shiftVideo+0x33>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shiftVideo>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getVideoPix@plt>
mov    %rax,%r14
lea    0xc000(%rax),%rsi
mov    %rax,%rdi
mov    $0x234000,%edx
call   1030 <memcpy@plt>
xorps  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movups %xmm0,0x234000(%r14,%rbx,1)
movups %xmm0,0x234010(%r14,%rbx,1)
movups %xmm0,0x234020(%r14,%rbx,1)
movups %xmm0,0x234030(%r14,%rbx,1)
movups %xmm0,0x234040(%r14,%rbx,1)
movups %xmm0,0x234050(%r14,%rbx,1)
movups %xmm0,0x234060(%r14,%rbx,1)
movups %xmm0,0x234070(%r14,%rbx,1)
movups %xmm0,0x234080(%r14,%rbx,1)
movups %xmm0,0x234090(%r14,%rbx,1)
movups %xmm0,0x2340a0(%r14,%rbx,1)
movups %xmm0,0x2340b0(%r14,%rbx,1)
movups %xmm0,0x2340c0(%r14,%rbx,1)
movups %xmm0,0x2340d0(%r14,%rbx,1)
movups %xmm0,0x2340e0(%r14,%rbx,1)
movups %xmm0,0x2340f0(%r14,%rbx,1)
add    $0x100,%rbx
cmp    $0xc000,%rbx
jne    1150 <shiftVideo+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @shiftVideo() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* (...) @getVideoPix()
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = load i8*, i8** %1
%6 = getelementptr inbounds i8, i8* %5, i64 49152
%7 = call i32 @memcpy(i8* %4, i8* %6, i32 2310144)
store i32 0, i32* %2
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 49152
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %2
%13 = srem i32 %12, 2
switch i32 %13, label %32 [
i32 0, label %14
i32 1, label %20
i32 2, label %26
]
14: ; preds = %11
%15 = load i8*, i8** %1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 2310144
store i8 0, i8* %19
br label %33
20: ; preds = %11
%21 = load i8*, i8** %1
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 2310144
store i8 0, i8* %25
br label %33
26: ; preds = %11
%27 = load i8*, i8** %1
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 2310144
store i8 0, i8* %31
br label %33
32: ; preds = %11
br label %33
33: ; preds = %32, %26, %20, %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %8
37: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @shiftVideo() {
%1 = tail call i8* (...) @getVideoPix()
%2 = getelementptr inbounds i8, i8* %1, i64 49152
%3 = tail call i32 @memcpy(i8* %1, i8* %2, i32 2310144)
%4 = getelementptr inbounds i8, i8* %1, i64 2310144
%5 = getelementptr inbounds i8, i8* %1, i64 2310144
%6 = getelementptr inbounds i8, i8* %1, i64 2310144
%7 = getelementptr inbounds i8, i8* %1, i64 2310144
%8 = getelementptr inbounds i8, i8* %1, i64 2310144
%9 = getelementptr inbounds i8, i8* %1, i64 2310144
%10 = getelementptr inbounds i8, i8* %1, i64 2310144
%11 = getelementptr inbounds i8, i8* %1, i64 2310144
br label %12
12: ; preds = %12, %0
%13 = phi i64 [ 0, %0 ], [ %53, %12 ]
%14 = getelementptr inbounds i8, i8* %4, i64 %13
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %15
%16 = getelementptr inbounds i8, i8* %14, i64 16
%17 = bitcast i8* %16 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %17
%18 = or i64 %13, 32
%19 = getelementptr inbounds i8, i8* %5, i64 %18
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %20
%21 = getelementptr inbounds i8, i8* %19, i64 16
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %22
%23 = or i64 %13, 64
%24 = getelementptr inbounds i8, i8* %6, i64 %23
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %25
%26 = getelementptr inbounds i8, i8* %24, i64 16
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %27
%28 = or i64 %13, 96
%29 = getelementptr inbounds i8, i8* %7, i64 %28
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %29, i64 16
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %32
%33 = or i64 %13, 128
%34 = getelementptr inbounds i8, i8* %8, i64 %33
%35 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %35
%36 = getelementptr inbounds i8, i8* %34, i64 16
%37 = bitcast i8* %36 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %37
%38 = or i64 %13, 160
%39 = getelementptr inbounds i8, i8* %9, i64 %38
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %40
%41 = getelementptr inbounds i8, i8* %39, i64 16
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %42
%43 = or i64 %13, 192
%44 = getelementptr inbounds i8, i8* %10, i64 %43
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %45
%46 = getelementptr inbounds i8, i8* %44, i64 16
%47 = bitcast i8* %46 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %47
%48 = or i64 %13, 224
%49 = getelementptr inbounds i8, i8* %11, i64 %48
%50 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %50
%51 = getelementptr inbounds i8, i8* %49, i64 16
%52 = bitcast i8* %51 to <16 x i8>*
store <16 x i8> zeroinitializer, <16 x i8>* %52
%53 = add nuw nsw i64 %13, 256
%54 = icmp eq i64 %53, 49152
br i1 %54, label %55, label %12
55: ; preds = %12
ret void
}