#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 constructHeader {
  int dummy;
};

/* Variables and functions */
char *EnvGetDefclassPPForm(void *, void *);
char *EnvGetDefmessageHandlerPPForm(void *, void *, unsigned int);
unsigned int EnvGetNextDefmessageHandler(void *, void *, unsigned int);
int /*<<< orphan*/ EnvPrintRouter(void *, char const *, char *);
int /*<<< orphan*/ PrintInChunks(void *, char const *, char const *);
void SaveDefclass(void *theEnv, struct constructHeader *theDefclass,
                  void *userBuffer) {
  const char *logName = (const char *)userBuffer;
  unsigned hnd;
  const char *ppForm;
  ppForm = EnvGetDefclassPPForm(theEnv, (void *)theDefclass);
  if (ppForm != NULL) {
    PrintInChunks(theEnv, logName, ppForm);
    EnvPrintRouter(theEnv, logName, "\n");
    hnd = EnvGetNextDefmessageHandler(theEnv, (void *)theDefclass, 0);
    while (hnd != 0) {
      ppForm = EnvGetDefmessageHandlerPPForm(theEnv, (void *)theDefclass, hnd);
      if (ppForm != NULL) {
        PrintInChunks(theEnv, logName, ppForm);
        EnvPrintRouter(theEnv, logName, "\n");
      }
      hnd = EnvGetNextDefmessageHandler(theEnv, (void *)theDefclass, hnd);
    }
  }
}


x86 assembly (clang, -O0):
<SaveDefclass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <EnvGetDefclassPPForm@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     122a <SaveDefclass+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <PrintInChunks@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xe58(%rip),%rdx
call   1040 <EnvPrintRouter@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1070 <EnvGetNextDefmessageHandler@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1225 <SaveDefclass+0xd5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <EnvGetDefmessageHandlerPPForm@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120d <SaveDefclass+0xbd>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <PrintInChunks@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xdf8(%rip),%rdx
call   1040 <EnvPrintRouter@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1070 <EnvGetNextDefmessageHandler@plt>
mov    %eax,-0x24(%rbp)
jmp    11bf <SaveDefclass+0x6f>
jmp    122a <SaveDefclass+0xda>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SaveDefclass>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1060 <EnvGetDefclassPPForm@plt>
test   %rax,%rax
je     11f3 <SaveDefclass+0xa3>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <PrintInChunks@plt>
lea    0xe7c(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <EnvPrintRouter@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1070 <EnvGetNextDefmessageHandler@plt>
test   %eax,%eax
je     11f3 <SaveDefclass+0xa3>
mov    %eax,%ebp
lea    0xe57(%rip),%r12
jmp    11c3 <SaveDefclass+0x73>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <EnvGetNextDefmessageHandler@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11f3 <SaveDefclass+0xa3>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <EnvGetDefmessageHandlerPPForm@plt>
test   %rax,%rax
je     11b0 <SaveDefclass+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <PrintInChunks@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <EnvPrintRouter@plt>
jmp    11b0 <SaveDefclass+0x60>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.constructHeader = type { i32 }
@.str = [2 x i8] c"\0A\00"
define void @SaveDefclass(i8* %0, %struct.constructHeader* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.constructHeader*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %4
store %struct.constructHeader* %1, %struct.constructHeader** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
store i8* %10, i8** %7
%11 = load i8*, i8** %4
%12 = load %struct.constructHeader*, %struct.constructHeader** %5
%13 = bitcast %struct.constructHeader* %12 to i8*
%14 = call i8* @EnvGetDefclassPPForm(i8* %11, i8* %13)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %55
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = load i8*, i8** %7
%20 = load i8*, i8** %9
%21 = call i32 @PrintInChunks(i8* %18, i8* %19, i8* %20)
%22 = load i8*, i8** %4
%23 = load i8*, i8** %7
%24 = call i32 @EnvPrintRouter(i8* %22, i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %4
%26 = load %struct.constructHeader*, %struct.constructHeader** %5
%27 = bitcast %struct.constructHeader* %26 to i8*
%28 = call i32 @EnvGetNextDefmessageHandler(i8* %25, i8* %27, i32 0)
store i32 %28, i32* %8
br label %29
29: ; preds = %48, %17
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %54
32: ; preds = %29
%33 = load i8*, i8** %4
%34 = load %struct.constructHeader*, %struct.constructHeader** %5
%35 = bitcast %struct.constructHeader* %34 to i8*
%36 = load i32, i32* %8
%37 = call i8* @EnvGetDefmessageHandlerPPForm(i8* %33, i8* %35, i32 %36)
store i8* %37, i8** %9
%38 = load i8*, i8** %9
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %48
40: ; preds = %32
%41 = load i8*, i8** %4
%42 = load i8*, i8** %7
%43 = load i8*, i8** %9
%44 = call i32 @PrintInChunks(i8* %41, i8* %42, i8* %43)
%45 = load i8*, i8** %4
%46 = load i8*, i8** %7
%47 = call i32 @EnvPrintRouter(i8* %45, i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %40, %32
%49 = load i8*, i8** %4
%50 = load %struct.constructHeader*, %struct.constructHeader** %5
%51 = bitcast %struct.constructHeader* %50 to i8*
%52 = load i32, i32* %8
%53 = call i32 @EnvGetNextDefmessageHandler(i8* %49, i8* %51, i32 %52)
store i32 %53, i32* %8
br label %29
54: ; preds = %29
br label %55
55: ; preds = %54, %3
ret void
}

LLVM IR (-O2):
%struct.constructHeader = type { i32 }
@.str = [2 x i8] c"\0A\00"
define void @SaveDefclass(i8* %0, %struct.constructHeader* %1, i8* %2) {
%4 = bitcast %struct.constructHeader* %1 to i8*
%5 = tail call i8* @EnvGetDefclassPPForm(i8* %0, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %22, label %7
7: ; preds = %3
%8 = tail call i32 @PrintInChunks(i8* %0, i8* %2, i8* %5)
%9 = tail call i32 @EnvPrintRouter(i8* %0, i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @EnvGetNextDefmessageHandler(i8* %0, i8* %4, i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %7, %19
%13 = phi i32 [ %20, %19 ], [ %10, %7 ]
%14 = tail call i8* @EnvGetDefmessageHandlerPPForm(i8* %0, i8* %4, i32 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i32 @PrintInChunks(i8* %0, i8* %2, i8* %14)
%18 = tail call i32 @EnvPrintRouter(i8* %0, i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %12
%20 = tail call i32 @EnvGetNextDefmessageHandler(i8* %0, i8* %4, i32 %13)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %19, %7, %3
ret void
}