#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*/ do_fxsave(unsigned char *);
scalar_t__ isFPLsbs(int);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int i, j;
  unsigned char *buf = malloc(512);
  int xx = 1;
  for (i = 0; i < 512; i++)
    buf[i] = 0x55;
  do_fxsave(buf);
  for (j = 0; j < 512; j++) {
    i = (j & 0xFFF0) + (15 - (j & 0xF));
    if ((j % 16) == 0)
      printf("%3d   ", j);
    if (xx && isFPLsbs(i))
      printf("xx ");
    else
      printf("%02x ", buf[i]);
    if (j > 0 && ((j % 16) == 15))
      printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jge    1199 <main+0x59>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x55,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <main+0x32>
mov    -0x20(%rbp),%rdi
call   1060 <do_fxsave@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x200,-0x18(%rbp)
jge    127d <main+0x13d>
mov    -0x18(%rbp),%eax
and    $0xfff0,%eax
mov    -0x18(%rbp),%edx
and    $0xf,%edx
mov    $0xf,%ecx
sub    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f5 <main+0xb5>
mov    -0x18(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1224 <main+0xe4>
mov    -0x14(%rbp),%edi
call   1030 <isFPLsbs@plt>
cmp    $0x0,%rax
je     1224 <main+0xe4>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123e <main+0xfe>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jle    126a <main+0x12a>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    126a <main+0x12a>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126f <main+0x12f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a9 <main+0x69>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x200,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    $0x200,%edx
mov    %rax,%rdi
mov    $0x55,%esi
call   1060 <memset@plt>
mov    %r13,%rdi
call   1080 <do_fxsave@plt>
lea    0xe72(%rip),%r15
lea    0xe67(%rip),%r12
xor    %ebp,%ebp
jmp    11bb <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x200,%ebp
je     1222 <main+0xc2>
mov    %ebp,%ebx
xor    $0xf,%rbx
mov    %ebp,%r14d
and    $0xf,%r14d
jne    11da <main+0x7a>
lea    0xe2f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1040 <isFPLsbs@plt>
test   %rax,%rax
je     1200 <main+0xa0>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xf,%r14d
jne    11b0 <main+0x50>
jmp    1216 <main+0xb6>
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xf,%r14d
jne    11b0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%3d \00"
@.str.1 = [4 x i8] c"xx \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @malloc(i32 512)
store i8* %10, i8** %8
store i32 1, i32* %9
store i32 0, i32* %6
br label %11
11: ; preds = %19, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 512
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8*, i8** %8
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 85, i8* %18
br label %19
19: ; preds = %14
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %11
22: ; preds = %11
%23 = load i8*, i8** %8
%24 = call i32 @do_fxsave(i8* %23)
store i32 0, i32* %7
br label %25
25: ; preds = %68, %22
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 512
br i1 %27, label %28, label %71
28: ; preds = %25
%29 = load i32, i32* %7
%30 = and i32 %29, 65520
%31 = load i32, i32* %7
%32 = and i32 %31, 15
%33 = sub nsw i32 15, %32
%34 = add nsw i32 %30, %33
store i32 %34, i32* %6
%35 = load i32, i32* %7
%36 = srem i32 %35, 16
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %28
%39 = load i32, i32* %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38, %28
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* %6
%46 = call i64 @isFPLsbs(i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %58
50: ; preds = %44, %41
%51 = load i8*, i8** %8
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %50, %48
%59 = load i32, i32* %7
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %67
61: ; preds = %58
%62 = load i32, i32* %7
%63 = srem i32 %62, 16
%64 = icmp eq i32 %63, 15
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %61, %58
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %25
71: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%3d \00"
@.str.1 = [4 x i8] c"xx \00"
@.str.2 = [6 x i8] c"%02x \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%4 = tail call i32 @do_fxsave(i8* %3)
br label %5
5: ; preds = %2, %27
%6 = phi i32 [ 0, %2 ], [ %28, %27 ]
%7 = xor i32 %6, 15
%8 = and i32 %6, 15
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %12
12: ; preds = %5, %10
%13 = tail call i64 @isFPLsbs(i32 %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %23
17: ; preds = %12
%18 = zext i32 %7 to i64
%19 = getelementptr inbounds i8, i8* %3, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %17, %15
%24 = icmp eq i32 %8, 15
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @putchar(i32 10)
br label %27
27: ; preds = %23, %25
%28 = add nuw nsw i32 %6, 1
%29 = icmp eq i32 %28, 512
br i1 %29, label %30, label %5
30: ; preds = %27
ret i32 0
}