#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 *, ...);
void dump_field(const char *f, int size) {
  int i;
  for (i = 0; i < (size * size); i++) {
    if ((i % size) == 0)
      printf("\n");
    printf("%c", f[i] ? 'X' : '.');
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    118e <dump_field+0x7e>
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1156 <dump_field+0x46>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x2e,%esi
mov    $0x58,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <dump_field+0x16>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_field>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%eax
imul   %esi,%eax
test   %eax,%eax
je     1172 <dump_field+0x62>
mov    %esi,%r15d
mov    %rdi,%r14
mov    %eax,%ebp
xor    %ebx,%ebx
mov    $0x2e,%r12d
jmp    115c <dump_field+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,(%r14,%rbx,1)
mov    $0x58,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1172 <dump_field+0x62>
mov    %ebx,%eax
cltd
idiv   %r15d
test   %edx,%edx
jne    1140 <dump_field+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1140 <dump_field+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @dump_field(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %30, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = mul nsw i32 %8, %9
%11 = icmp slt i32 %7, %10
br i1 %11, label %12, label %33
12: ; preds = %6
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = srem i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 88, i32 46
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %19
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %6
33: ; preds = %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @dump_field(i8* nocapture %0, i32 %1) {
%3 = mul i32 %1, %1
%4 = icmp eq i32 %3, 0
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = zext i32 %3 to i64
br label %7
7: ; preds = %5, %14
%8 = phi i64 [ 0, %5 ], [ %20, %14 ]
%9 = trunc i64 %8 to i32
%10 = srem i32 %9, %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @putchar(i32 10)
br label %14
14: ; preds = %12, %7
%15 = getelementptr inbounds i8, i8* %0, i64 %8
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
%18 = select i1 %17, i32 46, i32 88
%19 = tail call i32 @putchar(i32 %18)
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %14, %2
%23 = tail call i32 @putchar(i32 10)
ret void
}