#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *, int *);
int /*<<< orphan*/ shift(char *, int);
int main() {
  char buf[2048];
  int n;
  printf("Shift string `s` right `n` bytes, enter `s` and `n`\n");
  scanf("%2048s%i", buf, &n);
  shift(buf, n);
  printf("result: %s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x810(%rbp),%rsi
lea    0xed7(%rip),%rdi
lea    -0x814(%rbp),%rdx
call   1050 <scanf@plt>
lea    -0x810(%rbp),%rdi
mov    -0x814(%rbp),%esi
call   1040 <shift@plt>
lea    -0x810(%rbp),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x810,%rsp
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <shift@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Shift string `s` right `n` bytes, enter `s` and `n`\0A\00"
@.str.1 = [9 x i8] c"%2048s%i\00"
@.str.2 = [12 x i8] c"result: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2048 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %3)
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @shift(i8* %7, i32 %8)
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %10)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%2048s%i\00"
@.str.2 = [12 x i8] c"result: %s\0A\00"
@str = [52 x i8] c"Shift string `s` right `n` bytes, enter `s` and `n`\00"
define i32 @main() {
%1 = alloca [2048 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32* %2)
%7 = load i32, i32* %2
%8 = call i32 @shift(i8* %3, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}