#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int);
void output_const_array(FILE *file, int id, int val) {
  int x, y;
  for (x = 0; x < 800; x++) {
    for (y = 0; y < 800; y++) {
      fprintf(file, "%4d,%4d,%4d,%4d\n", id, x, y, val);
    }
  }
}


x86 assembly (clang, -O0):
<output_const_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x320,-0x14(%rbp)
jge    1189 <output_const_array+0x79>
movl   $0x0,-0x18(%rbp)
cmpl   $0x320,-0x18(%rbp)
jge    1176 <output_const_array+0x66>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe9d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <output_const_array+0x2d>
jmp    117b <output_const_array+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <output_const_array+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_const_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r13
xor    %ebp,%ebp
lea    0xed3(%rip),%r12
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
call   1030 <fprintf@plt>
add    $0x1,%ebx
cmp    $0x320,%ebx
jne    1140 <output_const_array+0x30>
add    $0x1,%ebp
cmp    $0x320,%ebp
jne    1130 <output_const_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%4d,%4d,%4d,%4d\0A\00"
define void @output_const_array(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %27, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 800
br i1 %11, label %12, label %30
12: ; preds = %9
store i32 0, i32* %8
br label %13
13: ; preds = %23, %12
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 800
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %13
26: ; preds = %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %9
30: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"%4d,%4d,%4d,%4d\0A\00"
define void @output_const_array(i32* nocapture %0, i32 %1, i32 %2) {
br label %4
4: ; preds = %3, %11
%5 = phi i32 [ 0, %3 ], [ %12, %11 ]
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ 0, %4 ], [ %9, %6 ]
%8 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %5, i32 %7, i32 %2)
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, 800
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 800
br i1 %13, label %14, label %4
14: ; preds = %11
ret void
}