#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*/ map;

/* Variables and functions */
int /*<<< orphan*/ memset(int **, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main() {
  int i, j;
  int map[128][128];
  memset(map, 0, sizeof(map));
  for (i = 0; i < 1000; i++) {
    map[rand() % 128][rand() % 128] = 1;
  }
  printf("P1\n%d %d\n", 128, 128);
  for (i = 0; i < 128; i++) {
    for (j = 0; j < 128; j++) {
      printf("%d", map[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10010(%rbp),%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1040 <memset@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    11be <main+0x8e>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x80,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    -0x10010(%rbp),%rax
shl    $0x9,%rcx
add    %rcx,%rax
mov    %rax,-0x10018(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    -0x10018(%rbp),%rax
movslq %edx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115c <main+0x2c>
lea    0xe3b(%rip),%rdi
mov    $0x80,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x80,-0x8(%rbp)
jge    124c <main+0x11c>
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    1230 <main+0x100>
movslq -0x8(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x9,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ee <main+0xbe>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11da <main+0xaa>
xor    %eax,%eax
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x10008,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1050 <memset@plt>
mov    $0x3e8,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x7f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff80,%ecx
sub    %ecx,%eax
movslq %eax,%rbp
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x7f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff80,%ecx
sub    %ecx,%eax
cltq
shl    $0x9,%rbp
lea    (%rsp,%rbp,1),%rcx
movl   $0x1,(%rcx,%rax,4)
add    $0xffffffff,%r14d
jne    1170 <main+0x30>
lea    0xe47(%rip),%rdi
mov    $0x80,%esi
mov    $0x80,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe39(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x80,%rbp
jne    11f0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x200,%rbx
cmp    $0x80,%r15
jne    11e0 <main+0xa0>
xor    %eax,%eax
add    $0x10008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"P1\0A%d %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [128 x [128 x i32]]
store i32 0, i32* %1
%5 = getelementptr inbounds [128 x [128 x i32]], [128 x [128 x i32]]* %4, i64 0, i64 0
%6 = bitcast [128 x i32]* %5 to i32**
%7 = call i32 @memset(i32** %6, i32 0, i32 65536)
store i32 0, i32* %2
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 128
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [128 x [128 x i32]], [128 x [128 x i32]]* %4, i64 0, i64 %14
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 128
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [128 x i32], [128 x i32]* %15, i64 0, i64 %18
store i32 1, i32* %19
br label %20
20: ; preds = %11
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %8
23: ; preds = %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 128, i32 128)
store i32 0, i32* %2
br label %25
25: ; preds = %46, %23
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 128
br i1 %27, label %28, label %49
28: ; preds = %25
store i32 0, i32* %3
br label %29
29: ; preds = %41, %28
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 128
br i1 %31, label %32, label %44
32: ; preds = %29
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [128 x [128 x i32]], [128 x [128 x i32]]* %4, i64 0, i64 %34
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [128 x i32], [128 x i32]* %35, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %32
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %29
44: ; preds = %29
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %25
49: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"P1\0A%d %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [128 x [128 x i32]]
%2 = bitcast [128 x [128 x i32]]* %1 to i8*
%3 = bitcast [128 x [128 x i32]]* %1 to i32**
%4 = call i32 @memset(i32** %3, i32 0, i32 65536)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %14, %5 ]
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 128
%9 = sext i32 %8 to i64
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 128
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [128 x [128 x i32]], [128 x [128 x i32]]* %1, i64 0, i64 %9, i64 %12
store i32 1, i32* %13
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 1000
br i1 %15, label %16, label %5
16: ; preds = %5
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 128, i32 128)
br label %18
18: ; preds = %16, %27
%19 = phi i64 [ 0, %16 ], [ %29, %27 ]
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %25, %20 ]
%22 = getelementptr inbounds [128 x [128 x i32]], [128 x [128 x i32]]* %1, i64 0, i64 %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, 128
br i1 %26, label %27, label %20
27: ; preds = %20
%28 = call i32 @putchar(i32 10)
%29 = add nuw nsw i64 %19, 1
%30 = icmp eq i64 %29, 128
br i1 %30, label %31, label %18
31: ; preds = %27
ret i32 0
}