#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 expr {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
long HashedExpressionIndex(void *, struct expr *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void PrintHashedExpressionReference(void *theEnv, FILE *theFile,
                                    struct expr *theExpression, int imageID,
                                    int maxIndices) {
  long theIDValue;
  if (theExpression == NULL) {
    fprintf(theFile, "NULL");
  } else {
    theIDValue = HashedExpressionIndex(theEnv, theExpression);
    fprintf(theFile, "&E%d_%ld[%ld]", imageID, theIDValue / maxIndices,
            theIDValue % maxIndices);
  }
}


x86 assembly (clang, -O0):
<PrintHashedExpressionReference>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115d <PrintHashedExpressionReference+0x3d>
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11a9 <PrintHashedExpressionReference+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <HashedExpressionIndex@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rsi
cqto
idiv   %rsi
mov    %rdx,%r8
mov    -0x2c(%rbp),%edx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintHashedExpressionReference>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
test   %rdx,%rdx
je     1163 <PrintHashedExpressionReference+0x33>
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %rdx,%rsi
call   1050 <HashedExpressionIndex@plt>
movslq %ebp,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1180 <PrintHashedExpressionReference+0x50>
cqto
idiv   %rcx
mov    %rdx,%r8
jmp    1187 <PrintHashedExpressionReference+0x57>
lea    0xe96(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fwrite@plt>
xor    %edx,%edx
div    %ebp
mov    %edx,%r8d
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
%struct.expr = type { i32 }
@.str = [5 x i8] c"NULL\00"
@.str.1 = [14 x i8] c"&E%d_%ld[%ld]\00"
define void @PrintHashedExpressionReference(i8* %0, i32* %1, %struct.expr* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.expr*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i8* %0, i8** %6
store i32* %1, i32** %7
store %struct.expr* %2, %struct.expr** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load %struct.expr*, %struct.expr** %8
%13 = icmp eq %struct.expr* %12, null
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32*, i32** %7
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %32
17: ; preds = %5
%18 = load i8*, i8** %6
%19 = load %struct.expr*, %struct.expr** %8
%20 = call i64 @HashedExpressionIndex(i8* %18, %struct.expr* %19)
store i64 %20, i64* %11
%21 = load i32*, i32** %7
%22 = load i32, i32* %9
%23 = load i64, i64* %11
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = sdiv i64 %23, %25
%27 = load i64, i64* %11
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = srem i64 %27, %29
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %22, i64 %26, i64 %30)
br label %32
32: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
%struct.expr = type { i32 }
@.str = [5 x i8] c"NULL\00"
@.str.1 = [14 x i8] c"&E%d_%ld[%ld]\00"
define void @PrintHashedExpressionReference(i8* %0, i32* nocapture %1, %struct.expr* %2, i32 %3, i32 %4) {
%6 = icmp eq %struct.expr* %2, null
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4, i64 1, i32* %1)
br label %15
9: ; preds = %5
%10 = tail call i64 @HashedExpressionIndex(i8* %0, %struct.expr* %2)
%11 = sext i32 %4 to i64
%12 = sdiv i64 %10, %11
%13 = srem i64 %10, %11
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %3, i64 %12, i64 %13)
br label %15
15: ; preds = %9, %7
ret void
}