#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 clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
int clock();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ show(int **, int);
int /*<<< orphan*/ srand(int);
int generator(int **input, int size) {
  clock_t timec;
  int i, j;
  for (i = 0; i < size; i++)
    input[i] = (int *)malloc(size * sizeof(int));
  srand(timec);
  for (i = 0; i < size; i++) {
    timec = clock();
    for (j = 0; j < size; j++) {
      timec = (int)((clock() - timec) / CLOCKS_PER_SEC);
      input[i][j] = rand() % 2;
    }
    input[i][i] = 1;
  }
  show(input, size);
  printf("mission completed\n");
  return 0;
}


x86 assembly (clang, -O0):
<generator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ae <generator+0x4e>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <generator+0x16>
mov    -0x10(%rbp),%edi
call   1060 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1252 <generator+0xf2>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122d <generator+0xcd>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x10(%rbp),%eax
mov    0x2df1(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11da <generator+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <generator+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <show@plt>
lea    0xd9b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generator>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r12
test   %esi,%esi
jle    120c <generator+0xac>
lea    0x0(,%r14,4),%r15d
mov    %r14d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <generator+0x30>
call   1060 <srand@plt>
test   %r14d,%r14d
jle    1211 <generator+0xb1>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <clock@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <clock@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    (%r12,%rbx,8),%rcx
mov    %eax,(%rcx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11d0 <generator+0x70>
movl   $0x1,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    %r13,%rbx
jne    11c0 <generator+0x60>
jmp    1211 <generator+0xb1>
call   1060 <srand@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <show@plt>
lea    0xddd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i32 0
@str = [18 x i8] c"mission completed\00"
define i32 @generator(i32** %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @srand(i32 undef)
br label %37
6: ; preds = %2
%7 = shl i32 %1, 2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %14, %9 ]
%11 = tail call i64 @malloc(i32 %7)
%12 = inttoptr i64 %11 to i32*
%13 = getelementptr inbounds i32*, i32** %0, i64 %10
store i32* %12, i32** %13
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9
%17 = tail call i32 @srand(i32 undef)
br i1 %3, label %18, label %37
18: ; preds = %16
%19 = zext i32 %1 to i64
br label %20
20: ; preds = %33, %18
%21 = phi i64 [ 0, %18 ], [ %35, %33 ]
%22 = tail call i32 (...) @clock()
%23 = getelementptr inbounds i32*, i32** %0, i64 %21
br label %24
24: ; preds = %20, %24
%25 = phi i64 [ 0, %20 ], [ %31, %24 ]
%26 = tail call i32 (...) @clock()
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 2
%29 = load i32*, i32** %23
%30 = getelementptr inbounds i32, i32* %29, i64 %25
store i32 %28, i32* %30
%31 = add nuw nsw i64 %25, 1
%32 = icmp eq i64 %31, %19
br i1 %32, label %33, label %24
33: ; preds = %24
%34 = getelementptr inbounds i32, i32* %29, i64 %21
store i32 1, i32* %34
%35 = add nuw nsw i64 %21, 1
%36 = icmp eq i64 %35, %19
br i1 %36, label %37, label %20
37: ; preds = %33, %4, %16
%38 = tail call i32 @show(i32** %0, i32 %1)
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
ret i32 0
}