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

/* Variables and functions */
int /*<<< orphan*/ DumpWord(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ luaL_verror(char *, int, char *);
void DumpString(char *s, int size, FILE *D) {
  if (s == NULL)
    DumpWord(0, D);
  else {
    if (((unsigned short)size != size))
      luaL_verror("string too long (%d bytes): \"%.32s...\"", size, s);
    DumpWord(size, D);
    fwrite(s, size, 1, D);
  }
}


x86 assembly (clang, -O0):
<DumpString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115e <DumpString+0x2e>
mov    -0x18(%rbp),%rsi
xor    %edi,%edi
call   1030 <DumpWord@plt>
jmp    11a1 <DumpString+0x71>
mov    -0xc(%rbp),%eax
movzwl %ax,%eax
cmp    -0xc(%rbp),%eax
je     1180 <DumpString+0x50>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe85(%rip),%rdi
call   1040 <luaL_verror@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <DumpWord@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1050 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpString>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
test   %rdi,%rdi
je     117a <DumpString+0x4a>
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0x10000,%esi
jb     115a <DumpString+0x2a>
lea    0xeb0(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <luaL_verror@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <DumpWord@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <fwrite@plt>
xor    %edi,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <DumpWord@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"string too long (%d bytes): \22%.32s...\22\00"
define void @DumpString(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32*, i32** %6
%11 = call i32 @DumpWord(i32 0, i32* %10)
br label %30
12: ; preds = %3
%13 = load i32, i32* %5
%14 = trunc i32 %13 to i16
%15 = zext i16 %14 to i32
%16 = load i32, i32* %5
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* %5
%20 = load i8*, i8** %4
%21 = call i32 @luaL_verror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %20)
br label %22
22: ; preds = %18, %12
%23 = load i32, i32* %5
%24 = load i32*, i32** %6
%25 = call i32 @DumpWord(i32 %23, i32* %24)
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = load i32*, i32** %6
%29 = call i32 @fwrite(i8* %26, i32 %27, i32 1, i32* %28)
br label %30
30: ; preds = %22, %9
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"string too long (%d bytes): \22%.32s...\22\00"
define void @DumpString(i8* %0, i32 %1, i32* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @DumpWord(i32 0, i32* %2)
br label %14
7: ; preds = %3
%8 = icmp ult i32 %1, 65536
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = tail call i32 @luaL_verror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %0)
br label %11
11: ; preds = %9, %7
%12 = tail call i32 @DumpWord(i32 %1, i32* %2)
%13 = tail call i32 @fwrite(i8* %0, i32 %1, i32 1, i32* %2)
br label %14
14: ; preds = %11, %5
ret void
}