#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 */
double Calculate_Energy_Function(int **, int *);
int /*<<< orphan*/ Display_Pattern(int *);
int /*<<< orphan*/ Generate_Pattern(int **);
int /*<<< orphan*/ Set_Initial_State(int **, int *);
int /*<<< orphan*/ Set_Weight_Value(int **, int **);
int /*<<< orphan*/ Update_State(int **, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int pattern[3][100];
  int state[100];
  int w[100][100];
  double energy;
  int iteration;
  Generate_Pattern(pattern);
  Set_Weight_Value(pattern, w);
  srand((unsigned int)time(NULL));
  Set_Initial_State(pattern, state);
  Display_Pattern(state);
  for (iteration = 0; iteration < 1e4; iteration++) {
    Update_State(w, state);
    energy = Calculate_Energy_Function(w, state);
  }
  Display_Pattern(state);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa2a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4c0(%rbp),%rdi
call   1090 <Generate_Pattern@plt>
lea    -0x4c0(%rbp),%rdi
lea    -0xa290(%rbp),%rsi
call   1070 <Set_Weight_Value@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x4c0(%rbp),%rdi
lea    -0x650(%rbp),%rsi
call   1040 <Set_Initial_State@plt>
lea    -0x650(%rbp),%rdi
call   10a0 <Display_Pattern@plt>
movl   $0x0,-0xa29c(%rbp)
cvtsi2sdl -0xa29c(%rbp),%xmm1
ff
movsd  0xe06(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1246 <main+0xc6>
lea    -0xa290(%rbp),%rdi
lea    -0x650(%rbp),%rsi
call   1030 <Update_State@plt>
lea    -0xa290(%rbp),%rdi
lea    -0x650(%rbp),%rsi
call   1080 <Calculate_Energy_Function@plt>
movsd  %xmm0,-0xa298(%rbp)
ff
mov    -0xa29c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa29c(%rbp)
jmp    11ea <main+0x6a>
lea    -0x650(%rbp),%rdi
call   10a0 <Display_Pattern@plt>
xor    %eax,%eax
add    $0xa2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xa288,%rsp
lea    0x190(%rsp),%r15
mov    %r15,%rdi
call   1090 <Generate_Pattern@plt>
lea    0x640(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <Set_Weight_Value@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <Set_Initial_State@plt>
mov    %rbx,%rdi
call   10a0 <Display_Pattern@plt>
mov    $0x2710,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <Update_State@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <Calculate_Energy_Function@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0x60>
mov    %rsp,%rdi
call   10a0 <Display_Pattern@plt>
xor    %eax,%eax
add    $0xa288,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [100 x i32]]
%3 = alloca [100 x i32]
%4 = alloca [100 x [100 x i32]]
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [3 x [100 x i32]], [3 x [100 x i32]]* %2, i64 0, i64 0
%8 = bitcast [100 x i32]* %7 to i32**
%9 = call i32 @Generate_Pattern(i32** %8)
%10 = getelementptr inbounds [3 x [100 x i32]], [3 x [100 x i32]]* %2, i64 0, i64 0
%11 = bitcast [100 x i32]* %10 to i32**
%12 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %4, i64 0, i64 0
%13 = bitcast [100 x i32]* %12 to i32**
%14 = call i32 @Set_Weight_Value(i32** %11, i32** %13)
%15 = call i64 @time(i32* null)
%16 = trunc i64 %15 to i32
%17 = call i32 @srand(i32 %16)
%18 = getelementptr inbounds [3 x [100 x i32]], [3 x [100 x i32]]* %2, i64 0, i64 0
%19 = bitcast [100 x i32]* %18 to i32**
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%21 = call i32 @Set_Initial_State(i32** %19, i32* %20)
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%23 = call i32 @Display_Pattern(i32* %22)
store i32 0, i32* %6
br label %24
24: ; preds = %37, %0
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = fcmp olt double %26, 1.000000e+04
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %4, i64 0, i64 0
%30 = bitcast [100 x i32]* %29 to i32**
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%32 = call i32 @Update_State(i32** %30, i32* %31)
%33 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %4, i64 0, i64 0
%34 = bitcast [100 x i32]* %33 to i32**
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%36 = call double @Calculate_Energy_Function(i32** %34, i32* %35)
store double %36, double* %5
br label %37
37: ; preds = %28
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %24
40: ; preds = %24
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%42 = call i32 @Display_Pattern(i32* %41)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [3 x [100 x i32]]
%2 = alloca [100 x i32]
%3 = alloca [100 x [100 x i32]]
%4 = bitcast [3 x [100 x i32]]* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = bitcast [100 x [100 x i32]]* %3 to i8*
%7 = bitcast [3 x [100 x i32]]* %1 to i32**
%8 = call i32 @Generate_Pattern(i32** %7)
%9 = bitcast [100 x [100 x i32]]* %3 to i32**
%10 = call i32 @Set_Weight_Value(i32** %7, i32** %9)
%11 = call i64 @time(i32* null)
%12 = trunc i64 %11 to i32
%13 = call i32 @srand(i32 %12)
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%15 = call i32 @Set_Initial_State(i32** %7, i32* %14)
%16 = call i32 @Display_Pattern(i32* %14)
br label %17
17: ; preds = %0, %17
%18 = phi i32 [ 0, %0 ], [ %21, %17 ]
%19 = call i32 @Update_State(i32** %9, i32* %14)
%20 = call double @Calculate_Energy_Function(i32** %9, i32* %14)
%21 = add nuw nsw i32 %18, 1
%22 = icmp eq i32 %21, 10000
br i1 %22, label %23, label %17
23: ; preds = %17
%24 = call i32 @Display_Pattern(i32* %14)
ret i32 0
}