#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*/ STDIN_FILENO;
int _dmt_size(char *, char *, int);
int /*<<< orphan*/ disableRawMode(int /*<<< orphan*/);
int enableRawMode(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ isprint(char);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
void linenoisePrintKeyCodes(void) {
  char quit[4];
  printf("Linenoise key codes debugging mode.\n"
         "Press keys to see scan codes. Type 'quit' at any time to exit.\n");
  if (enableRawMode(STDIN_FILENO) == -1)
    return;
  memset(quit, ' ', 4);
  while (1) {
    char c;
    int nread;
    nread = read(STDIN_FILENO, &c, 1);
    if (nread <= 0)
      continue;
    memmove(quit, quit + 1,
            _dmt_size(quit,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/emekankurumeh/spork/"
                      "refs/heads/master/src/linenoise/linenoise.c",
                      918) -
                1);
    quit[_dmt_size(quit,
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/emekankurumeh/spork/refs/"
                   "heads/master/src/linenoise/linenoise.c",
                   919) -
         1] = c;
    if (memcmp(
            quit, "quit",
            _dmt_size(quit,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/emekankurumeh/spork/"
                      "refs/heads/master/src/linenoise/linenoise.c",
                      920)) == 0)
      break;
    printf("'%c' %02x (%d) (type quit to exit)\n", isprint(c) ? c : '?', (int)c,
           (int)c);
    printf("\r");
    fflush(stdout);
  }
  disableRawMode(STDIN_FILENO);
}


x86 assembly (clang, -O0):
<linenoisePrintKeyCodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1030 <enableRawMode@plt>
cmp    $0xffffffff,%eax
jne    11d2 <linenoisePrintKeyCodes+0x32>
jmp    1322 <linenoisePrintKeyCodes+0x182>
lea    -0x4(%rbp),%rdi
mov    $0x20,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     120e <linenoisePrintKeyCodes+0x6e>
jmp    11e5 <linenoisePrintKeyCodes+0x45>
lea    -0x4(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x4(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
lea    -0x4(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x396,%edx
call   1090 <_dmt_size@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   10c0 <memmove@plt>
mov    -0x5(%rbp),%al
mov    %al,-0x19(%rbp)
lea    -0x4(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x397,%edx
call   1090 <_dmt_size@plt>
mov    -0x19(%rbp),%cl
sub    $0x1,%eax
cltq
mov    %cl,-0x4(%rbp,%rax,1)
lea    -0x4(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
lea    0xde1(%rip),%rsi
mov    $0x398,%edx
call   1090 <_dmt_size@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe64(%rip),%rsi
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    12ae <linenoisePrintKeyCodes+0x10e>
jmp    1314 <linenoisePrintKeyCodes+0x174>
movsbl -0x5(%rbp),%edi
call   10b0 <isprint@plt>
cmp    $0x0,%rax
je     12cd <linenoisePrintKeyCodes+0x12d>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    12da <linenoisePrintKeyCodes+0x13a>
mov    $0x3f,%eax
mov    %eax,-0x34(%rbp)
jmp    12da <linenoisePrintKeyCodes+0x13a>
mov    -0x34(%rbp),%esi
movsbl -0x5(%rbp),%edx
movsbl -0x5(%rbp),%ecx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
jmp    11e5 <linenoisePrintKeyCodes+0x45>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
call   1040 <disableRawMode@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linenoisePrintKeyCodes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xef1(%rip),%rdi
call   1050 <puts@plt>
mov    0x2dfa(%rip),%rbp
mov    0x0(%rbp),%edi
call   1030 <enableRawMode@plt>
cmp    $0xffffffff,%eax
je     12e1 <linenoisePrintKeyCodes+0x121>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x4,%edx
call   1080 <memset@plt>
lea    0x3(%rsp),%r15
lea    0xdee(%rip),%r12
mov    0x2dc7(%rip),%r13
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
test   %eax,%eax
jle    1220 <linenoisePrintKeyCodes+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x396,%edx
call   10b0 <_dmt_size@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
lea    0x5(%rsp),%rsi
call   10e0 <memmove@plt>
movsbl 0x3(%rsp),%r14d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x397,%edx
call   10b0 <_dmt_size@plt>
cltq
mov    %r14b,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x398,%edx
call   10b0 <_dmt_size@plt>
mov    %rbx,%rdi
lea    0xe0f(%rip),%rsi
mov    %eax,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
je     12d9 <linenoisePrintKeyCodes+0x119>
mov    %r14d,%edi
call   10d0 <isprint@plt>
test   %rax,%rax
mov    %r14d,%esi
mov    $0x3f,%eax
cmove  %eax,%esi
lea    0xdeb(%rip),%rdi
mov    %r14d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xd,%edi
call   1040 <putchar@plt>
mov    0x0(%r13),%edi
call   10c0 <fflush@plt>
jmp    1220 <linenoisePrintKeyCodes+0x60>
mov    0x0(%rbp),%edi
call   1060 <disableRawMode@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [100 x i8] c"Linenoise key codes debugging mode.\0APress keys to see scan codes. Type 'quit' at any time to exit.\0A\00"
@STDIN_FILENO = global i32 0
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emekankurumeh/spork/refs/heads/master/src/linenoise/linenoise.c\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [36 x i8] c"'%c' %02x (%d) (type quit to exit)\0A\00"
@.str.4 = [2 x i8] c"\0D\00"
@stdout = global i32 0
define void @linenoisePrintKeyCodes() {
%1 = alloca [4 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @STDIN_FILENO
%6 = call i32 @enableRawMode(i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
br label %59
9: ; preds = %0
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i8 signext 32, i32 4)
br label %12
12: ; preds = %9, %17, %46
%13 = load i32, i32* @STDIN_FILENO
%14 = call i32 @read(i32 %13, i8* %2, i32 1)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %12
18: ; preds = %12
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%23 = call i32 @_dmt_size(i8* %22, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 918)
%24 = sub nsw i32 %23, 1
%25 = call i32 @memmove(i8* %19, i8* %21, i32 %24)
%26 = load i8, i8* %2
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%28 = call i32 @_dmt_size(i8* %27, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 919)
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 %30
store i8 %26, i8* %31
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%34 = call i32 @_dmt_size(i8* %33, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 920)
%35 = call i64 @memcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %18
br label %56
38: ; preds = %18
%39 = load i8, i8* %2
%40 = call i64 @isprint(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8, i8* %2
%44 = sext i8 %43 to i32
br label %46
45: ; preds = %38
br label %46
46: ; preds = %45, %42
%47 = phi i32 [ %44, %42 ], [ 63, %45 ]
%48 = load i8, i8* %2
%49 = sext i8 %48 to i32
%50 = load i8, i8* %2
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 %49, i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%54 = load i32, i32* @stdout
%55 = call i32 @fflush(i32 %54)
br label %12
56: ; preds = %37
%57 = load i32, i32* @STDIN_FILENO
%58 = call i32 @disableRawMode(i32 %57)
br label %59
59: ; preds = %56, %8
ret void
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emekankurumeh/spork/refs/heads/master/src/linenoise/linenoise.c\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [36 x i8] c"'%c' %02x (%d) (type quit to exit)\0A\00"
@stdout = global i32 0
@str = [99 x i8] c"Linenoise key codes debugging mode.\0APress keys to see scan codes. Type 'quit' at any time to exit.\00"
define void @linenoisePrintKeyCodes() {
%1 = alloca [4 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
%5 = load i32, i32* @STDIN_FILENO
%6 = tail call i32 @enableRawMode(i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %40, label %8
8: ; preds = %0
%9 = call i32 @memset(i8* %3, i8 signext 32, i32 4)
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 1
br label %11
11: ; preds = %36, %8
%12 = load i32, i32* @STDIN_FILENO
%13 = call i32 @read(i32 %12, i8* %2, i32 1)
%14 = icmp slt i32 %13, 1
br i1 %14, label %36, label %15
15: ; preds = %11
%16 = call i32 @_dmt_size(i8* %3, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 918)
%17 = add nsw i32 %16, -1
%18 = call i32 @memmove(i8* %3, i8* %10, i32 %17)
%19 = load i8, i8* %2
%20 = call i32 @_dmt_size(i8* %3, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 919)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 %22
store i8 %19, i8* %23
%24 = call i32 @_dmt_size(i8* %3, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 920)
%25 = call i64 @memcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %37, label %27
27: ; preds = %15
%28 = call i64 @isprint(i8 signext %19)
%29 = icmp eq i64 %28, 0
%30 = sext i8 %19 to i32
%31 = select i1 %29, i32 63, i32 %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %30, i32 %30)
%33 = call i32 @putchar(i32 13)
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
br label %36
36: ; preds = %11, %27
br label %11
37: ; preds = %15
%38 = load i32, i32* @STDIN_FILENO
%39 = call i32 @disableRawMode(i32 %38)
br label %40
40: ; preds = %0, %37
ret void
}