#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  FILE *file;
  int r;
  int c;
  int row = 0, col = 0;
  if (argc != 4) {
    fputs("usage: [rows] [columns] [file name]\n", stderr);
    exit(EXIT_FAILURE);
  }
  r = (int)strtol(argv[1], NULL, 10);
  c = (int)strtol(argv[2], NULL, 10);
  file = fopen(argv[3], "w");
  if (file == NULL) {
    fputs("initial_condition", stderr);
    fputs(" could not be opened.\n", stderr);
    exit(EXIT_FAILURE);
  }
  srand(time(0));
  for (row = 0; row < r; row++) {
    for (col = 0; col < c; col++) {
      if (rand() % 2 == 0)
        fputc('0', file);
      else
        fputc('1', file);
    }
  }
  fclose(file);
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11e1 <main+0x51>
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
lea    0xe32(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    126e <main+0xde>
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
lea    0xde1(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
lea    0xdde(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1301 <main+0x171>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12ee <main+0x15e>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12cd <main+0x13d>
mov    -0x18(%rbp),%rsi
mov    $0x30,%edi
call   1050 <fputc@plt>
jmp    12db <main+0x14b>
mov    -0x18(%rbp),%rsi
mov    $0x31,%edi
call   1050 <fputc@plt>
jmp    12e0 <main+0x150>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1296 <main+0x106>
jmp    12f3 <main+0x163>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1283 <main+0xf3>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    1256 <main+0xc6>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1268 <main+0xd8>
mov    %rax,%rbx
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
test   %r14d,%r14d
jle    123c <main+0xac>
xor    %r12d,%r12d
jmp    1209 <main+0x79>
xchg   %ax,%ax
add    $0x1,%r12d
cmp    %r14d,%r12d
je     123c <main+0xac>
test   %r15d,%r15d
jle    1200 <main+0x70>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <rand@plt>
and    $0x1,%eax
lea    0x30(%rax),%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%ebp
jne    1220 <main+0x90>
jmp    1200 <main+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
lea    0xd9a(%rip),%rdi
jmp    1286 <main+0xf6>
mov    0x2d71(%rip),%rbx
mov    (%rbx),%esi
lea    0xdaf(%rip),%rdi
call   1040 <fputs@plt>
mov    (%rbx),%esi
lea    0xdb3(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"usage: [rows] [columns] [file name]\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [18 x i8] c"initial_condition\00"
@.str.3 = [23 x i8] c" could not be opened.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strtol(i8* %21, i32* null, i32 10)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @strtol(i8* %26, i32* null, i32 10)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %8
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %6
%33 = load i32*, i32** %6
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %42
35: ; preds = %18
%36 = load i32, i32* @stderr
%37 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* @stderr
%39 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %18
%43 = call i32 @time(i32 0)
%44 = call i32 @srand(i32 %43)
store i32 0, i32* %9
br label %45
45: ; preds = %69, %42
%46 = load i32, i32* %9
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %72
49: ; preds = %45
store i32 0, i32* %10
br label %50
50: ; preds = %65, %49
%51 = load i32, i32* %10
%52 = load i32, i32* %8
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %68
54: ; preds = %50
%55 = call i32 (...) @rand()
%56 = srem i32 %55, 2
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i32*, i32** %6
%60 = call i32 @fputc(i8 signext 48, i32* %59)
br label %64
61: ; preds = %54
%62 = load i32*, i32** %6
%63 = call i32 @fputc(i8 signext 49, i32* %62)
br label %64
64: ; preds = %61, %58
br label %65
65: ; preds = %64
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %50
68: ; preds = %50
br label %69
69: ; preds = %68
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %45
72: ; preds = %45
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* @EXIT_SUCCESS
ret i32 %75
}

LLVM IR (-O2):
@.str = [37 x i8] c"usage: [rows] [columns] [file name]\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [18 x i8] c"initial_condition\00"
@.str.3 = [23 x i8] c" could not be opened.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 10)
%13 = trunc i64 %12 to i32
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i64 @strtol(i8* nocapture %15, i32* null, i32 10)
%17 = trunc i64 %16 to i32
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %29
22: ; preds = %9
%23 = load i32, i32* @stderr
%24 = tail call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %9
%30 = tail call i32 @time(i32 0)
%31 = tail call i32 @srand(i32 %30)
%32 = icmp sgt i32 %13, 0
br i1 %32, label %33, label %49
33: ; preds = %29
%34 = icmp sgt i32 %17, 0
br label %35
35: ; preds = %33, %46
%36 = phi i32 [ 0, %33 ], [ %47, %46 ]
br i1 %34, label %37, label %46
37: ; preds = %35, %37
%38 = phi i32 [ %44, %37 ], [ 0, %35 ]
%39 = tail call i32 (...) @rand()
%40 = and i32 %39, 1
%41 = icmp eq i32 %40, 0
%42 = select i1 %41, i8 48, i8 49
%43 = tail call i32 @fputc(i8 signext %42, i32* %20)
%44 = add nuw nsw i32 %38, 1
%45 = icmp eq i32 %44, %17
br i1 %45, label %46, label %37
46: ; preds = %37, %35
%47 = add nuw nsw i32 %36, 1
%48 = icmp eq i32 %47, %13
br i1 %48, label %49, label %35
49: ; preds = %46, %29
%50 = tail call i32 @fclose(i32* %20)
%51 = load i32, i32* @EXIT_SUCCESS
ret i32 %51
}