#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ numbwrite(int /*<<< orphan*/ *, long, char);
long rand();
int /*<<< orphan*/ srand(unsigned int);
void matrixmake(char *inputfilename, long c, long n, long m, long k, long h) {
  srand((unsigned int)(c));
  long i;
  long j;
  long l;
  FILE *inputfile;
  inputfile = fopen(inputfilename, "w");
  numbwrite(inputfile, n, ' ');
  numbwrite(inputfile, m, ' ');
  numbwrite(inputfile, h, '\n');
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < h - 1; j++) {
      if (c < 20) {
        if ((i == 0) && (j < n - 1)) {
          numbwrite(inputfile, j + 1, ' ');
        } else {
          numbwrite(inputfile, n - 1, ' ');
        }
      } else if (c % 2 == 0) {
        numbwrite(inputfile, i + 1 + (rand() % (n - i - 1)), ' ');
      } else if ((c % 14 == 7) && (n % h == 0) && (h < n)) {
        numbwrite(inputfile, j * (n / h) + (rand() % (n / h)), ' ');
      } else {
        numbwrite(inputfile, rand() % n, ' ');
      }
      numbwrite(inputfile, rand() % k, ' ');
    }
    numbwrite(inputfile, n - 1, ' ');
    numbwrite(inputfile, 0, '\n');
  }
  fclose(inputfile);
}


