#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*/ printf(char *, ...);
void print_array(int nums[], int len) {
  printf("[");
  for (int i = 0; i < len; i++) {
    if (i < len - 1) {
      printf("%d, ", nums[i]);
    } else {
      printf("%d", nums[i]);
    }
    if (((i + 1) % 5 == 0) && (i != len - 1)) {
      printf("\n");
    }
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <print_array+0xc1>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    116f <print_array+0x5f>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <print_array+0x78>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11be <print_array+0xae>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11be <print_array+0xae>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <print_array+0xb3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <print_array+0x24>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,(%rsp)
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    11d0 <print_array+0xa0>
lea    -0x1(%r14),%ebx
mov    %r14d,%r14d
mov    $0x1,%ebp
xor    %r12d,%r12d
jmp    1178 <print_array+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %r12,%r14
je     11d0 <print_array+0xa0>
mov    %r12,%r13
mov    %ebp,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%r15d
add    $0xffffffff,%r15d
cmp    %rbx,%r12
mov    (%rsp),%rax
mov    (%rax,%r12,4),%esi
lea    0xe61(%rip),%rdi
lea    0xe55(%rip),%rax
cmovb  %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
cmp    %r13d,%r15d
jne    1170 <print_array+0x40>
cmp    %r13,%rbx
je     1170 <print_array+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <print_array+0x40>
lea    0xe31(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [2 x i8] c"]\00"
define void @print_array(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @putchar(i32 91)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = add nsw i32 %1, -1
%7 = zext i32 %6 to i64
%8 = zext i32 %6 to i64
%9 = zext i32 %1 to i64
br label %12
10: ; preds = %27, %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
12: ; preds = %5, %27
%13 = phi i64 [ 0, %5 ], [ %19, %27 ]
%14 = icmp ult i64 %13, %8
%15 = getelementptr inbounds i32, i32* %0, i64 %13
%16 = load i32, i32* %15
%17 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17, i32 %16)
%19 = add nuw nsw i64 %13, 1
%20 = trunc i64 %19 to i32
%21 = urem i32 %20, 5
%22 = icmp ne i32 %21, 0
%23 = icmp eq i64 %13, %7
%24 = select i1 %22, i1 true, i1 %23
br i1 %24, label %27, label %25
25: ; preds = %12
%26 = tail call i32 @putchar(i32 10)
br label %27
27: ; preds = %12, %25
%28 = icmp eq i64 %19, %9
br i1 %28, label %10, label %12
}