#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*/ scanf(char *, int *);
void rotr(int *a, int *b, int *c) {
  int swap, counter, amount;
  scanf("%d", &amount);
  for (counter = 0; counter < amount; counter++) {
    swap = *a;
    *a = *c;
    *c = *b;
    *b = swap;
  }
}


x86 assembly (clang, -O0):
<rotr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed5(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <scanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    117f <rotr+0x6f>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113b <rotr+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1189 <rotr+0x79>
cmp    $0x1,%eax
je     1175 <rotr+0x65>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%edx
mov    (%r14),%esi
mov    %esi,(%rbx)
mov    (%r15),%esi
mov    %esi,(%r14)
mov    %edx,(%r15)
mov    (%rbx),%edx
mov    (%r14),%esi
mov    %esi,(%rbx)
mov    (%r15),%esi
mov    %esi,(%r14)
mov    %edx,(%r15)
add    $0xfffffffe,%ecx
jne    1150 <rotr+0x40>
test   $0x1,%al
je     1189 <rotr+0x79>
mov    (%rbx),%eax
mov    (%r14),%ecx
mov    %ecx,(%rbx)
mov    (%r15),%ecx
mov    %ecx,(%r14)
mov    %eax,(%r15)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @rotr(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
store i32 0, i32* %8
br label %11
11: ; preds = %26, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %9
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
store i32 %17, i32* %7
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = load i32*, i32** %4
store i32 %19, i32* %20
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = load i32*, i32** %6
store i32 %22, i32* %23
%24 = load i32, i32* %7
%25 = load i32*, i32** %5
store i32 %24, i32* %25
br label %26
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %11
29: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @rotr(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %3
%10 = and i32 %7, 1
%11 = icmp eq i32 %7, 1
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = and i32 %7, -2
br label %14
14: ; preds = %14, %12
%15 = phi i32 [ 0, %12 ], [ %22, %14 ]
%16 = load i32, i32* %0
%17 = load i32, i32* %2
store i32 %17, i32* %0
%18 = load i32, i32* %1
store i32 %18, i32* %2
store i32 %16, i32* %1
%19 = load i32, i32* %0
%20 = load i32, i32* %2
store i32 %20, i32* %0
%21 = load i32, i32* %1
store i32 %21, i32* %2
store i32 %19, i32* %1
%22 = add i32 %15, 2
%23 = icmp eq i32 %22, %13
br i1 %23, label %24, label %14
24: ; preds = %14, %9
%25 = icmp eq i32 %10, 0
br i1 %25, label %30, label %26
26: ; preds = %24
%27 = load i32, i32* %0
%28 = load i32, i32* %2
store i32 %28, i32* %0
%29 = load i32, i32* %1
store i32 %29, i32* %2
store i32 %27, i32* %1
br label %30
30: ; preds = %26, %24, %3
ret void
}