#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*/ print_int_array(int, int *);
int /*<<< orphan*/ print_random_array();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i, j, k, negative_count = 0;
  int array3D[10][10][10], array2[] = {3, 5, 1, -23},
                           array4[4] = {[1] = 1, [3] = -7};
  float average = 0;
  srand(time(NULL));
  print_random_array();
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      for (k = 0; k < 10; k++) {
        array3D[i][j][k] = -5 + (rand() % 11);
        if (array3D[i][j][k] < 0) {
          negative_count++;
          average += array3D[i][j][k];
        }
        printf("%d ", array3D[i][j][k]);
      }
      printf("\n");
    }
    printf("\n----------------\n");
  }
  if (negative_count > 0)
    printf("The average is %f\n", average / negative_count);
  else
    printf("No negative numbers\n");
  print_int_array(4, array2);
  print_int_array(4, array4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xff0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe80(%rip),%rax
mov    %rax,-0xfd0(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0xfc8(%rbp)
mov    0xe74(%rip),%rax
mov    %rax,-0xfe0(%rbp)
mov    0xe6e(%rip),%rax
mov    %rax,-0xfd8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xfe4(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <print_random_array@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    132d <main+0x1cd>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1311 <main+0x1b1>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    12f5 <main+0x195>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0xfffffffb,%edx
movslq -0x8(%rbp),%rcx
lea    -0xfc0(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x8(%rbp),%rcx
lea    -0xfc0(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    12b2 <main+0x152>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x8(%rbp),%rcx
lea    -0xfc0(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm0
addss  -0xfe4(%rbp),%xmm0
ff
movss  %xmm0,-0xfe4(%rbp)
ff
movslq -0x8(%rbp),%rcx
lea    -0xfc0(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fc <main+0x9c>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11eb <main+0x8b>
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11da <main+0x7a>
cmpl   $0x0,-0x14(%rbp)
jle    135f <main+0x1ff>
movss  -0xfe4(%rbp),%xmm0
ff
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xce4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    136d <main+0x20d>
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xfd0(%rbp),%rsi
mov    $0x4,%edi
call   1060 <print_int_array@plt>
lea    -0xfe0(%rbp),%rsi
mov    $0x4,%edi
call   1060 <print_int_array@plt>
xor    %eax,%eax
add    $0xff0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1090 <print_random_array@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xe63(%rip),%r15
lea    0xe87(%rip),%r14
xor    %r12d,%r12d
jmp    11f6 <main+0x76>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x1,%r12d
cmp    $0xa,%r12d
je     128d <main+0x10d>
xor    %r13d,%r13d
jmp    1214 <main+0x94>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
cmp    $0xa,%r13d
je     11e0 <main+0x60>
mov    $0xa,%ebp
jmp    124b <main+0xcb>
nopl   0x0(%rax,%rax,1)
movss  0xdd8(%rip),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
mov    %cl,%al
add    %eax,%ebx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebp
je     1200 <main+0x80>
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0xfffffffb,%esi
xor    %eax,%eax
cmp    $0x5,%edx
setl   %cl
jge    1220 <main+0xa0>
xorps  %xmm0,%xmm0
cvtsi2ss %esi,%xmm0
jmp    1228 <main+0xa8>
test   %ebx,%ebx
jle    12b9 <main+0x139>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xd84(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    12c5 <main+0x145>
lea    0xd87(%rip),%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rsi
mov    $0x4,%edi
call   1080 <print_int_array@plt>
lea    0x10(%rsp),%rsi
mov    $0x4,%edi
call   1080 <print_int_array@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.array2 = [4 x i32] [i32 3, i32 5, i32 1, i32 -23]
@__const.main.array4 = [4 x i32] [i32 0, i32 1, i32 0, i32 -7]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [19 x i8] c"\0A----------------\0A\00"
@.str.3 = [19 x i8] c"The average is %f\0A\00"
@.str.4 = [21 x i8] c"No negative numbers\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [10 x [10 x [10 x i32]]]
%7 = alloca [4 x i32]
%8 = alloca [4 x i32]
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
%10 = bitcast [4 x i32]* %7 to i8*
%11 = bitcast [4 x i32]* %8 to i8*
store float 0.000000e+00, float* %9
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
%14 = call i32 (...) @print_random_array()
store i32 0, i32* %2
br label %15
15: ; preds = %88, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %91
18: ; preds = %15
store i32 0, i32* %3
br label %19
19: ; preds = %83, %18
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 10
br i1 %21, label %22, label %86
22: ; preds = %19
store i32 0, i32* %4
br label %23
23: ; preds = %78, %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %81
26: ; preds = %23
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 11
%29 = add nsw i32 -5, %28
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x [10 x [10 x i32]]], [10 x [10 x [10 x i32]]]* %6, i64 0, i64 %31
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %32, i64 0, i64 %34
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %35, i64 0, i64 %37
store i32 %29, i32* %38
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x [10 x [10 x i32]]], [10 x [10 x [10 x i32]]]* %6, i64 0, i64 %40
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %41, i64 0, i64 %43
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %44, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %66
50: ; preds = %26
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
%53 = load i32, i32* %2
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x [10 x [10 x i32]]], [10 x [10 x [10 x i32]]]* %6, i64 0, i64 %54
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %55, i64 0, i64 %57
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %58, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = sitofp i32 %62 to float
%64 = load float, float* %9
%65 = fadd float %64, %63
store float %65, float* %9
br label %66
66: ; preds = %50, %26
%67 = load i32, i32* %2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [10 x [10 x [10 x i32]]], [10 x [10 x [10 x i32]]]* %6, i64 0, i64 %68
%70 = load i32, i32* %3
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %69, i64 0, i64 %71
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [10 x i32], [10 x i32]* %72, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %66
%79 = load i32, i32* %4
%80 = add nsw i32 %79, 1
store i32 %80, i32* %4
br label %23
81: ; preds = %23
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %83
83: ; preds = %81
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 1
store i32 %85, i32* %3
br label %19
86: ; preds = %19
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %88
88: ; preds = %86
%89 = load i32, i32* %2
%90 = add nsw i32 %89, 1
store i32 %90, i32* %2
br label %15
91: ; preds = %15
%92 = load i32, i32* %5
%93 = icmp sgt i32 %92, 0
br i1 %93, label %94, label %101
94: ; preds = %91
%95 = load float, float* %9
%96 = load i32, i32* %5
%97 = sitofp i32 %96 to float
%98 = fdiv float %95, %97
%99 = fpext float %98 to double
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %99)
br label %103
101: ; preds = %91
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %103
103: ; preds = %101, %94
%104 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%105 = call i32 @print_int_array(i32 4, i32* %104)
%106 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%107 = call i32 @print_int_array(i32 4, i32* %106)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array2 = [4 x i32] [i32 3, i32 5, i32 1, i32 -23]
@__const.main.array4 = [4 x i32] [i32 0, i32 1, i32 0, i32 -7]
@.str = [4 x i8] c"%d \00"
@.str.3 = [19 x i8] c"The average is %f\0A\00"
@str = [20 x i8] c"No negative numbers\00"
@str.5 = [18 x i8] c"\0A----------------\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 (...) @print_random_array()
br label %8
8: ; preds = %0, %36
%9 = phi float [ 0.000000e+00, %0 ], [ %28, %36 ]
%10 = phi i32 [ 0, %0 ], [ %26, %36 ]
%11 = phi i32 [ 0, %0 ], [ %38, %36 ]
br label %12
12: ; preds = %8, %32
%13 = phi float [ %9, %8 ], [ %28, %32 ]
%14 = phi i32 [ %10, %8 ], [ %26, %32 ]
%15 = phi i32 [ 0, %8 ], [ %34, %32 ]
br label %16
16: ; preds = %12, %16
%17 = phi float [ %13, %12 ], [ %28, %16 ]
%18 = phi i32 [ %14, %12 ], [ %26, %16 ]
%19 = phi i32 [ 0, %12 ], [ %30, %16 ]
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 11
%22 = add nsw i32 %21, -5
%23 = icmp slt i32 %21, 5
%24 = sitofp i32 %22 to float
%25 = zext i1 %23 to i32
%26 = add nsw i32 %18, %25
%27 = select i1 %23, float %24, float -0.000000e+00
%28 = fadd float %17, %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%30 = add nuw nsw i32 %19, 1
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %16
32: ; preds = %16
%33 = tail call i32 @putchar(i32 10)
%34 = add nuw nsw i32 %15, 1
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %12
36: ; preds = %32
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
%38 = add nuw nsw i32 %11, 1
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %8
40: ; preds = %36
%41 = icmp sgt i32 %26, 0
br i1 %41, label %42, label %47
42: ; preds = %40
%43 = sitofp i32 %26 to float
%44 = fdiv float %28, %43
%45 = fpext float %44 to double
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %45)
br label %49
47: ; preds = %40
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %47, %42
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%51 = call i32 @print_int_array(i32 4, i32* %50)
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%53 = call i32 @print_int_array(i32 4, i32* %52)
ret i32 0
}