#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int rand();
void main() {
  int i, j;
  FILE *fp;
  fp = fopen("jacobi_data.h", "wb");
  fprintf(fp, "\nstatic const float a[128][128] = {\n");
  for (i = 0; i < 128; i++) {
    fprintf(fp, "{");
    for (j = 0; j < 128; j++) {
      fprintf(fp, "%f, ", (float)(rand() % 1000));
    }
    fprintf(fp, "},");
    fprintf(fp, "\n");
  }
  fprintf(fp, "};\n\n");
  fprintf(fp, "\nstatic const float d[128] = {\n");
  for (i = 0; i < 128; i++) {
    fprintf(fp, "%f, ", (float)(rand() % 1000));
    fprintf(fp, "\n");
  }
  fprintf(fp, "};");
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    121c <main+0xdc>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x80,-0x8(%rbp)
jge    11ea <main+0xaa>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe63(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119e <main+0x5e>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1178 <main+0x38>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    12a5 <main+0x165>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x20(%rbp),%rdi
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdba(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1247 <main+0x107>
mov    -0x10(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe91(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe8c(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xe98(%rip),%r14
lea    0xe96(%rip),%r15
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    $0x7b,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x70>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12d
cmp    $0x80,%r12d
jne    11b0 <main+0x50>
lea    0xdf2(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xdde(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    $0x80,%ebp
lea    0xdb3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0xffffffff,%ebp
jne    1290 <main+0x130>
lea    0xd7d(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"jacobi_data.h\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [37 x i8] c"\0Astatic const float a[128][128] = {\0A\00"
@.str.3 = [2 x i8] c"{\00"
@.str.4 = [5 x i8] c"%f, \00"
@.str.5 = [3 x i8] c"},\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [5 x i8] c"};\0A\0A\00"
@.str.8 = [32 x i8] c"\0Astatic const float d[128] = {\0A\00"
@.str.9 = [3 x i8] c"};\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 128
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %13
13: ; preds = %23, %10
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 128
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 1000
%20 = sitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %13
26: ; preds = %13
%27 = load i32*, i32** %3
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32*, i32** %3
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %26
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %7
34: ; preds = %7
%35 = load i32*, i32** %3
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%37 = load i32*, i32** %3
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %39
39: ; preds = %51, %34
%40 = load i32, i32* %1
%41 = icmp slt i32 %40, 128
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = load i32*, i32** %3
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 1000
%46 = sitofp i32 %45 to float
%47 = fpext float %46 to double
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %47)
%49 = load i32*, i32** %3
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %51
51: ; preds = %42
%52 = load i32, i32* %1
%53 = add nsw i32 %52, 1
store i32 %53, i32* %1
br label %39
54: ; preds = %39
%55 = load i32*, i32** %3
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%57 = load i32*, i32** %3
%58 = call i32 @fclose(i32* %57)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"jacobi_data.h\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [37 x i8] c"\0Astatic const float a[128][128] = {\0A\00"
@.str.4 = [5 x i8] c"%f, \00"
@.str.5 = [3 x i8] c"},\00"
@.str.7 = [5 x i8] c"};\0A\0A\00"
@.str.8 = [32 x i8] c"\0Astatic const float d[128] = {\0A\00"
@.str.9 = [3 x i8] c"};\00"
define void @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64 36, i64 1, i32* %1)
br label %3
3: ; preds = %0, %15
%4 = phi i32 [ 0, %0 ], [ %18, %15 ]
%5 = tail call i32 @fputc(i32 123, i32* %1)
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %13, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 1000
%10 = sitofp i32 %9 to float
%11 = fpext float %10 to double
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %11)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, 128
br i1 %14, label %15, label %6
15: ; preds = %6
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %1)
%17 = tail call i32 @fputc(i32 10, i32* %1)
%18 = add nuw nsw i32 %4, 1
%19 = icmp eq i32 %18, 128
br i1 %19, label %20, label %3
20: ; preds = %15
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 4, i64 1, i32* %1)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i64 31, i64 1, i32* %1)
br label %23
23: ; preds = %20, %23
%24 = phi i32 [ 0, %20 ], [ %31, %23 ]
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 1000
%27 = sitofp i32 %26 to float
%28 = fpext float %27 to double
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %28)
%30 = tail call i32 @fputc(i32 10, i32* %1)
%31 = add nuw nsw i32 %24, 1
%32 = icmp eq i32 %31, 128
br i1 %32, label %33, label %23
33: ; preds = %23
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64 2, i64 1, i32* %1)
%35 = tail call i32 @fclose(i32* %1)
ret void
}