#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*/ find_smallest_diff(int, int *);
int /*<<< orphan*/ print_list(int, int *);
int rand();
int main(void) {
  int ar_size = rand() % 50;
  int ar[ar_size], i;
  for (i = 0; i < ar_size; i++) {
    ar[i] = rand() % 10000;
    if (rand() % 2)
      ar[i] *= -1;
  }
  print_list(ar_size, ar);
  find_smallest_diff(ar_size, ar);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rcx
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f3 <main+0xc3>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11e0 <main+0xb0>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xffffffff,(%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
jmp    11e5 <main+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <main+0x63>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <print_list@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1040 <find_smallest_diff@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%r14
imul   $0x51eb851f,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rax
add    %ecx,%eax
imul   $0x32,%eax,%eax
sub    %eax,%r14d
lea    0xf(,%r14,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
test   %r14d,%r14d
jle    11c6 <main+0x96>
xor    %r12d,%r12d
jmp    1189 <main+0x59>
xchg   %ax,%ax
add    $0x1,%r12
cmp    %r12,%r14
je     11c6 <main+0x96>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,(%r15,%r12,4)
xor    %eax,%eax
call   1050 <rand@plt>
test   $0x1,%al
je     1180 <main+0x50>
neg    %ebx
mov    %ebx,(%r15,%r12,4)
jmp    1180 <main+0x50>
mov    %r14d,%edi
mov    %r15,%rsi
call   1030 <print_list@plt>
mov    %r14d,%edi
mov    %r15,%rsi
call   1040 <find_smallest_diff@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 50
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
store i32 0, i32* %5
br label %12
12: ; preds = %32, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %12
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 10000
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %11, i64 %20
store i32 %18, i32* %21
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %16
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %11, i64 %27
%29 = load i32, i32* %28
%30 = mul nsw i32 %29, -1
store i32 %30, i32* %28
br label %31
31: ; preds = %25, %16
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %12
35: ; preds = %12
%36 = load i32, i32* %2
%37 = call i32 @print_list(i32 %36, i32* %11)
%38 = load i32, i32* %2
%39 = call i32 @find_smallest_diff(i32 %38, i32* %11)
store i32 0, i32* %1
%40 = load i8*, i8** %3
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 50
%3 = zext i32 %2 to i64
%4 = alloca i32, i64 %3
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %19
6: ; preds = %0, %16
%7 = phi i64 [ %17, %16 ], [ 0, %0 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10000
%10 = getelementptr inbounds i32, i32* %4, i64 %7
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %6
%15 = sub nsw i32 0, %9
store i32 %15, i32* %10
br label %16
16: ; preds = %6, %14
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, %3
br i1 %18, label %19, label %6
19: ; preds = %16, %0
%20 = call i32 @print_list(i32 %2, i32* %4)
%21 = call i32 @find_smallest_diff(i32 %2, i32* %4)
ret i32 0
}