#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*/ kill_time(int);
int /*<<< orphan*/ printf(char *, ...);
void write_frame_basic(unsigned char write_field[]) {
  int i = 0;
  printf("************************************\n");
  printf("******** write frame basic *********\n");
  printf("************************************\n");
  for (i = 0; i < 10; i++) {
    *((unsigned char *)(0xfffc000A + i)) = write_field[i];
    kill_time(10);
    printf("write data: %i , 0x%X , 0x%X \n", i, write_field[i],
           *((unsigned char *)(0xfffc000A + i)));
  }
}


x86 assembly (clang, -O0):
<write_frame_basic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11c7 <write_frame_basic+0xa7>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0xc(%rbp),%eax
add    $0xfffc000a,%eax
mov    %eax,%eax
mov    %cl,(%rax)
mov    $0xa,%edi
call   1030 <kill_time@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0xc(%rbp),%eax
add    $0xfffc000a,%eax
mov    %eax,%eax
movzbl (%rax),%ecx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <write_frame_basic+0x44>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_frame_basic>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xf05(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%rbx),%al
mov    $0xfffc000a,%r15d
mov    %al,(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl (%rbx),%edx
movzbl (%r15),%ecx
lea    0xe82(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1(%rbx),%al
mov    %al,0x1(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x1(%rbx),%edx
movzbl 0x1(%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2(%rbx),%al
mov    %al,0x2(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x2(%rbx),%edx
movzbl 0x2(%r15),%ecx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3(%rbx),%al
mov    %al,0x3(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x3(%rbx),%edx
movzbl 0x3(%r15),%ecx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%al
mov    %al,0x4(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x4(%rbx),%edx
movzbl 0x4(%r15),%ecx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x5(%rbx),%al
mov    %al,0x5(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x5(%rbx),%edx
movzbl 0x5(%r15),%ecx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x6(%rbx),%al
mov    %al,0x6(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x6(%rbx),%edx
movzbl 0x6(%r15),%ecx
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x7(%rbx),%al
mov    %al,0x7(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x7(%rbx),%edx
movzbl 0x7(%r15),%ecx
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%al
mov    %al,0x8(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x8(%rbx),%edx
movzbl 0x8(%r15),%ecx
mov    %r14,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x9(%rbx),%al
mov    %al,0x9(%r15)
mov    $0xa,%edi
call   1030 <kill_time@plt>
movzbl 0x9(%rbx),%edx
movzbl 0x9(%r15),%ecx
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

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

LLVM IR (-O2):
@.str.2 = [31 x i8] c"write data: %i , 0x%X , 0x%X \0A\00"
@str.3 = [37 x i8] c"******** write frame basic *********\00"
@str.4 = [37 x i8] c"************************************\00"
define void @write_frame_basic(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
%5 = load i8, i8* %0
store i8 %5, i8* inttoptr (i64 4294705162 to i8*)
%6 = tail call i32 @kill_time(i32 10)
%7 = load i8, i8* %0
%8 = zext i8 %7 to i32
%9 = load i8, i8* inttoptr (i64 4294705162 to i8*)
%10 = zext i8 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %8, i32 %10)
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
store i8 %13, i8* inttoptr (i64 4294705163 to i8*)
%14 = tail call i32 @kill_time(i32 10)
%15 = load i8, i8* %12
%16 = zext i8 %15 to i32
%17 = load i8, i8* inttoptr (i64 4294705163 to i8*)
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %16, i32 %18)
%20 = getelementptr inbounds i8, i8* %0, i64 2
%21 = load i8, i8* %20
store i8 %21, i8* inttoptr (i64 4294705164 to i8*)
%22 = tail call i32 @kill_time(i32 10)
%23 = load i8, i8* %20
%24 = zext i8 %23 to i32
%25 = load i8, i8* inttoptr (i64 4294705164 to i8*)
%26 = zext i8 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %24, i32 %26)
%28 = getelementptr inbounds i8, i8* %0, i64 3
%29 = load i8, i8* %28
store i8 %29, i8* inttoptr (i64 4294705165 to i8*)
%30 = tail call i32 @kill_time(i32 10)
%31 = load i8, i8* %28
%32 = zext i8 %31 to i32
%33 = load i8, i8* inttoptr (i64 4294705165 to i8*)
%34 = zext i8 %33 to i32
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %32, i32 %34)
%36 = getelementptr inbounds i8, i8* %0, i64 4
%37 = load i8, i8* %36
store i8 %37, i8* inttoptr (i64 4294705166 to i8*)
%38 = tail call i32 @kill_time(i32 10)
%39 = load i8, i8* %36
%40 = zext i8 %39 to i32
%41 = load i8, i8* inttoptr (i64 4294705166 to i8*)
%42 = zext i8 %41 to i32
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %40, i32 %42)
%44 = getelementptr inbounds i8, i8* %0, i64 5
%45 = load i8, i8* %44
store i8 %45, i8* inttoptr (i64 4294705167 to i8*)
%46 = tail call i32 @kill_time(i32 10)
%47 = load i8, i8* %44
%48 = zext i8 %47 to i32
%49 = load i8, i8* inttoptr (i64 4294705167 to i8*)
%50 = zext i8 %49 to i32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 %48, i32 %50)
%52 = getelementptr inbounds i8, i8* %0, i64 6
%53 = load i8, i8* %52
store i8 %53, i8* inttoptr (i64 4294705168 to i8*)
%54 = tail call i32 @kill_time(i32 10)
%55 = load i8, i8* %52
%56 = zext i8 %55 to i32
%57 = load i8, i8* inttoptr (i64 4294705168 to i8*)
%58 = zext i8 %57 to i32
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 %56, i32 %58)
%60 = getelementptr inbounds i8, i8* %0, i64 7
%61 = load i8, i8* %60
store i8 %61, i8* inttoptr (i64 4294705169 to i8*)
%62 = tail call i32 @kill_time(i32 10)
%63 = load i8, i8* %60
%64 = zext i8 %63 to i32
%65 = load i8, i8* inttoptr (i64 4294705169 to i8*)
%66 = zext i8 %65 to i32
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 7, i32 %64, i32 %66)
%68 = getelementptr inbounds i8, i8* %0, i64 8
%69 = load i8, i8* %68
store i8 %69, i8* inttoptr (i64 4294705170 to i8*)
%70 = tail call i32 @kill_time(i32 10)
%71 = load i8, i8* %68
%72 = zext i8 %71 to i32
%73 = load i8, i8* inttoptr (i64 4294705170 to i8*)
%74 = zext i8 %73 to i32
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 8, i32 %72, i32 %74)
%76 = getelementptr inbounds i8, i8* %0, i64 9
%77 = load i8, i8* %76
store i8 %77, i8* inttoptr (i64 4294705171 to i8*)
%78 = tail call i32 @kill_time(i32 10)
%79 = load i8, i8* %76
%80 = zext i8 %79 to i32
%81 = load i8, i8* inttoptr (i64 4294705171 to i8*)
%82 = zext i8 %81 to i32
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 9, i32 %80, i32 %82)
ret void
}