#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*/ shift(int *, int, int);
char *test_shift_left() {
  int a[] = {1, 2, 3, 4};
  shift(a, 4, -1);
  do {
    if (!(a[0] == 2))
      return "a[0] != 2";
  } while (0);
  do {
    if (!(a[1] == 3))
      return "a[1] != 3";
  } while (0);
  do {
    if (!(a[2] == 4))
      return "a[2] != 4";
  } while (0);
  do {
    if (!(a[3] == 1))
      return "a[3] != 1";
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<test_shift_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0xffffffff,%edx
call   1030 <shift@plt>
cmpl   $0x2,-0x20(%rbp)
je     115b <test_shift_left+0x4b>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d4 <test_shift_left+0xc4>
jmp    1160 <test_shift_left+0x50>
jmp    1165 <test_shift_left+0x55>
cmpl   $0x3,-0x1c(%rbp)
je     117f <test_shift_left+0x6f>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d4 <test_shift_left+0xc4>
jmp    1184 <test_shift_left+0x74>
jmp    1189 <test_shift_left+0x79>
cmpl   $0x4,-0x18(%rbp)
je     11a3 <test_shift_left+0x93>
lea    0xe8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d4 <test_shift_left+0xc4>
jmp    11a8 <test_shift_left+0x98>
jmp    11ad <test_shift_left+0x9d>
cmpl   $0x1,-0x14(%rbp)
je     11c7 <test_shift_left+0xb7>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d4 <test_shift_left+0xc4>
jmp    11cc <test_shift_left+0xbc>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_shift_left>:
sub    $0x18,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0xffffffff,%edx
call   1030 <shift@plt>
cmpl   $0x2,(%rsp)
jne    115c <test_shift_left+0x4c>
cmpl   $0x3,0x4(%rsp)
jne    1168 <test_shift_left+0x58>
cmpl   $0x4,0x8(%rsp)
jne    1174 <test_shift_left+0x64>
xor    %eax,%eax
cmpl   $0x1,0xc(%rsp)
lea    0xedb(%rip),%rcx
cmovne %rcx,%rax
add    $0x18,%rsp
ret
lea    0xead(%rip),%rax
add    $0x18,%rsp
ret
lea    0xeab(%rip),%rax
add    $0x18,%rsp
ret
lea    0xea9(%rip),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_shift_left.a = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [10 x i8] c"a[0] != 2\00"
@.str.1 = [10 x i8] c"a[1] != 3\00"
@.str.2 = [10 x i8] c"a[2] != 4\00"
@.str.3 = [10 x i8] c"a[3] != 1\00"
define i8* @test_shift_left() {
%1 = alloca i8*
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @shift(i32* %4, i32 4, i32 -1)
br label %6
6: ; preds = %0
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 2
br i1 %9, label %11, label %10
10: ; preds = %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1
br label %34
11: ; preds = %6
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 3
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %34
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 4
br i1 %23, label %25, label %24
24: ; preds = %20
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %34
25: ; preds = %20
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 1
br i1 %30, label %32, label %31
31: ; preds = %27
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %34
32: ; preds = %27
br label %33
33: ; preds = %32
store i8* null, i8** %1
br label %34
34: ; preds = %33, %31, %24, %17, %10
%35 = load i8*, i8** %1
ret i8* %35
}

LLVM IR (-O2):
@__const.test_shift_left.a = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [10 x i8] c"a[0] != 2\00"
@.str.1 = [10 x i8] c"a[1] != 3\00"
@.str.2 = [10 x i8] c"a[2] != 4\00"
@.str.3 = [10 x i8] c"a[3] != 1\00"
define i8* @test_shift_left() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @shift(i32* %3, i32 4, i32 -1)
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %20
7: ; preds = %0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 4
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 1
%19 = select i1 %18, i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
br label %20
20: ; preds = %15, %11, %7, %0
%21 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %11 ], [ %19, %15 ]
ret i8* %21
}