#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 random_char_gen();
void main() {
  int i, j;
  FILE *fp;
  fp = fopen("seg_bus.h", "wb");
  fprintf(fp, "\nstatic const float Bus_A[] = {\n");
  for (i = 0; i < 512; i++) {
    for (j = 0; j < 512; j++) {
      fprintf(fp, "%d, ", random_char_gen());
    }
    fprintf(fp, "\n");
  }
  fprintf(fp, "};\n\n");
  fprintf(fp, "\nstatic const float Bus_B[] = {\n");
  for (i = 0; i < 512; i++) {
    for (j = 0; j < 512; j++) {
      fprintf(fp, "%d, ", random_char_gen());
    }
    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    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x200,-0x4(%rbp)
jge    11ea <main+0xaa>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200,-0x8(%rbp)
jge    11ca <main+0x8a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <random_char_gen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x4c>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1178 <main+0x38>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x200,-0x4(%rbp)
jge    1287 <main+0x147>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200,-0x8(%rbp)
jge    1267 <main+0x127>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <random_char_gen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1229 <main+0xe9>
mov    -0x10(%rbp),%rdi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1215 <main+0xd5>
mov    -0x10(%rbp),%rdi
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe92(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe89(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xe91(%rip),%r14
xor    %r15d,%r15d
mov    $0x200,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <random_char_gen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x50>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r15d
cmp    $0x200,%r15d
jne    11a0 <main+0x40>
lea    0xe47(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe33(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe10(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x200,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <random_char_gen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1240 <main+0xe0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r15d
cmp    $0x200,%r15d
jne    1230 <main+0xd0>
lea    0xddd(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

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

LLVM IR (-O2):
@.str = [10 x i8] c"seg_bus.h\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [33 x i8] c"\0Astatic const float Bus_A[] = {\0A\00"
@.str.3 = [5 x i8] c"%d, \00"
@.str.5 = [5 x i8] c"};\0A\0A\00"
@.str.6 = [33 x i8] c"\0Astatic const float Bus_B[] = {\0A\00"
@.str.7 = [3 x i8] c"};\00"
define void @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i64 32, i64 1, i32* %1)
br label %3
3: ; preds = %0, %11
%4 = phi i32 [ 0, %0 ], [ %13, %11 ]
br label %5
5: ; preds = %3, %5
%6 = phi i32 [ 0, %3 ], [ %9, %5 ]
%7 = tail call i32 (...) @random_char_gen()
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = add nuw nsw i32 %6, 1
%10 = icmp eq i32 %9, 512
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = tail call i32 @fputc(i32 10, i32* %1)
%13 = add nuw nsw i32 %4, 1
%14 = icmp eq i32 %13, 512
br i1 %14, label %15, label %3
15: ; preds = %11
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 4, i64 1, i32* %1)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i64 32, i64 1, i32* %1)
br label %18
18: ; preds = %15, %26
%19 = phi i32 [ 0, %15 ], [ %28, %26 ]
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ 0, %18 ], [ %24, %20 ]
%22 = tail call i32 (...) @random_char_gen()
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %21, 1
%25 = icmp eq i32 %24, 512
br i1 %25, label %26, label %20
26: ; preds = %20
%27 = tail call i32 @fputc(i32 10, i32* %1)
%28 = add nuw nsw i32 %19, 1
%29 = icmp eq i32 %28, 512
br i1 %29, label %30, label %18
30: ; preds = %26
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %1)
%32 = tail call i32 @fclose(i32* %1)
ret void
}