#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*/ limpa(int *, int);
int rand();
int /*<<< orphan*/ showA(int, int *);
void barStk(int *stock, int tmn) {
  int tmp[20], r, i = 0;
  limpa(tmp, tmn);
  r = (rand() % tmn);
  showA(tmn, stock);
  while (i < tmn) {
    if (tmp[r] == 0) {
      tmp[r] = stock[i];
      i++;
      r = rand() % 20;
    } else {
      r = rand() % 20;
    };
  };
}


x86 assembly (clang, -O0):
<barStk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <limpa@plt>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x64(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <showA@plt>
mov    -0x68(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <barStk+0xa1>
movslq -0x64(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
jne    11ba <barStk+0x8a>
mov    -0x8(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x64(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x64(%rbp)
jmp    11cc <barStk+0x9c>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x64(%rbp)
jmp    116c <barStk+0x3c>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<barStk>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rsp,%rdi
call   1030 <limpa@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <showA@plt>
test   %ebx,%ebx
jle    11b2 <barStk+0x82>
mov    %ebp,%eax
cltd
idiv   %ebx
xor    %ebp,%ebp
jmp    119a <barStk+0x6a>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
cmp    %ebx,%ebp
jge    11b2 <barStk+0x82>
movslq %edx,%rax
cmpl   $0x0,(%rsp,%rax,4)
jne    1170 <barStk+0x40>
movslq %ebp,%rbp
mov    (%r14,%rbp,4),%ecx
mov    %ecx,(%rsp,%rax,4)
add    $0x1,%ebp
jmp    1170 <barStk+0x40>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @barStk(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [20 x i32]
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %7
%8 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 0
%9 = load i32, i32* %4
%10 = call i32 @limpa(i32* %8, i32 %9)
%11 = call i32 (...) @rand()
%12 = load i32, i32* %4
%13 = srem i32 %11, %12
store i32 %13, i32* %6
%14 = load i32, i32* %4
%15 = load i32*, i32** %3
%16 = call i32 @showA(i32 %14, i32* %15)
br label %17
17: ; preds = %43, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %44
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %21
%28 = load i32*, i32** %3
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %34
store i32 %32, i32* %35
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = call i32 (...) @rand()
%39 = srem i32 %38, 20
store i32 %39, i32* %6
br label %43
40: ; preds = %21
%41 = call i32 (...) @rand()
%42 = srem i32 %41, 20
store i32 %42, i32* %6
br label %43
43: ; preds = %40, %27
br label %17
44: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @barStk(i32* %0, i32 %1) {
%3 = alloca [20 x i32]
%4 = bitcast [20 x i32]* %3 to i8*
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%6 = call i32 @limpa(i32* %5, i32 %1)
%7 = call i32 (...) @rand()
%8 = call i32 @showA(i32 %1, i32* %0)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %29
10: ; preds = %2
%11 = srem i32 %7, %1
br label %12
12: ; preds = %10, %24
%13 = phi i32 [ %25, %24 ], [ 0, %10 ]
%14 = phi i32 [ %27, %24 ], [ %11, %10 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = sext i32 %13 to i64
%21 = getelementptr inbounds i32, i32* %0, i64 %20
%22 = load i32, i32* %21
store i32 %22, i32* %16
%23 = add nsw i32 %13, 1
br label %24
24: ; preds = %12, %19
%25 = phi i32 [ %23, %19 ], [ %13, %12 ]
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 20
%28 = icmp slt i32 %25, %1
br i1 %28, label %12, label %29
29: ; preds = %24, %2
ret void
}