x86 assembly (clang, -O0):
<matrixmake>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0x8(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <numbwrite@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jge    140b <matrixmake+0x2bb>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jge    13d2 <matrixmake+0x282>
cmpq   $0x14,-0x10(%rbp)
jge    1263 <matrixmake+0x113>
cmpq   $0x0,-0x38(%rbp)
jne    1248 <matrixmake+0xf8>
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jge    1248 <matrixmake+0xf8>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
add    $0x1,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
jmp    125e <matrixmake+0x10e>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
jmp    1395 <matrixmake+0x245>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    12c1 <matrixmake+0x171>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x18(%rbp),%rcx
sub    -0x38(%rbp),%rcx
sub    $0x1,%rcx
cqto
idiv   %rcx
add    %rdx,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
jmp    1390 <matrixmake+0x240>
mov    -0x10(%rbp),%rax
mov    $0xe,%ecx
cqto
idiv   %rcx
cmp    $0x7,%rdx
jne    135f <matrixmake+0x20f>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x30(%rbp)
cmp    $0x0,%rdx
jne    135f <matrixmake+0x20f>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    135f <matrixmake+0x20f>
mov    -0x50(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rax
cqto
idivq  -0x30(%rbp)
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x78(%rbp),%rsi
mov    -0x70(%rbp),%rdi
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
cqto
idivq  -0x30(%rbp)
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cqto
idiv   %rcx
add    %rdx,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
jmp    138b <matrixmake+0x23b>
mov    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x88(%rbp),%rdi
cqto
idivq  -0x18(%rbp)
mov    %rdx,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
jmp    1390 <matrixmake+0x240>
jmp    1395 <matrixmake+0x245>
mov    -0x50(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x90(%rbp),%rdi
cqto
idivq  -0x28(%rbp)
mov    %rdx,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11ed <matrixmake+0x9d>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <numbwrite@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d0 <matrixmake+0x80>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixmake>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r15
mov    %r8,%r13
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rdi,%rbx
mov    %rsi,0x18(%rsp)
mov    %esi,%edi
call   1040 <srand@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    %rbx,%rdi
mov    %r15,0x20(%rsp)
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <numbwrite@plt>
cmp    $0x2,%rbp
jl     13e0 <matrixmake+0x290>
mov    %rbp,%rsi
add    $0xffffffffffffffff,%rbp
mov    0x18(%rsp),%rdi
mov    %rdi,%rax
shr    %rax
movabs $0x4924924924924925,%rcx
92 24 49
mul    %rcx
shr    %rdx
mov    %rdx,%rax
shl    $0x4,%rax
mov    %rdx,%rcx
sub    %rax,%rcx
add    %rdx,%rcx
add    %rdi,%rcx
mov    %rcx,0x28(%rsp)
xor    %ecx,%ecx
mov    %rsi,0x8(%rsp)
jmp    1244 <matrixmake+0xf4>
nopl   (%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <numbwrite@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rax
mov    %rax,%rcx
cmp    %rbp,%rax
je     13e0 <matrixmake+0x290>
mov    %rcx,0x10(%rsp)
lea    0x1(%rcx),%rax
mov    %rax,(%rsp)
mov    0x20(%rsp),%rcx
cmp    $0x2,%rcx
jl     1210 <matrixmake+0xc0>
mov    0x10(%rsp),%rax
not    %rax
add    %rsi,%rax
mov    %rax,0x30(%rsp)
mov    $0x1,%r14d
jmp    12ac <matrixmake+0x15c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cqto
idiv   %r13
mov    %rdx,%rsi
mov    %rbx,%rdi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
add    $0x1,%r14
mov    0x20(%rsp),%rcx
cmp    %r14,%rcx
mov    0x8(%rsp),%rsi
je     1210 <matrixmake+0xc0>
lea    -0x1(%r14),%r15
mov    0x18(%rsp),%rax
cmp    $0x13,%rax
jg     12e0 <matrixmake+0x190>
cmp    %rbp,%r15
mov    %rbp,%rsi
cmovl  %r14,%rsi
cmpq   $0x0,0x10(%rsp)
cmovne %rbp,%rsi
jmp    13b0 <matrixmake+0x260>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   $0x1,%al
jne    1310 <matrixmake+0x1c0>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rcx
mov    0x30(%rsp),%rsi
or     %rsi,%rcx
shr    $0x20,%rcx
je     1336 <matrixmake+0x1e6>
cqto
idiv   %rsi
mov    %rdx,%rsi
add    (%rsp),%rsi
jmp    13b0 <matrixmake+0x260>
nopl   (%rax)
cmpq   $0x7,0x28(%rsp)
jne    1376 <matrixmake+0x226>
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1342 <matrixmake+0x1f2>
mov    %rsi,%rax
cqto
idiv   %rcx
mov    %rax,%r12
cmp    %rsi,%rcx
jl     1350 <matrixmake+0x200>
jmp    1376 <matrixmake+0x226>
xor    %edx,%edx
div    %esi
mov    %edx,%esi
add    (%rsp),%rsi
jmp    13b0 <matrixmake+0x260>
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%r12d
cmp    %rsi,%rcx
jge    1376 <matrixmake+0x226>
test   %rdx,%rdx
jne    1376 <matrixmake+0x226>
imul   %r12,%r15
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rcx
or     %r12,%rcx
shr    $0x20,%rcx
je     13a0 <matrixmake+0x250>
cqto
idiv   %r12
mov    %rdx,%rsi
jmp    13a7 <matrixmake+0x257>
xor    %eax,%eax
call   1070 <rand@plt>
mov    0x8(%rsp),%rsi
mov    %rax,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     1398 <matrixmake+0x248>
cqto
idiv   %rsi
mov    %rdx,%rsi
jmp    13b0 <matrixmake+0x260>
xor    %edx,%edx
div    %esi
mov    %edx,%esi
jmp    13b0 <matrixmake+0x260>
xor    %edx,%edx
div    %r12d
mov    %edx,%esi
add    %r15,%rsi
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x20,%edx
call   1050 <numbwrite@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rcx
or     %r13,%rcx
shr    $0x20,%rcx
jne    1280 <matrixmake+0x130>
xor    %edx,%edx
div    %r13d
mov    %edx,%esi
jmp    1288 <matrixmake+0x138>
mov    %rbx,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
define void @matrixmake(i8* %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i64 %5, i64* %12
%17 = load i64, i64* %8
%18 = trunc i64 %17 to i32
%19 = call i32 @srand(i32 %18)
%20 = load i8*, i8** %7
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %16
%22 = load i32*, i32** %16
%23 = load i64, i64* %9
%24 = call i32 @numbwrite(i32* %22, i64 %23, i8 signext 32)
%25 = load i32*, i32** %16
%26 = load i64, i64* %10
%27 = call i32 @numbwrite(i32* %25, i64 %26, i8 signext 32)
%28 = load i32*, i32** %16
%29 = load i64, i64* %12
%30 = call i32 @numbwrite(i32* %28, i64 %29, i8 signext 10)
store i64 0, i64* %13
br label %31
31: ; preds = %131, %6
%32 = load i64, i64* %13
%33 = load i64, i64* %9
%34 = sub nsw i64 %33, 1
%35 = icmp slt i64 %32, %34
br i1 %35, label %36, label %134
36: ; preds = %31
store i64 0, i64* %14
br label %37
37: ; preds = %121, %36
%38 = load i64, i64* %14
%39 = load i64, i64* %12
%40 = sub nsw i64 %39, 1
%41 = icmp slt i64 %38, %40
br i1 %41, label %42, label %124
42: ; preds = %37
%43 = load i64, i64* %8
%44 = icmp slt i64 %43, 20
br i1 %44, label %45, label %64
45: ; preds = %42
%46 = load i64, i64* %13
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i64, i64* %14
%50 = load i64, i64* %9
%51 = sub nsw i64 %50, 1
%52 = icmp slt i64 %49, %51
br i1 %52, label %53, label %58
53: ; preds = %48
%54 = load i32*, i32** %16
%55 = load i64, i64* %14
%56 = add nsw i64 %55, 1
%57 = call i32 @numbwrite(i32* %54, i64 %56, i8 signext 32)
br label %63
58: ; preds = %48, %45
%59 = load i32*, i32** %16
%60 = load i64, i64* %9
%61 = sub nsw i64 %60, 1
%62 = call i32 @numbwrite(i32* %59, i64 %61, i8 signext 32)
br label %63
63: ; preds = %58, %53
br label %115
64: ; preds = %42
%65 = load i64, i64* %8
%66 = srem i64 %65, 2
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %80
68: ; preds = %64
%69 = load i32*, i32** %16
%70 = load i64, i64* %13
%71 = add nsw i64 %70, 1
%72 = call i64 (...) @rand()
%73 = load i64, i64* %9
%74 = load i64, i64* %13
%75 = sub nsw i64 %73, %74
%76 = sub nsw i64 %75, 1
%77 = srem i64 %72, %76
%78 = add nsw i64 %71, %77
%79 = call i32 @numbwrite(i32* %69, i64 %78, i8 signext 32)
br label %114
80: ; preds = %64
%81 = load i64, i64* %8
%82 = srem i64 %81, 14
%83 = icmp eq i64 %82, 7
br i1 %83, label %84, label %107
84: ; preds = %80
%85 = load i64, i64* %9
%86 = load i64, i64* %12
%87 = srem i64 %85, %86
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %107
89: ; preds = %84
%90 = load i64, i64* %12
%91 = load i64, i64* %9
%92 = icmp slt i64 %90, %91
br i1 %92, label %93, label %107
93: ; preds = %89
%94 = load i32*, i32** %16
%95 = load i64, i64* %14
%96 = load i64, i64* %9
%97 = load i64, i64* %12
%98 = sdiv i64 %96, %97
%99 = mul nsw i64 %95, %98
%100 = call i64 (...) @rand()
%101 = load i64, i64* %9
%102 = load i64, i64* %12
%103 = sdiv i64 %101, %102
%104 = srem i64 %100, %103
%105 = add nsw i64 %99, %104
%106 = call i32 @numbwrite(i32* %94, i64 %105, i8 signext 32)
br label %113
107: ; preds = %89, %84, %80
%108 = load i32*, i32** %16
%109 = call i64 (...) @rand()
%110 = load i64, i64* %9
%111 = srem i64 %109, %110
%112 = call i32 @numbwrite(i32* %108, i64 %111, i8 signext 32)
br label %113
113: ; preds = %107, %93
br label %114
114: ; preds = %113, %68
br label %115
115: ; preds = %114, %63
%116 = load i32*, i32** %16
%117 = call i64 (...) @rand()
%118 = load i64, i64* %11
%119 = srem i64 %117, %118
%120 = call i32 @numbwrite(i32* %116, i64 %119, i8 signext 32)
br label %121
121: ; preds = %115
%122 = load i64, i64* %14
%123 = add nsw i64 %122, 1
store i64 %123, i64* %14
br label %37
124: ; preds = %37
%125 = load i32*, i32** %16
%126 = load i64, i64* %9
%127 = sub nsw i64 %126, 1
%128 = call i32 @numbwrite(i32* %125, i64 %127, i8 signext 32)
%129 = load i32*, i32** %16
%130 = call i32 @numbwrite(i32* %129, i64 0, i8 signext 10)
br label %131
131: ; preds = %124
%132 = load i64, i64* %13
%133 = add nsw i64 %132, 1
store i64 %133, i64* %13
br label %31
134: ; preds = %31
%135 = load i32*, i32** %16
%136 = call i32 @fclose(i32* %135)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
define void @matrixmake(i8* nocapture %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = trunc i64 %1 to i32
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @numbwrite(i32* %9, i64 %2, i8 signext 32)
%11 = tail call i32 @numbwrite(i32* %9, i64 %3, i8 signext 32)
%12 = tail call i32 @numbwrite(i32* %9, i64 %5, i8 signext 10)
%13 = add i64 %2, -1
%14 = icmp sgt i64 %2, 1
br i1 %14, label %15, label %69
15: ; preds = %6
%16 = add i64 %5, -1
%17 = icmp sgt i64 %5, 1
%18 = icmp slt i64 %1, 20
%19 = and i64 %1, 1
%20 = icmp eq i64 %19, 0
%21 = urem i64 %1, 14
%22 = icmp eq i64 %21, 7
%23 = icmp slt i64 %5, %2
br label %24
24: ; preds = %15, %65
%25 = phi i64 [ 0, %15 ], [ %26, %65 ]
%26 = add nuw nsw i64 %25, 1
br i1 %17, label %27, label %65
27: ; preds = %24
%28 = xor i64 %25, -1
%29 = add i64 %28, %2
%30 = icmp eq i64 %25, 0
br label %31
31: ; preds = %27, %57
%32 = phi i64 [ 0, %27 ], [ %63, %57 ]
br i1 %18, label %33, label %38
33: ; preds = %31
%34 = icmp slt i64 %32, %13
%35 = select i1 %30, i1 %34, i1 false
%36 = add nuw nsw i64 %32, 1
%37 = select i1 %35, i64 %36, i64 %13
br label %57
38: ; preds = %31
br i1 %20, label %39, label %43
39: ; preds = %38
%40 = tail call i64 (...) @rand()
%41 = srem i64 %40, %29
%42 = add nsw i64 %26, %41
br label %57
43: ; preds = %38
br i1 %22, label %44, label %54
44: ; preds = %43
%45 = srem i64 %2, %5
%46 = sdiv i64 %2, %5
%47 = icmp eq i64 %45, 0
%48 = and i1 %23, %47
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = mul nsw i64 %46, %32
%51 = tail call i64 (...) @rand()
%52 = srem i64 %51, %46
%53 = add nsw i64 %52, %50
br label %57
54: ; preds = %44, %43
%55 = tail call i64 (...) @rand()
%56 = srem i64 %55, %2
br label %57
57: ; preds = %33, %39, %54, %49
%58 = phi i64 [ %42, %39 ], [ %56, %54 ], [ %53, %49 ], [ %37, %33 ]
%59 = tail call i32 @numbwrite(i32* %9, i64 %58, i8 signext 32)
%60 = tail call i64 (...) @rand()
%61 = srem i64 %60, %4
%62 = tail call i32 @numbwrite(i32* %9, i64 %61, i8 signext 32)
%63 = add nuw nsw i64 %32, 1
%64 = icmp eq i64 %63, %16
br i1 %64, label %65, label %31
65: ; preds = %57, %24
%66 = tail call i32 @numbwrite(i32* %9, i64 %13, i8 signext 32)
%67 = tail call i32 @numbwrite(i32* %9, i64 0, i8 signext 10)
%68 = icmp eq i64 %26, %13
br i1 %68, label %69, label %24
69: ; preds = %65, %6
%70 = tail call i32 @fclose(i32* %9)
ret void
}