#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 printf_array(int a[]) {
  int *p = a;
  while (*p++ == 0)
    printf("%-3d", *(p - 1));
  p--;
  while (*p++ != 0)
    printf("%-3d", *(p - 1));
  printf("\n");
}


x86 assembly (clang, -O0):
<printf_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
cmpl   $0x0,(%rax)
jne    1156 <printf_array+0x46>
mov    -0x10(%rbp),%rax
mov    -0x4(%rax),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1124 <printf_array+0x14>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
cmpl   $0x0,(%rax)
je     1194 <printf_array+0x84>
mov    -0x10(%rbp),%rax
mov    -0x4(%rax),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <printf_array+0x52>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    (%rdi),%esi
test   %esi,%esi
je     1133 <printf_array+0x13>
mov    %r15,%rbx
jmp    115b <printf_array+0x3b>
lea    0xec6(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    0x4(%r15),%rbx
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%r15),%esi
mov    %rbx,%r15
test   %esi,%esi
je     1140 <printf_array+0x20>
add    $0x4,%rbx
lea    0xe9a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
add    $0x4,%rbx
test   %esi,%esi
jne    1170 <printf_array+0x50>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%-3d\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @printf_array(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
store i32* %4, i32** %3
br label %5
5: ; preds = %10, %1
%6 = load i32*, i32** %3
%7 = getelementptr inbounds i32, i32* %6, i32 1
store i32* %7, i32** %3
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 -1
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %5
15: ; preds = %5
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i32 -1
store i32* %17, i32** %3
br label %18
18: ; preds = %23, %15
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %3
%21 = load i32, i32* %19
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i64 -1
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %18
28: ; preds = %18
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%-3d\00"
define void @printf_array(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1, %4
%5 = phi i32* [ %6, %4 ], [ %0, %1 ]
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0)
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %4, %1
%11 = phi i32* [ %0, %1 ], [ %6, %4 ]
%12 = phi i32 [ %2, %1 ], [ %8, %4 ]
br label %13
13: ; preds = %10, %13
%14 = phi i32* [ %16, %13 ], [ %11, %10 ]
%15 = phi i32 [ %18, %13 ], [ %12, %10 ]
%16 = getelementptr inbounds i32, i32* %14, i64 1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%18 = load i32, i32* %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = tail call i32 @putchar(i32 10)
ret void
}