#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_enum(const char *enum_table[]) {
  unsigned int i;
  printf(" = [");
  for (i = 0; enum_table[i] != NULL; i++)
    if (enum_table[i + 1] == NULL)
      printf("%s]", enum_table[i]);
    else
      printf("%s | ", enum_table[i]);
}


x86 assembly (clang, -O0):
<print_enum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
je     11a4 <print_enum+0x94>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    1178 <print_enum+0x68>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1191 <print_enum+0x81>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1196 <print_enum+0x86>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <print_enum+0x21>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_enum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r12),%rsi
test   %rsi,%rsi
je     1171 <print_enum+0x61>
mov    $0x1,%ebp
lea    0xec7(%rip),%r14
lea    0xec4(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%ebx
cmpq   $0x0,(%r12,%rbx,8)
mov    %r15,%rdi
cmove  %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x1,%ebp
test   %rsi,%rsi
jne    1150 <print_enum+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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