#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strReverseT(char *, int, int);
int strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Input Error!");
    exit(EXIT_FAILURE);
  }
  int strLen = strlen(argv[1]);
  int tailNum = atoi(argv[2]);
  tailNum = tailNum % strLen;
  strReverseT(argv[1], 0, strLen - tailNum);
  strReverseT(argv[1], strLen - tailNum, tailNum);
  strReverseT(argv[1], 0, strLen);
  printf("%s\n", argv[1]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a3 <main+0x43>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
xor    %esi,%esi
call   1050 <strReverseT@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
sub    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <strReverseT@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1050 <strReverseT@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11dd <main+0x7d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
cltd
idiv   %r14d
mov    %edx,%r15d
mov    0x8(%rbx),%rdi
mov    %r14d,%ebp
sub    %edx,%ebp
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <strReverseT@plt>
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1050 <strReverseT@plt>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <strReverseT@plt>
mov    0x8(%rbx),%rsi
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"Input Error!\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = srem i32 %24, %25
store i32 %26, i32* %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = sub nsw i32 %30, %31
%33 = call i32 @strReverseT(i8* %29, i32 0, i32 %32)
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = sub nsw i32 %37, %38
%40 = load i32, i32* %7
%41 = call i32 @strReverseT(i8* %36, i32 %39, i32 %40)
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = load i32, i32* %6
%46 = call i32 @strReverseT(i8* %44, i32 0, i32 %45)
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @EXIT_SUCCESS
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"Input Error!\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = srem i32 %15, %12
%17 = load i8*, i8** %10
%18 = sub nsw i32 %12, %16
%19 = tail call i32 @strReverseT(i8* %17, i32 0, i32 %18)
%20 = load i8*, i8** %10
%21 = tail call i32 @strReverseT(i8* %20, i32 %18, i32 %16)
%22 = load i8*, i8** %10
%23 = tail call i32 @strReverseT(i8* %22, i32 0, i32 %12)
%24 = load i8*, i8** %10
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}