#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int);
int strlen(char *);
void mpz_rotate_sum(mpz_t rop) {
  char str[500];
  mpz_get_str(str, 10, rop);
  size_t l = strlen(str) - 1;
  size_t i;
  for (i = 0; i < l / 2 + 1; ++i) {
    char t = str[l - i];
    str[l - i] = str[i];
    str[i] = t;
  }
  mpz_t s;
  mpz_init(s);
  mpz_set_str(s, str, 10);
  mpz_add(rop, rop, s);
  mpz_clear(s);
}


x86 assembly (clang, -O0):
<mpz_rotate_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x200(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x208(%rbp)
movq   $0x0,-0x210(%rbp)
mov    -0x210(%rbp),%rax
mov    -0x208(%rbp),%rcx
shr    $0x1,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    122d <mpz_rotate_sum+0xcd>
mov    -0x208(%rbp),%rax
sub    -0x210(%rbp),%rax
mov    -0x200(%rbp,%rax,1),%al
mov    %al,-0x211(%rbp)
mov    -0x210(%rbp),%rax
mov    -0x200(%rbp,%rax,1),%cl
mov    -0x208(%rbp),%rax
sub    -0x210(%rbp),%rax
mov    %cl,-0x200(%rbp,%rax,1)
mov    -0x211(%rbp),%cl
mov    -0x210(%rbp),%rax
mov    %cl,-0x200(%rbp,%rax,1)
mov    -0x210(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x210(%rbp)
jmp    11a5 <mpz_rotate_sum+0x45>
mov    -0x218(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x218(%rbp),%edi
lea    -0x200(%rbp),%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x218(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x218(%rbp),%edi
call   1080 <mpz_clear@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_rotate_sum>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r14d,%edx
call   1050 <mpz_get_str@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movslq %eax,%rbp
mov    %rbp,%rcx
shr    %rcx
add    $0x1,%rcx
cmp    $0x2,%ebp
jae    11a2 <mpz_rotate_sum+0x42>
xor    %edx,%edx
jmp    11d9 <mpz_rotate_sum+0x79>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
lea    (%rsp,%rbp,1),%rdi
xor    %edx,%edx
nop
movzbl (%rdi),%ebx
movzbl (%rsp,%rdx,1),%eax
mov    %al,(%rdi)
mov    %bl,(%rsp,%rdx,1)
movzbl -0x1(%rdi),%eax
movzbl 0x1(%rsp,%rdx,1),%ebx
mov    %bl,-0x1(%rdi)
mov    %al,0x1(%rsp,%rdx,1)
add    $0x2,%rdx
add    $0xfffffffffffffffe,%rdi
cmp    %rdx,%rsi
jne    11b0 <mpz_rotate_sum+0x50>
test   $0x1,%cl
je     11ed <mpz_rotate_sum+0x8d>
sub    %rdx,%rbp
mov    (%rsp,%rbp,1),%al
mov    (%rsp,%rdx,1),%cl
mov    %cl,(%rsp,%rbp,1)
mov    %al,(%rsp,%rdx,1)
call   1040 <mpz_init@plt>
mov    %rsp,%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    %r14d,%edi
mov    %r14d,%esi
call   1060 <mpz_add@plt>
call   1080 <mpz_clear@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @mpz_rotate_sum(i32 %0) {
%2 = alloca i32
%3 = alloca [500 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %2
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @mpz_get_str(i8* %8, i32 10, i32 %9)
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
store i64 %14, i64* %4
store i64 0, i64* %5
br label %15
15: ; preds = %37, %1
%16 = load i64, i64* %5
%17 = load i64, i64* %4
%18 = udiv i64 %17, 2
%19 = add i64 %18, 1
%20 = icmp ult i64 %16, %19
br i1 %20, label %21, label %40
21: ; preds = %15
%22 = load i64, i64* %4
%23 = load i64, i64* %5
%24 = sub i64 %22, %23
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %6
%27 = load i64, i64* %5
%28 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i64, i64* %4
%31 = load i64, i64* %5
%32 = sub i64 %30, %31
%33 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %32
store i8 %29, i8* %33
%34 = load i8, i8* %6
%35 = load i64, i64* %5
%36 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 %35
store i8 %34, i8* %36
br label %37
37: ; preds = %21
%38 = load i64, i64* %5
%39 = add i64 %38, 1
store i64 %39, i64* %5
br label %15
40: ; preds = %15
%41 = load i32, i32* %7
%42 = call i32 @mpz_init(i32 %41)
%43 = load i32, i32* %7
%44 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%45 = call i32 @mpz_set_str(i32 %43, i8* %44, i32 10)
%46 = load i32, i32* %2
%47 = load i32, i32* %2
%48 = load i32, i32* %7
%49 = call i32 @mpz_add(i32 %46, i32 %47, i32 %48)
%50 = load i32, i32* %7
%51 = call i32 @mpz_clear(i32 %50)
ret void
}

LLVM IR (-O2):
define void @mpz_rotate_sum(i32 %0) {
%2 = alloca [500 x i8]
%3 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%4 = call i32 @mpz_get_str(i8* %3, i32 10, i32 %0)
%5 = call i32 @strlen(i8* %3)
%6 = add nsw i32 %5, -1
%7 = sext i32 %6 to i64
%8 = lshr i64 %7, 1
%9 = add nuw i64 %8, 1
%10 = and i64 %9, 1
%11 = icmp ult i32 %6, 2
br i1 %11, label %31, label %12
12: ; preds = %1
%13 = and i64 %9, -2
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ 0, %12 ], [ %28, %14 ]
%16 = phi i64 [ 0, %12 ], [ %29, %14 ]
%17 = sub i64 %7, %15
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %15
%21 = load i8, i8* %20
store i8 %21, i8* %18
store i8 %19, i8* %20
%22 = or i64 %15, 1
%23 = sub i64 %7, %22
%24 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %22
%27 = load i8, i8* %26
store i8 %27, i8* %24
store i8 %25, i8* %26
%28 = add nuw i64 %15, 2
%29 = add i64 %16, 2
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %14
31: ; preds = %14, %1
%32 = phi i64 [ 0, %1 ], [ %28, %14 ]
%33 = icmp eq i64 %10, 0
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = sub i64 %7, %32
%36 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %32
%39 = load i8, i8* %38
store i8 %39, i8* %36
store i8 %37, i8* %38
br label %40
40: ; preds = %31, %34
%41 = call i32 @mpz_init(i32 undef)
%42 = call i32 @mpz_set_str(i32 undef, i8* %3, i32 10)
%43 = call i32 @mpz_add(i32 %0, i32 %0, i32 undef)
%44 = call i32 @mpz_clear(i32 undef)
ret void
}