#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 */
char *EnvGetDefmoduleName(void *, void *);
void *EnvGetNextDefmodule(void *, void *);
int /*<<< orphan*/ EnvPrintRouter(void *, char const *, char *);
int /*<<< orphan*/ PrintTally(void *, char const *, int, char *, char *);
void EnvListDefmodules(void *theEnv, const char *logicalName) {
  void *theModule;
  int count = 0;
  for (theModule = EnvGetNextDefmodule(theEnv, NULL); theModule != NULL;
       theModule = EnvGetNextDefmodule(theEnv, theModule)) {
    EnvPrintRouter(theEnv, logicalName, EnvGetDefmoduleName(theEnv, theModule));
    EnvPrintRouter(theEnv, logicalName, "\n");
    count++;
  }
  PrintTally(theEnv, logicalName, count, "defmodule", "defmodules");
}


x86 assembly (clang, -O0):
<EnvListDefmodules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <EnvGetNextDefmodule@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d3 <EnvListDefmodules+0x93>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <EnvGetDefmoduleName@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
call   1030 <EnvPrintRouter@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe51(%rip),%rdx
call   1030 <EnvPrintRouter@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <EnvGetNextDefmodule@plt>
mov    %rax,-0x18(%rbp)
jmp    1168 <EnvListDefmodules+0x28>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe1d(%rip),%rcx
lea    0xe20(%rip),%r8
call   1040 <PrintTally@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EnvListDefmodules>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %r12d,%r12d
xor    %esi,%esi
call   1060 <EnvGetNextDefmodule@plt>
test   %rax,%rax
je     11ae <EnvListDefmodules+0x6e>
mov    %rax,%rbx
xor    %r12d,%r12d
lea    0xe95(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <EnvGetDefmoduleName@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <EnvPrintRouter@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1030 <EnvPrintRouter@plt>
add    $0x1,%r12d
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <EnvGetNextDefmodule@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <EnvListDefmodules+0x30>
lea    0xe4d(%rip),%rcx
lea    0xe50(%rip),%r8
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <PrintTally@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [10 x i8] c"defmodule\00"
@.str.2 = [11 x i8] c"defmodules\00"
define void @EnvListDefmodules(i8* %0, i8* %1) {
%3 = tail call i8* @EnvGetNextDefmodule(i8* %0, i8* null)
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %11, %5 ], [ 0, %2 ]
%7 = phi i8* [ %12, %5 ], [ %3, %2 ]
%8 = tail call i8* @EnvGetDefmoduleName(i8* %0, i8* %7)
%9 = tail call i32 @EnvPrintRouter(i8* %0, i8* %1, i8* %8)
%10 = tail call i32 @EnvPrintRouter(i8* %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = add nuw nsw i32 %6, 1
%12 = tail call i8* @EnvGetNextDefmodule(i8* %0, i8* %7)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %5
14: ; preds = %5, %2
%15 = phi i32 [ 0, %2 ], [ %11, %5 ]
%16 = tail call i32 @PrintTally(i8* %0, i8* %1, i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
ret void
}