#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*/ getarray(int *, int *);
int /*<<< orphan*/ printarray(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ shift(int *, int, int);
int main(void) {
  int table[8];
  int howmany = 0;
  int amount;
  getarray(table, &howmany);
  if (howmany == 0) {
    printf("Sorry, you entered the null sequence. Good bye.\n");
  } else {
    do {
      printarray(table, howmany);
      printf("By how much do you want to shift[0 to terminate]? ");
      scanf("%d", &amount);
      if (amount != 0)
        shift(table, howmany, amount);
    } while (amount != 0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
call   1040 <getarray@plt>
cmpl   $0x0,-0x34(%rbp)
jne    118e <main+0x3e>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    11e8 <main+0x98>
jmp    1193 <main+0x43>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <printarray@plt>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x38(%rbp)
je     11d4 <main+0x84>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1050 <shift@plt>
jmp    11d9 <main+0x89>
cmpl   $0x0,-0x38(%rbp)
jne    1193 <main+0x43>
jmp    11e8 <main+0x98>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <getarray@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     121c <main+0xbc>
lea    0x10(%rsp),%rdi
call   1070 <printarray@plt>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
je     1228 <main+0xc8>
lea    0x10(%rsp),%rbx
lea    0xe37(%rip),%r14
lea    0xe63(%rip),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <shift@plt>
cmpl   $0x0,0x8(%rsp)
je     1228 <main+0xc8>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1070 <printarray@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
jne    11e0 <main+0x80>
jmp    1228 <main+0xc8>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Sorry, you entered the null sequence. Good bye.\0A\00"
@.str.1 = [51 x i8] c"By how much do you want to shift[0 to terminate]? \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%6 = call i32 @getarray(i32* %5, i32* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %30
11: ; preds = %0
br label %12
12: ; preds = %26, %11
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 @printarray(i32* %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @shift(i32* %21, i32 %22, i32 %23)
br label %25
25: ; preds = %20, %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %12, label %29
29: ; preds = %26
br label %30
30: ; preds = %29, %9
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [51 x i8] c"By how much do you want to shift[0 to terminate]? \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [48 x i8] c"Sorry, you entered the null sequence. Good bye.\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [8 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%8 = call i32 @getarray(i32* %7, i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %0
%12 = call i32 @printarray(i32* %7, i32 %9)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %32, label %19
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %32
19: ; preds = %11, %25
%20 = phi i32 [ %30, %25 ], [ %15, %11 ]
%21 = load i32, i32* %2
%22 = call i32 @shift(i32* %7, i32 %21, i32 %20)
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %19
%26 = load i32, i32* %2
%27 = call i32 @printarray(i32* %7, i32 %26)
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %19
32: ; preds = %19, %25, %11, %17
ret i32 0
}