#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 */
int /*<<< orphan*/ internalCheckFail(char *, char *, int);
void putLexShort(int shortValue, char **writePointer) {
  {
    if (!(shortValue <= 65535))
      internalCheckFail("shortValue <= 65535",
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/thoni56/"
                        "c-xrefactory/refs/heads/main/src/lexembuffer.c",
                        27);
  };
  **writePointer = ((unsigned)shortValue) % 256;
  (*writePointer)++;
  **writePointer = ((unsigned)shortValue) / 256;
  (*writePointer)++;
}


x86 assembly (clang, -O0):
<putLexShort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0xffff,-0x4(%rbp)
jle    1144 <putLexShort+0x34>
lea    0xecd(%rip),%rdi
lea    0xeda(%rip),%rsi
mov    $0x1b,%edx
call   1030 <internalCheckFail@plt>
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putLexShort>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%edx
cmp    $0x10000,%edi
jl     113c <putLexShort+0x2c>
lea    0xed9(%rip),%rdi
lea    0xee6(%rip),%rsi
mov    %edx,%ebp
mov    $0x1b,%edx
call   1030 <internalCheckFail@plt>
mov    %ebp,%edx
mov    (%rbx),%rax
mov    %dl,(%rax)
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
mov    %dh,0x1(%rax)
addq   $0x1,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"shortValue <= 65535\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/thoni56/c-xrefactory/refs/heads/main/src/lexembuffer.c\00"
define void @putLexShort(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 65535
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @internalCheckFail(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 27)
br label %9
9: ; preds = %7, %2
%10 = load i32, i32* %3
%11 = urem i32 %10, 256
%12 = trunc i32 %11 to i8
%13 = load i8**, i8*** %4
%14 = load i8*, i8** %13
store i8 %12, i8* %14
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %15
%18 = load i32, i32* %3
%19 = udiv i32 %18, 256
%20 = trunc i32 %19 to i8
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
store i8 %20, i8* %22
%23 = load i8**, i8*** %4
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %23
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"shortValue <= 65535\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/thoni56/c-xrefactory/refs/heads/main/src/lexembuffer.c\00"
define void @putLexShort(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 65536
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @internalCheckFail(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 27)
br label %6
6: ; preds = %4, %2
%7 = trunc i32 %0 to i8
%8 = load i8*, i8** %1
store i8 %7, i8* %8
%9 = load i8*, i8** %1
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** %1
%11 = lshr i32 %0, 8
%12 = trunc i32 %11 to i8
store i8 %12, i8* %10
%13 = load i8*, i8** %1
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** %1
ret void
}