#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
long long sumsq_wq(short *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i;
  long long result, rresult;
  signed short samples[200002];
  srandom(time(NULL));
  for (i = 0; i < 200002; i++)
    samples[i] = random() & 0xffff;
  rresult = sumsq_wq(&samples[1], 200002 - 1);
  result = sumsq_wq(&samples[1], 200002 - 1);
  if (result == rresult) {
    printf("OK\n");
  } else {
    printf("sum mismatch: %lld != %lld\n", result, rresult);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61aa0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x30d42,-0x8(%rbp)
jge    11bf <main+0x5f>
mov    $0x0,%al
call   1070 <random@plt>
and    $0xffff,%eax
mov    %ax,%cx
movslq -0x8(%rbp),%rax
mov    %cx,-0x61aa0(%rbp,%rax,2)
ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1189 <main+0x29>
lea    -0x61aa0(%rbp),%rdi
add    $0x2,%rdi
mov    $0x30d41,%esi
call   1050 <sumsq_wq@plt>
mov    %rax,-0x18(%rbp)
lea    -0x61aa0(%rbp),%rdi
add    $0x2,%rdi
mov    $0x30d41,%esi
call   1050 <sumsq_wq@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1212 <main+0xb2>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1228 <main+0xc8>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x61a88,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <random@plt>
mov    %ax,(%rsp,%rbx,2)
add    $0x1,%rbx
cmp    $0x30d42,%rbx
jne    1190 <main+0x20>
lea    0x2(%rsp),%r14
mov    %r14,%rdi
mov    $0x30d41,%esi
call   1060 <sumsq_wq@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x30d41,%esi
call   1060 <sumsq_wq@plt>
cmp    %rbx,%rax
jne    11e2 <main+0x72>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe17(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"OK\0A\00"
@.str.1 = [28 x i8] c"sum mismatch: %lld != %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca [200002 x i16]
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srandom(i32 %6)
store i32 0, i32* %2
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 200002
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = call i32 (...) @random()
%13 = and i32 %12, 65535
%14 = trunc i32 %13 to i16
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [200002 x i16], [200002 x i16]* %5, i64 0, i64 %16
store i16 %14, i16* %17
br label %18
18: ; preds = %11
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %8
21: ; preds = %8
%22 = getelementptr inbounds [200002 x i16], [200002 x i16]* %5, i64 0, i64 1
%23 = call i64 @sumsq_wq(i16* %22, i32 200001)
store i64 %23, i64* %4
%24 = getelementptr inbounds [200002 x i16], [200002 x i16]* %5, i64 0, i64 1
%25 = call i64 @sumsq_wq(i16* %24, i32 200001)
store i64 %25, i64* %3
%26 = load i64, i64* %3
%27 = load i64, i64* %4
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %35
31: ; preds = %21
%32 = load i64, i64* %3
%33 = load i64, i64* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i64 %32, i64 %33)
br label %35
35: ; preds = %31, %29
%36 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"sum mismatch: %lld != %lld\0A\00"
@str = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca [200002 x i16]
%2 = bitcast [200002 x i16]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srandom(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %10, %5 ]
%7 = tail call i32 (...) @random()
%8 = trunc i32 %7 to i16
%9 = getelementptr inbounds [200002 x i16], [200002 x i16]* %1, i64 0, i64 %6
store i16 %8, i16* %9
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 200002
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = getelementptr inbounds [200002 x i16], [200002 x i16]* %1, i64 0, i64 1
%14 = call i64 @sumsq_wq(i16* %13, i32 200001)
%15 = call i64 @sumsq_wq(i16* %13, i32 200001)
%16 = icmp eq i64 %15, %14
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i64 %15, i64 %14)
br label %21
21: ; preds = %19, %17
%22 = call i32 @exit(i32 0)
unreachable
}