#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 *, unsigned char, int);
int storeData(int data, unsigned char *memory, int last) {
  int count, final = last + 4, aux = 0;
  for (count = last; count < final; count++) {
    memory[count] = data >> (8 * aux);
    printf("STORING %i AT %i POSITION.\n", memory[count], count);
    aux++;
  }
  return final;
}


x86 assembly (clang, -O0):
<storeData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1190 <storeData+0x80>
mov    -0x4(%rbp),%eax
mov    -0x20(%rbp),%ecx
shl    $0x3,%ecx
sar    %cl,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%edx
lea    0xe8f(%rip),%rdi
movzbl %al,%esi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <storeData+0x28>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<storeData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
movslq %edx,%rbx
add    $0x4,%r14d
movslq %r14d,%r12
mov    %bpl,(%rsi,%rbx,1)
movzbl %bpl,%esi
lea    0xec7(%rip),%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
lea    0x1(%rbx),%rdx
cmp    %r12,%rdx
jge    1196 <storeData+0x86>
mov    %ebp,%eax
shr    $0x8,%eax
mov    %al,0x1(%r15,%rbx,1)
movzbl %al,%esi
lea    0xea3(%rip),%r12
mov    %r12,%rdi
call   1030 <printf@plt>
lea    0x2(%rbx),%rdx
mov    %ebp,%eax
shr    $0x10,%eax
mov    %al,0x2(%r15,%rbx,1)
movzbl %al,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
shr    $0x18,%ebp
mov    %bpl,0x3(%r15,%rbx,1)
add    $0x3,%rbx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"STORING %i AT %i POSITION.\0A\00"
define i32 @storeData(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 4
store i32 %11, i32* %8
store i32 0, i32* %9
%12 = load i32, i32* %6
store i32 %12, i32* %7
br label %13
13: ; preds = %36, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = load i32, i32* %4
%19 = load i32, i32* %9
%20 = mul nsw i32 8, %19
%21 = ashr i32 %18, %20
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %7
%33 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %31, i32 %32)
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %36
36: ; preds = %17
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %13
39: ; preds = %13
%40 = load i32, i32* %8
ret i32 %40
}

LLVM IR (-O2):
@.str = [28 x i8] c"STORING %i AT %i POSITION.\0A\00"
define i32 @storeData(i32 %0, i8* nocapture writeonly %1, i32 %2) {
%4 = add nsw i32 %2, 4
%5 = sext i32 %2 to i64
%6 = sext i32 %4 to i64
%7 = trunc i32 %0 to i8
%8 = getelementptr inbounds i8, i8* %1, i64 %5
store i8 %7, i8* %8
%9 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %7, i32 %2)
%10 = add nsw i64 %5, 1
%11 = icmp slt i64 %10, %6
br i1 %11, label %12, label %30
12: ; preds = %3
%13 = lshr i32 %0, 8
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 %14, i8* %15
%16 = trunc i64 %10 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %14, i32 %16)
%18 = add nsw i64 %5, 2
%19 = lshr i32 %0, 16
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 %20, i8* %21
%22 = trunc i64 %18 to i32
%23 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %20, i32 %22)
%24 = add nsw i64 %5, 3
%25 = lshr i32 %0, 24
%26 = trunc i32 %25 to i8
%27 = getelementptr inbounds i8, i8* %1, i64 %24
store i8 %26, i8* %27
%28 = trunc i64 %24 to i32
%29 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %26, i32 %28)
br label %30
30: ; preds = %12, %3
ret i32 %4
}