#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 RAND_MAX;
int *malloc(int);
double rand();
int *rand_pixel(int width, int height) {
  int *ret = malloc(2 * sizeof(int));
  ret[0] = (int)width * (rand() / (RAND_MAX + 1.0));
  ret[1] = (int)height * (rand() / (RAND_MAX + 1.0));
  return ret;
}


x86 assembly (clang, -O0):
<rand_pixel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xea3(%rip),%xmm2
mov    0x2e84(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xe65(%rip),%xmm2
mov    0x2e46(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_pixel>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2e96(%rip),%rbp
movsd  0x0(%rbp),%xmm1
addsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
movsd  0xe74(%rip),%xmm1
addsd  0x0(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x4(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32* @rand_pixel(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32* @malloc(i32 8)
store i32* %6, i32** %5
%7 = load i32, i32* %3
%8 = sitofp i32 %7 to double
%9 = call double (...) @rand()
%10 = load double, double* @RAND_MAX
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double %9, %11
%13 = fmul double %8, %12
%14 = fptosi double %13 to i32
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 0
store i32 %14, i32* %16
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = call double (...) @rand()
%20 = load double, double* @RAND_MAX
%21 = fadd double %20, 1.000000e+00
%22 = fdiv double %19, %21
%23 = fmul double %18, %22
%24 = fptosi double %23 to i32
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 1
store i32 %24, i32* %26
%27 = load i32*, i32** %5
ret i32* %27
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define noalias i32* @rand_pixel(i32 %0, i32 %1) {
%3 = tail call i32* @malloc(i32 8)
%4 = sitofp i32 %0 to double
%5 = tail call double (...) @rand()
%6 = load double, double* @RAND_MAX
%7 = fadd double %6, 1.000000e+00
%8 = fdiv double %5, %7
%9 = fmul double %8, %4
%10 = fptosi double %9 to i32
store i32 %10, i32* %3
%11 = sitofp i32 %1 to double
%12 = tail call double (...) @rand()
%13 = load double, double* @RAND_MAX
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %12, %14
%16 = fmul double %15, %11
%17 = fptosi double %16 to i32
%18 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %17, i32* %18
ret i32* %3
}