#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 *quote(char *);
void dump_env(const char *var, char **list) {
  char **p;
  printf("static char* %s[] = {\n", var);
  for (p = list; *p; p++)
    printf("\t%s,\n", quote(*p));
  printf("\tNULL\n");
  printf("};\n\n");
}


x86 assembly (clang, -O0):
<dump_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1186 <dump_env+0x66>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <quote@plt>
mov    %rax,%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    114a <dump_env+0x2a>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_env>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     117e <dump_env+0x4e>
add    $0x8,%rbx
lea    0xebc(%rip),%r14
nopl   0x0(%rax,%rax,1)
call   1050 <quote@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1160 <dump_env+0x30>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [23 x i8] c"static char* %s[] = {\0A\00"
@.str.1 = [6 x i8] c"\09%s,\0A\00"
@str = [6 x i8] c"\09NULL\00"
@str.4 = [4 x i8] c"};\0A\00"
define void @dump_env(i8* %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i8* [ %12, %6 ], [ %4, %2 ]
%8 = phi i8** [ %11, %6 ], [ %1, %2 ]
%9 = tail call i8* @quote(i8* %7)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds i8*, i8** %8, i64 1
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0))
ret void
}