#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 */
struct initrec {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dump_rec(char const *, int, struct initrec *);
int /*<<< orphan*/ printf(char *, ...);
void dump_tab(const char *var, struct initrec **inittab) {
  const char *rec = "irec";
  struct initrec *p, **pp;
  int i, n;
  for (i = 0, pp = inittab; (p = *pp); pp++, i++)
    dump_rec(rec, i, p);
  n = i;
  printf("static struct initrec* %s[] = {\n", var);
  printf("\tNULL,\n");
  for (i = 0; i < n; i++)
    printf("\t&%s%i,\n", rec, i);
  printf("\tNULL\n");
  printf("};\n\n");
}


x86 assembly (clang, -O0):
<dump_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1189 <dump_tab+0x69>
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <dump_rec@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114a <dump_tab+0x2a>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11e5 <dump_tab+0xc5>
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b6 <dump_tab+0x96>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_tab>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rsi),%rdx
test   %rdx,%rdx
je     116a <dump_tab+0x3a>
mov    %rsi,%r15
xor    %ebx,%ebx
lea    0xeb1(%rip),%r12
nop
mov    %r12,%rdi
mov    %ebx,%esi
call   1050 <dump_rec@plt>
mov    0x8(%r15,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    1150 <dump_tab+0x20>
jmp    116c <dump_tab+0x3c>
xor    %ebx,%ebx
lea    0xe92(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
je     11b6 <dump_tab+0x86>
lea    0xe92(%rip),%r14
lea    0xe65(%rip),%r15
xor    %ebp,%ebp
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11a0 <dump_tab+0x70>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.initrec = type { i32 }
@.str = [5 x i8] c"irec\00"
@.str.1 = [33 x i8] c"static struct initrec* %s[] = {\0A\00"
@.str.2 = [8 x i8] c"\09NULL,\0A\00"
@.str.3 = [9 x i8] c"\09&%s%i,\0A\00"
@.str.4 = [7 x i8] c"\09NULL\0A\00"
@.str.5 = [5 x i8] c"};\0A\0A\00"
define void @dump_tab(i8* %0, %struct.initrec** %1) {
%3 = alloca i8*
%4 = alloca %struct.initrec**
%5 = alloca i8*
%6 = alloca %struct.initrec*
%7 = alloca %struct.initrec**
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store %struct.initrec** %1, %struct.initrec*** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %5
store i32 0, i32* %8
%10 = load %struct.initrec**, %struct.initrec*** %4
store %struct.initrec** %10, %struct.initrec*** %7
br label %11
11: ; preds = %20, %2
%12 = load %struct.initrec**, %struct.initrec*** %7
%13 = load %struct.initrec*, %struct.initrec** %12
store %struct.initrec* %13, %struct.initrec** %6
%14 = icmp ne %struct.initrec* %13, null
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i32, i32* %8
%18 = load %struct.initrec*, %struct.initrec** %6
%19 = call i32 @dump_rec(i8* %16, i32 %17, %struct.initrec* %18)
br label %20
20: ; preds = %15
%21 = load %struct.initrec**, %struct.initrec*** %7
%22 = getelementptr inbounds %struct.initrec*, %struct.initrec** %21, i32 1
store %struct.initrec** %22, %struct.initrec*** %7
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
br label %11
25: ; preds = %11
%26 = load i32, i32* %8
store i32 %26, i32* %9
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %30
30: ; preds = %38, %25
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i8*, i8** %5
%36 = load i32, i32* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %35, i32 %36)
br label %38
38: ; preds = %34
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %30
41: ; preds = %30
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.initrec = type { i32 }
@.str = [5 x i8] c"irec\00"
@.str.1 = [33 x i8] c"static struct initrec* %s[] = {\0A\00"
@.str.3 = [9 x i8] c"\09&%s%i,\0A\00"
@str = [7 x i8] c"\09NULL,\00"
@str.6 = [6 x i8] c"\09NULL\00"
@str.7 = [4 x i8] c"};\0A\00"
define void @dump_tab(i8* %0, %struct.initrec** nocapture %1) {
%3 = load %struct.initrec*, %struct.initrec** %1
%4 = icmp eq %struct.initrec* %3, null
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi %struct.initrec* [ %12, %5 ], [ %3, %2 ]
%7 = phi %struct.initrec** [ %10, %5 ], [ %1, %2 ]
%8 = phi i32 [ %11, %5 ], [ 0, %2 ]
%9 = tail call i32 @dump_rec(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8, %struct.initrec* %6)
%10 = getelementptr inbounds %struct.initrec*, %struct.initrec** %7, i64 1
%11 = add nuw nsw i32 %8, 1
%12 = load %struct.initrec*, %struct.initrec** %10
%13 = icmp eq %struct.initrec* %12, null
br i1 %13, label %14, label %5
14: ; preds = %5, %2
%15 = phi i32 [ 0, %2 ], [ %11, %5 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%18 = icmp eq i32 %15, 0
br i1 %18, label %24, label %19
19: ; preds = %14, %19
%20 = phi i32 [ %22, %19 ], [ 0, %14 ]
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = add nuw i32 %20, 1
%23 = icmp eq i32 %22, %15
br i1 %23, label %24, label %19
24: ; preds = %19, %14
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0))
ret void
}