#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ nether_flag(int **, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void main() {
  int *arr = (int *)malloc(sizeof(int) * 32);
  srand(time(NULL));
  for (int i = 0; i < 32; i++) {
    arr[i] = rand() % 3;
    printf("%d ", arr[i]);
  }
  printf("\n");
  nether_flag(&arr, 32);
  for (int i = 0; i < 32; i++)
    printf("%d ", arr[i]);
  printf("\n");
  free(arr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11e8 <main+0x78>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <main+0x2d>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1080 <nether_flag@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    123c <main+0xcc>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    120b <main+0x9b>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x80,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x8(%rsp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe50(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x55555556,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%esi
mov    %esi,(%r15,%rbx,4)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    11c0 <main+0x40>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x8(%rsp),%rdi
mov    $0x20,%esi
call   1090 <nether_flag@plt>
lea    0xde5(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1220 <main+0xa0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = call i64 @malloc(i32 128)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
store i32 0, i32* %2
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 3
%14 = load i32*, i32** %1
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
%18 = load i32*, i32** %1
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %11
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %8
27: ; preds = %8
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @nether_flag(i32** %1, i32 32)
store i32 0, i32* %3
br label %30
30: ; preds = %40, %27
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 32
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32*, i32** %1
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %30
43: ; preds = %30
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = load i32*, i32** %1
%46 = call i32 @free(i32* %45)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @main() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
%3 = tail call i64 @malloc(i32 128)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %1
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
br label %10
7: ; preds = %10
%8 = tail call i32 @putchar(i32 10)
%9 = call i32 @nether_flag(i32** %1, i32 32)
br label %22
10: ; preds = %0, %10
%11 = phi i64 [ 0, %0 ], [ %16, %10 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 3
%14 = getelementptr inbounds i32, i32* %4, i64 %11
store i32 %13, i32* %14
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, 32
br i1 %17, label %7, label %10
18: ; preds = %22
%19 = call i32 @putchar(i32 10)
%20 = load i32*, i32** %1
%21 = call i32 @free(i32* %20)
ret void
22: ; preds = %7, %22
%23 = phi i64 [ 0, %7 ], [ %28, %22 ]
%24 = load i32*, i32** %1
%25 = getelementptr inbounds i32, i32* %24, i64 %23
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, 32
br i1 %29, label %18, label %22
}