#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 n, char *arr[], char sep) {
  for (int i = --n; i > 0; --i) {
    printf("%s", arr[i]);
    if (i != 1)
      printf("%c", sep);
    else
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1196 <print_array+0x86>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
je     1175 <print_array+0x65>
movsbl -0x11(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1183 <print_array+0x73>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <print_array+0x78>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <print_array+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jl     117f <print_array+0x5f>
mov    %rsi,%r15
movsbl %dl,%ebp
mov    %edi,%ebx
add    $0xffffffffffffffff,%rbx
lea    0xec0(%rip),%r14
mov    $0xa,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%eax
mov    (%r15,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
mov    %ebp,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%rax
add    $0x1,%rbx
cmp    $0x2,%rbx
mov    %rax,%rbx
ja     1150 <print_array+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @print_array(i32 %0, i8** nocapture %1, i8 signext %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = sext i8 %2 to i32
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %9, %3
ret void
9: ; preds = %5, %9
%10 = phi i64 [ %7, %5 ], [ %11, %9 ]
%11 = add nsw i64 %10, -1
%12 = trunc i64 %11 to i32
%13 = and i64 %11, 4294967295
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp eq i32 %12, 1
%18 = select i1 %17, i32 10, i32 %6
%19 = tail call i32 @putchar(i32 %18)
%20 = icmp ugt i64 %10, 2
br i1 %20, label %9, label %8
}