#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*/ free(unsigned char *);
unsigned char *malloc(int);
void rotWord(unsigned char *word) {
  int i;
  unsigned char *c = malloc(sizeof(unsigned char) * 4);
  for (i = 0; i < 4; i++)
    c[i] = word[(i + 1) % 4];
  for (i = 0; i < 4; i++)
    word[i] = c[i];
  free(c);
}


x86 assembly (clang, -O0):
<rotWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1184 <rotWord+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1141 <rotWord+0x21>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11b9 <rotWord+0x99>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <rotWord+0x6b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotWord>:
push   %rbx
mov    %rdi,%rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    0x1(%rbx),%cl
mov    %cl,(%rax)
mov    0x2(%rbx),%cl
mov    %cl,0x1(%rax)
mov    0x3(%rbx),%cl
mov    %cl,0x2(%rax)
mov    (%rbx),%cl
mov    %cl,0x3(%rax)
mov    (%rax),%ecx
mov    %ecx,(%rbx)
mov    %rax,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @rotWord(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i8* @malloc(i32 4)
store i8* %5, i8** %4
store i32 0, i32* %3
br label %6
6: ; preds = %21, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
%13 = srem i32 %12, 4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = load i8, i8* %15
%17 = load i8*, i8** %4
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %9
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %6
24: ; preds = %6
store i32 0, i32* %3
br label %25
25: ; preds = %38, %24
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i8*, i8** %4
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 %33, i8* %37
br label %38
38: ; preds = %28
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %25
41: ; preds = %25
%42 = load i8*, i8** %4
%43 = call i32 @free(i8* %42)
ret void
}

LLVM IR (-O2):
define void @rotWord(i8* nocapture %0) {
%2 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
store i8 %4, i8* %2
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %6, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 3
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %2, i64 2
store i8 %9, i8* %10
%11 = load i8, i8* %0
%12 = getelementptr inbounds i8, i8* %2, i64 3
store i8 %11, i8* %12
%13 = bitcast i8* %2 to i32*
%14 = bitcast i8* %0 to i32*
%15 = load i32, i32* %13
store i32 %15, i32* %14
%16 = tail call i32 @free(i8* %2)
ret void
}