#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_array(int *, int);
int /*<<< orphan*/ radix_sort(int *, int, int);
int /*<<< orphan*/ random_array(int *, int);
int main(void) {
  int a[20];
  random_array(a, 20);
  for (int i = 0; i < 20; ++i)
    if (a[i] == 0)
      a[i] = 1;
  print_array(a, 20);
  radix_sort(a, 20, 2);
  print_array(a, 20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1050 <random_array@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    118c <main+0x5c>
movslq -0x64(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
jne    1179 <main+0x49>
movslq -0x64(%rbp),%rax
movl   $0x1,-0x60(%rbp,%rax,4)
jmp    117e <main+0x4e>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1154 <main+0x24>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1030 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
mov    $0x2,%edx
call   1040 <radix_sort@plt>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
mov    %rsp,%rdi
mov    $0x14,%esi
call   1050 <random_array@plt>
cmpl   $0x0,(%rsp)
je     1254 <main+0x124>
cmpl   $0x0,0x4(%rsp)
je     1266 <main+0x136>
cmpl   $0x0,0x8(%rsp)
je     1279 <main+0x149>
cmpl   $0x0,0xc(%rsp)
je     128c <main+0x15c>
cmpl   $0x0,0x10(%rsp)
je     129f <main+0x16f>
cmpl   $0x0,0x14(%rsp)
je     12b2 <main+0x182>
cmpl   $0x0,0x18(%rsp)
je     12c5 <main+0x195>
cmpl   $0x0,0x1c(%rsp)
je     12d8 <main+0x1a8>
cmpl   $0x0,0x20(%rsp)
je     12eb <main+0x1bb>
cmpl   $0x0,0x24(%rsp)
je     12fe <main+0x1ce>
cmpl   $0x0,0x28(%rsp)
je     1311 <main+0x1e1>
cmpl   $0x0,0x2c(%rsp)
je     1324 <main+0x1f4>
cmpl   $0x0,0x30(%rsp)
je     1337 <main+0x207>
cmpl   $0x0,0x34(%rsp)
je     134a <main+0x21a>
cmpl   $0x0,0x38(%rsp)
je     135d <main+0x22d>
cmpl   $0x0,0x3c(%rsp)
je     1370 <main+0x240>
cmpl   $0x0,0x40(%rsp)
je     1383 <main+0x253>
cmpl   $0x0,0x44(%rsp)
je     1396 <main+0x266>
cmpl   $0x0,0x48(%rsp)
je     13a9 <main+0x279>
cmpl   $0x0,0x4c(%rsp)
je     13bc <main+0x28c>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <print_array@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
mov    $0x2,%edx
call   1040 <radix_sort@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret
movl   $0x1,(%rsp)
cmpl   $0x0,0x4(%rsp)
jne    1157 <main+0x27>
movl   $0x1,0x4(%rsp)
cmpl   $0x0,0x8(%rsp)
jne    1162 <main+0x32>
movl   $0x1,0x8(%rsp)
cmpl   $0x0,0xc(%rsp)
jne    116d <main+0x3d>
movl   $0x1,0xc(%rsp)
cmpl   $0x0,0x10(%rsp)
jne    1178 <main+0x48>
movl   $0x1,0x10(%rsp)
cmpl   $0x0,0x14(%rsp)
jne    1183 <main+0x53>
movl   $0x1,0x14(%rsp)
cmpl   $0x0,0x18(%rsp)
jne    118e <main+0x5e>
movl   $0x1,0x18(%rsp)
cmpl   $0x0,0x1c(%rsp)
jne    1199 <main+0x69>
movl   $0x1,0x1c(%rsp)
cmpl   $0x0,0x20(%rsp)
jne    11a4 <main+0x74>
movl   $0x1,0x20(%rsp)
cmpl   $0x0,0x24(%rsp)
jne    11af <main+0x7f>
movl   $0x1,0x24(%rsp)
cmpl   $0x0,0x28(%rsp)
jne    11ba <main+0x8a>
movl   $0x1,0x28(%rsp)
cmpl   $0x0,0x2c(%rsp)
jne    11c5 <main+0x95>
movl   $0x1,0x2c(%rsp)
cmpl   $0x0,0x30(%rsp)
jne    11d0 <main+0xa0>
movl   $0x1,0x30(%rsp)
cmpl   $0x0,0x34(%rsp)
jne    11db <main+0xab>
movl   $0x1,0x34(%rsp)
cmpl   $0x0,0x38(%rsp)
jne    11e6 <main+0xb6>
movl   $0x1,0x38(%rsp)
cmpl   $0x0,0x3c(%rsp)
jne    11f1 <main+0xc1>
movl   $0x1,0x3c(%rsp)
cmpl   $0x0,0x40(%rsp)
jne    11fc <main+0xcc>
movl   $0x1,0x40(%rsp)
cmpl   $0x0,0x44(%rsp)
jne    1207 <main+0xd7>
movl   $0x1,0x44(%rsp)
cmpl   $0x0,0x48(%rsp)
jne    1212 <main+0xe2>
movl   $0x1,0x48(%rsp)
cmpl   $0x0,0x4c(%rsp)
jne    121d <main+0xed>
movl   $0x1,0x4c(%rsp)
jmp    121d <main+0xed>

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @random_array(i32* %3, i32 20)
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 1, i32* %3
br label %8
8: ; preds = %0, %7
%9 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %9
br label %13
13: ; preds = %12, %8
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %14
br label %18
18: ; preds = %17, %13
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 3
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %19
br label %23
23: ; preds = %22, %18
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 4
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %24
br label %28
28: ; preds = %27, %23
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 5
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 1, i32* %29
br label %33
33: ; preds = %32, %28
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 6
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %34
br label %38
38: ; preds = %37, %33
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 7
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 1, i32* %39
br label %43
43: ; preds = %42, %38
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 8
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 1, i32* %44
br label %48
48: ; preds = %47, %43
%49 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 9
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 1, i32* %49
br label %53
53: ; preds = %52, %48
%54 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 10
%55 = load i32, i32* %54
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 1, i32* %54
br label %58
58: ; preds = %57, %53
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 11
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 1, i32* %59
br label %63
63: ; preds = %62, %58
%64 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 12
%65 = load i32, i32* %64
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %63
store i32 1, i32* %64
br label %68
68: ; preds = %67, %63
%69 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 13
%70 = load i32, i32* %69
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %68
store i32 1, i32* %69
br label %73
73: ; preds = %72, %68
%74 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 14
%75 = load i32, i32* %74
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %73
store i32 1, i32* %74
br label %78
78: ; preds = %77, %73
%79 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 15
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %78
store i32 1, i32* %79
br label %83
83: ; preds = %82, %78
%84 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 16
%85 = load i32, i32* %84
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %83
store i32 1, i32* %84
br label %88
88: ; preds = %87, %83
%89 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 17
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %93
92: ; preds = %88
store i32 1, i32* %89
br label %93
93: ; preds = %92, %88
%94 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 18
%95 = load i32, i32* %94
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %93
store i32 1, i32* %94
br label %98
98: ; preds = %97, %93
%99 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 19
%100 = load i32, i32* %99
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %98
store i32 1, i32* %99
br label %103
103: ; preds = %102, %98
%104 = call i32 @print_array(i32* %3, i32 20)
%105 = call i32 @radix_sort(i32* %3, i32 20, i32 2)
%106 = call i32 @print_array(i32* %3, i32 20)
ret i32 0
}