#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 */

/* Variables and functions */
int rand();
void Generate_Pattern(int pattern[][100]) {
  int i, p;
  for (p = 0; p < 5; p++) {
    for (i = 0; i < 100; i++) {
      pattern[p][i] = 2 * (rand() % 2) - 1;
    }
  }
}


x86 assembly (clang, -O0):
<Generate_Pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    118d <Generate_Pattern+0x7d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    117a <Generate_Pattern+0x6a>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x1,%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <Generate_Pattern+0x24>
jmp    117f <Generate_Pattern+0x6f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <Generate_Pattern+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Generate_Pattern>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1120 <Generate_Pattern+0x10>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x190(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1150 <Generate_Pattern+0x40>
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x320(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1180 <Generate_Pattern+0x70>
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x4b0(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11b0 <Generate_Pattern+0xa0>
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x640(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11e0 <Generate_Pattern+0xd0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @Generate_Pattern([100 x i32]* %0) {
%2 = alloca [100 x i32]*
%3 = alloca i32
%4 = alloca i32
store [100 x i32]* %0, [100 x i32]** %2
store i32 0, i32* %4
br label %5
5: ; preds = %28, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %31
8: ; preds = %5
store i32 0, i32* %3
br label %9
9: ; preds = %24, %8
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 2
%15 = mul nsw i32 2, %14
%16 = sub nsw i32 %15, 1
%17 = load [100 x i32]*, [100 x i32]** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %17, i64 %19
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %20, i64 0, i64 %22
store i32 %16, i32* %23
br label %24
24: ; preds = %12
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %9
27: ; preds = %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %5
31: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @Generate_Pattern([100 x i32]* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %9, %2 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 2
%6 = shl nsw i32 %5, 1
%7 = add nsw i32 %6, -1
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %0, i64 0, i64 %3
store i32 %7, i32* %8
%9 = add nuw nsw i64 %3, 1
%10 = icmp eq i64 %9, 100
br i1 %10, label %11, label %2
11: ; preds = %2, %11
%12 = phi i64 [ %18, %11 ], [ 0, %2 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 2
%15 = shl nsw i32 %14, 1
%16 = add nsw i32 %15, -1
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %0, i64 1, i64 %12
store i32 %16, i32* %17
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, 100
br i1 %19, label %20, label %11
20: ; preds = %11, %20
%21 = phi i64 [ %27, %20 ], [ 0, %11 ]
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 2
%24 = shl nsw i32 %23, 1
%25 = add nsw i32 %24, -1
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %0, i64 2, i64 %21
store i32 %25, i32* %26
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, 100
br i1 %28, label %29, label %20
29: ; preds = %20, %29
%30 = phi i64 [ %36, %29 ], [ 0, %20 ]
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 2
%33 = shl nsw i32 %32, 1
%34 = add nsw i32 %33, -1
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %0, i64 3, i64 %30
store i32 %34, i32* %35
%36 = add nuw nsw i64 %30, 1
%37 = icmp eq i64 %36, 100
br i1 %37, label %38, label %29
38: ; preds = %29, %38
%39 = phi i64 [ %45, %38 ], [ 0, %29 ]
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 2
%42 = shl nsw i32 %41, 1
%43 = add nsw i32 %42, -1
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %0, i64 4, i64 %39
store i32 %43, i32* %44
%45 = add nuw nsw i64 %39, 1
%46 = icmp eq i64 %45, 100
br i1 %46, label %47, label %38
47: ; preds = %38
ret void
}