#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void embaralhar(int m[4][4]) {
  int x1, y1, x2, y2;
  int k;
  srand(time(NULL));
  for (k = 0; k < 100; k++) {
    x1 = rand() % 4;
    y1 = rand() % 4;
    x2 = rand() % 4;
    y2 = rand() % 4;
    int tmp = m[x1][y1];
    m[x1][y1] = m[x2][y2];
    m[x2][y2] = tmp;
  }
}


x86 assembly (clang, -O0):
<embaralhar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    1211 <embaralhar+0xe1>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1153 <embaralhar+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<embaralhar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x64,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r15d
lea    0x3(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r15d
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r12d
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
movslq %r15d,%rcx
movslq %r12d,%rdx
shl    $0x4,%rcx
add    %r14,%rcx
mov    (%rcx,%rdx,4),%esi
movslq %ebx,%rdi
cltq
shl    $0x4,%rdi
add    %r14,%rdi
mov    (%rdi,%rax,4),%ebx
mov    %ebx,(%rcx,%rdx,4)
mov    %esi,(%rdi,%rax,4)
add    $0xffffffff,%ebp
jne    1150 <embaralhar+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @embaralhar([4 x i32]* %0) {
%2 = alloca [4 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [4 x i32]* %0, [4 x i32]** %2
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %54, %1
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %57
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 4
store i32 %16, i32* %3
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 4
store i32 %18, i32* %4
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 4
store i32 %20, i32* %5
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 4
store i32 %22, i32* %6
%23 = load [4 x i32]*, [4 x i32]** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %23, i64 %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %26, i64 0, i64 %28
%30 = load i32, i32* %29
store i32 %30, i32* %8
%31 = load [4 x i32]*, [4 x i32]** %2
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %31, i64 %33
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %34, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = load [4 x i32]*, [4 x i32]** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %39, i64 %41
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4 x i32], [4 x i32]* %42, i64 0, i64 %44
store i32 %38, i32* %45
%46 = load i32, i32* %8
%47 = load [4 x i32]*, [4 x i32]** %2
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %47, i64 %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %50, i64 0, i64 %52
store i32 %46, i32* %53
br label %54
54: ; preds = %14
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %11
57: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @embaralhar([4 x i32]* nocapture %0) {
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %22, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 4
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 4
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 4
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 4
%14 = sext i32 %7 to i64
%15 = sext i32 %9 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %14, i64 %15
%17 = load i32, i32* %16
%18 = sext i32 %11 to i64
%19 = sext i32 %13 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %18, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %16
store i32 %17, i32* %20
%22 = add nuw nsw i32 %5, 1
%23 = icmp eq i32 %22, 100
br i1 %23, label %24, label %4
24: ; preds = %4
ret void
}