#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*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ stderr;
short transform_short_int(short const);
short int get_shortint(const short int i_value) {
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.get_shortint(): received %d"
      "\n",
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/amiq-consulting/amiq_blog/refs/heads/master/"
      "amiq_sv_dpi_c_how_to_map_systemverilog_data_types_to_c_using_dpi_c/src/"
      "dpi_c_ex.c",
      55, (int)(i_value));
  short int result = transform_short_int(i_value);
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.get_shortint(): return %d"
      "\n",
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/amiq-consulting/amiq_blog/refs/heads/master/"
      "amiq_sv_dpi_c_how_to_map_systemverilog_data_types_to_c_using_dpi_c/src/"
      "dpi_c_ex.c",
      57, (int)(result));
  return result;
}


x86 assembly (clang, -O0):
<get_shortint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
movswl -0x2(%rbp),%r8d
lea    0xebc(%rip),%rsi
lea    0xee7(%rip),%rdx
mov    $0x37,%ecx
call   1030 <fprintf@plt>
movswl -0x2(%rbp),%edi
call   1040 <transform_short_int@plt>
mov    %ax,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
movswl -0x4(%rbp),%r8d
lea    0xf93(%rip),%rsi
lea    0xeb4(%rip),%rdx
mov    $0x39,%ecx
call   1030 <fprintf@plt>
movswl -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_shortint>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2eb2(%rip),%r15
mov    (%r15),%edi
lea    0xec8(%rip),%rsi
lea    0xef3(%rip),%r14
mov    %r14,%rdx
mov    $0x37,%ecx
mov    %ebx,%r8d
call   1030 <fprintf@plt>
mov    %ebx,%edi
call   1040 <transform_short_int@plt>
mov    (%r15),%edi
movswl %ax,%ebx
lea    0xfa7(%rip),%rsi
mov    %r14,%rdx
mov    $0x39,%ecx
mov    %ebx,%r8d
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"[INFO](%s:%d:) dpi_c.get_shortint(): received %d\0A\00"
@.str.1 = [216 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/amiq-consulting/amiq_blog/refs/heads/master/amiq_sv_dpi_c_how_to_map_systemverilog_data_types_to_c_using_dpi_c/src/dpi_c_ex.c\00"
@.str.2 = [48 x i8] c"[INFO](%s:%d:) dpi_c.get_shortint(): return %d\0A\00"
define signext i16 @get_shortint(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %2
%4 = load i32, i32* @stderr
%5 = load i16, i16* %2
%6 = sext i16 %5 to i32
%7 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %6)
%8 = load i16, i16* %2
%9 = call signext i16 @transform_short_int(i16 signext %8)
store i16 %9, i16* %3
%10 = load i32, i32* @stderr
%11 = load i16, i16* %3
%12 = sext i16 %11 to i32
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 57, i32 %12)
%14 = load i16, i16* %3
ret i16 %14
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"[INFO](%s:%d:) dpi_c.get_shortint(): received %d\0A\00"
@.str.1 = [216 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/amiq-consulting/amiq_blog/refs/heads/master/amiq_sv_dpi_c_how_to_map_systemverilog_data_types_to_c_using_dpi_c/src/dpi_c_ex.c\00"
@.str.2 = [48 x i8] c"[INFO](%s:%d:) dpi_c.get_shortint(): return %d\0A\00"
define signext i16 @get_shortint(i16 signext %0) {
%2 = load i32, i32* @stderr
%3 = sext i16 %0 to i32
%4 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %3)
%5 = tail call signext i16 @transform_short_int(i16 signext %0)
%6 = load i32, i32* @stderr
%7 = sext i16 %5 to i32
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 57, i32 %7)
ret i16 %5
}