#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();
void cargar(int vec[30], int x) {
  int i;
  for (i = 0; i < 30; i++) {
    if (x == 1) {
      vec[i] = rand() % 900 + 100;
    } else {
      if (x == 2) {
        vec[i] = (rand() % 450 + 50) * 2;
      } else {
        vec[i] = ((rand() % 450 + 50) * 2) + 1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<cargar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1e,-0x10(%rbp)
jge    11c6 <cargar+0xb6>
cmpl   $0x1,-0xc(%rbp)
jne    115c <cargar+0x4c>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x384,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11b3 <cargar+0xa3>
cmpl   $0x2,-0xc(%rbp)
jne    118b <cargar+0x7b>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x1c2,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
shl    $0x1,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11ae <cargar+0x9e>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x1c2,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
shl    $0x1,%edx
add    $0x1,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11b3 <cargar+0xa3>
jmp    11b8 <cargar+0xa8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <cargar+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cargar>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1159 <cargar+0x49>
nopl   (%rax)
call   1030 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x8,%ecx
add    %edx,%ecx
imul   $0x1c2,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0x65,%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     11d0 <cargar+0xc0>
xor    %eax,%eax
cmp    $0x2,%ebp
je     11a0 <cargar+0x90>
cmp    $0x1,%ebp
jne    1120 <cargar+0x10>
call   1030 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x9,%ecx
add    %edx,%ecx
imul   $0x384,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x64,%eax
jmp    114b <cargar+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x8,%ecx
add    %edx,%ecx
imul   $0x1c2,%ecx,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0x64,%eax
jmp    114b <cargar+0x3b>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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