#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 array_print_full(int *arr, int n, const char *sep, const char *start,
                      const char *end) {
  int i = 0;
  if (start != NULL) {
    printf("%s", start);
  }
  if (n > 0) {
    if (sep != NULL) {
      for (i = 0; i < n - 1; i++) {
        printf("%d%s", arr[i], sep);
      }
    } else {
      for (i = 0; i < n - 1; i++) {
        printf("%d", arr[i]);
      }
    }
    printf("%d", arr[i]);
  }
  if (end != NULL) {
    printf("%s", end);
  }
}


x86 assembly (clang, -O0):
<array_print_full>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     114f <array_print_full+0x3f>
mov    -0x20(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1209 <array_print_full+0xf9>
cmpq   $0x0,-0x18(%rbp)
je     11ac <array_print_full+0x9c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a7 <array_print_full+0x97>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x18(%rbp),%rdx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116b <array_print_full+0x5b>
jmp    11f0 <array_print_full+0xe0>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11eb <array_print_full+0xdb>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b3 <array_print_full+0xa3>
jmp    11f0 <array_print_full+0xe0>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1226 <array_print_full+0x116>
mov    -0x28(%rbp),%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_print_full>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbx
test   %rcx,%rcx
je     113d <array_print_full+0x2d>
lea    0xecf(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r12d,%r12d
jle    11dc <array_print_full+0xcc>
lea    -0x1(%r12),%r13d
xor    %eax,%eax
test   %r15,%r15
je     1190 <array_print_full+0x80>
cmp    $0x1,%r12d
je     11c9 <array_print_full+0xb9>
mov    %r13d,0x4(%rsp)
mov    %r13d,%ebp
lea    0xe99(%rip),%r12
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r13,4),%esi
mov    %r12,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%rbp
jne    1170 <array_print_full+0x60>
mov    0x4(%rsp),%eax
jmp    11c9 <array_print_full+0xb9>
cmp    $0x1,%r12d
je     11c9 <array_print_full+0xb9>
mov    %r13d,%r12d
lea    0xe65(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11b0 <array_print_full+0xa0>
mov    %r13d,%eax
mov    %eax,%eax
mov    (%rbx,%rax,4),%esi
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r14,%r14
je     1200 <array_print_full+0xf0>
lea    0xe1a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%d%s\00"
@.str.2 = [3 x i8] c"%d\00"
define void @array_print_full(i32* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i32 0, i32* %11
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i8*, i8** %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %5
%18 = load i32, i32* %7
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %65
20: ; preds = %17
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %41
23: ; preds = %20
store i32 0, i32* %11
br label %24
24: ; preds = %37, %23
%25 = load i32, i32* %11
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %40
29: ; preds = %24
%30 = load i32*, i32** %6
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i8*, i8** %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34, i8* %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %24
40: ; preds = %24
br label %58
41: ; preds = %20
store i32 0, i32* %11
br label %42
42: ; preds = %54, %41
%43 = load i32, i32* %11
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 1
%46 = icmp slt i32 %43, %45
br i1 %46, label %47, label %57
47: ; preds = %42
%48 = load i32*, i32** %6
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %42
57: ; preds = %42
br label %58
58: ; preds = %57, %40
%59 = load i32*, i32** %6
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %58, %17
%66 = load i8*, i8** %10
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i8*, i8** %10
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %68, %65
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%d%s\00"
@.str.2 = [3 x i8] c"%d\00"
define void @array_print_full(i32* nocapture %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = icmp eq i8* %3, null
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %9
9: ; preds = %7, %5
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %41
11: ; preds = %9
%12 = icmp eq i8* %2, null
%13 = add nsw i32 %1, -1
%14 = icmp eq i32 %1, 1
br i1 %12, label %18, label %15
15: ; preds = %11
br i1 %14, label %35, label %16
16: ; preds = %15
%17 = zext i32 %13 to i64
br label %21
18: ; preds = %11
br i1 %14, label %35, label %19
19: ; preds = %18
%20 = zext i32 %13 to i64
br label %28
21: ; preds = %16, %21
%22 = phi i64 [ 0, %16 ], [ %26, %21 ]
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24, i8* %2)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %35, label %21
28: ; preds = %19, %28
%29 = phi i64 [ 0, %19 ], [ %33, %28 ]
%30 = getelementptr inbounds i32, i32* %0, i64 %29
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = add nuw nsw i64 %29, 1
%34 = icmp eq i64 %33, %20
br i1 %34, label %35, label %28
35: ; preds = %21, %28, %15, %18
%36 = phi i32 [ 0, %18 ], [ 0, %15 ], [ %13, %28 ], [ %13, %21 ]
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %0, i64 %37
%39 = load i32, i32* %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35, %9
%42 = icmp eq i8* %4, null
br i1 %42, label %45, label %43
43: ; preds = %41
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %45
45: ; preds = %43, %41
ret void
}