#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 pow(int, int);
int rand();
void Riempimento(int *mat, int x, int y) {
  int i;
  for (i = 0; i < x * y; i++)
    *(mat + i) = rand() % 10 * pow(-1, rand() % 2);
}


x86 assembly (clang, -O0):
<Riempimento>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1197 <Riempimento+0x77>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    $0xffffffff,%edi
call   1030 <pow@plt>
mov    -0x18(%rbp),%edx
imul   %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <Riempimento+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Riempimento>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
imul   %edx,%esi
test   %esi,%esi
jle    1196 <Riempimento+0x76>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r12
imul   $0x66666667,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    $0xffffffff,%edi
mov    %eax,%esi
call   1030 <pow@plt>
imul   %r12d,%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <Riempimento+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Riempimento(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %25, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = mul nsw i32 %10, %11
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %28
14: ; preds = %8
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 10
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 2
%19 = call i32 @pow(i32 -1, i32 %18)
%20 = mul nsw i32 %16, %19
%21 = load i32*, i32** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
br label %25
25: ; preds = %14
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @Riempimento(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = mul i32 %2, %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %17, %8 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 10
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 2
%14 = tail call i32 @pow(i32 -1, i32 %13)
%15 = mul nsw i32 %14, %11
%16 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %15, i32* %16
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %19, label %8
19: ; preds = %8, %3
ret void
}