#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 */
scalar_t__ RAND_MAX;
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ rand();
signed char *generate_numbers(size_t n) {
  signed char *numbers = (signed char *)malloc(sizeof(signed char) * n);
  if (!numbers) {
    perror("Not enough memory");
    exit(-1);
  }
  size_t i;
  double random;
  for (i = 0; i < n; i++) {
    random = (double)rand() / (double)RAND_MAX;
    random *= 200;
    random -= 100;
    numbers[i] = (signed char)random;
  }
  return numbers;
}


x86 assembly (clang, -O0):
<generate_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1180 <generate_numbers+0x40>
lea    0xe9f(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    120a <generate_numbers+0xca>
xor    %eax,%eax
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e3f(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1188 <generate_numbers+0x48>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_numbers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <malloc@plt>
test   %rax,%rax
je     11bb <generate_numbers+0x7b>
mov    %rax,%r12
test   %r14,%r14
je     11ac <generate_numbers+0x6c>
mov    0x2e84(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xe6d(%rip),%xmm0
addsd  0xe6d(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <generate_numbers+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe4e(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Not enough memory\00"
@RAND_MAX = global i64 0
define i8* @generate_numbers(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca double
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = mul i64 1, %6
%8 = trunc i64 %7 to i32
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %1
store i64 0, i64* %4
br label %17
17: ; preds = %36, %16
%18 = load i64, i64* %4
%19 = load i64, i64* %2
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %39
21: ; preds = %17
%22 = call i64 (...) @rand()
%23 = sitofp i64 %22 to double
%24 = load i64, i64* @RAND_MAX
%25 = sitofp i64 %24 to double
%26 = fdiv double %23, %25
store double %26, double* %5
%27 = load double, double* %5
%28 = fmul double %27, 2.000000e+02
store double %28, double* %5
%29 = load double, double* %5
%30 = fsub double %29, 1.000000e+02
store double %30, double* %5
%31 = load double, double* %5
%32 = fptosi double %31 to i8
%33 = load i8*, i8** %3
%34 = load i64, i64* %4
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %21
%37 = load i64, i64* %4
%38 = add i64 %37, 1
store i64 %38, i64* %4
br label %17
39: ; preds = %17
%40 = load i8*, i8** %3
ret i8* %40
}

LLVM IR (-O2):
@.str = [18 x i8] c"Not enough memory\00"
@RAND_MAX = global i64 0
define i8* @generate_numbers(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = icmp eq i64 %0, 0
br i1 %7, label %24, label %11
8: ; preds = %1
%9 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %6, %11
%12 = phi i64 [ %22, %11 ], [ 0, %6 ]
%13 = tail call i64 (...) @rand()
%14 = sitofp i64 %13 to double
%15 = load i64, i64* @RAND_MAX
%16 = sitofp i64 %15 to double
%17 = fdiv double %14, %16
%18 = fmul double %17, 2.000000e+02
%19 = fadd double %18, -1.000000e+02
%20 = fptosi double %19 to i8
%21 = getelementptr inbounds i8, i8* %4, i64 %12
store i8 %20, i8* %21
%22 = add nuw i64 %12, 1
%23 = icmp eq i64 %22, %0
br i1 %23, label %24, label %11
24: ; preds = %11, %6
ret i8* %4
}