#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 *, char const *, ...);
int /*<<< orphan*/ putchar(char);
void ListCommands(const char *cmds[], const char *separator) {
  if (!cmds || !separator)
    return;
  for (const char **pcmd = &cmds[0]; *pcmd != NULL; ++pcmd) {
    const char *cmd = *pcmd;
    if (*(pcmd + 1) == NULL) {
      printf("\"%s\"", cmd);
    } else {
      printf("\"%s\"%s ", cmd, separator);
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<ListCommands>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1146 <ListCommands+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    114b <ListCommands+0x2b>
jmp    11c8 <ListCommands+0xa8>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11be <ListCommands+0x9e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1192 <ListCommands+0x72>
mov    -0x20(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a8 <ListCommands+0x88>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ad <ListCommands+0x8d>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1153 <ListCommands+0x33>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ListCommands>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     118b <ListCommands+0x6b>
mov    %rsi,%r14
test   %rsi,%rsi
je     118b <ListCommands+0x6b>
mov    %rdi,%rbx
mov    (%rdi),%rsi
test   %rsi,%rsi
je     1197 <ListCommands+0x77>
add    $0x8,%rbx
lea    0xeb5(%rip),%r15
lea    0xeb3(%rip),%r12
jmp    1179 <ListCommands+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
je     1197 <ListCommands+0x77>
cmpq   $0x0,(%rbx)
jne    1160 <ListCommands+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116d <ListCommands+0x4d>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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