#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);
void compute_shortint(const short int i_value, short int *result) {
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.compute_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",
      49, (int)(i_value));
  *result = transform_short_int(i_value);
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.compute_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",
      51, (int)(*result));
}


x86 assembly (clang, -O0):
<compute_shortint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
movswl -0x2(%rbp),%r8d
lea    0xeb8(%rip),%rsi
lea    0xee7(%rip),%rdx
mov    $0x31,%ecx
call   1030 <fprintf@plt>
movswl -0x2(%rbp),%edi
call   1040 <transform_short_int@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movswl (%rax),%r8d
lea    0xf8a(%rip),%rsi
lea    0xeab(%rip),%rdx
mov    $0x33,%ecx
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_shortint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2ead(%rip),%r15
mov    (%r15),%edi
lea    0xec3(%rip),%rsi
lea    0xef2(%rip),%r14
mov    %r14,%rdx
mov    $0x31,%ecx
mov    %ebp,%r8d
call   1030 <fprintf@plt>
mov    %ebp,%edi
call   1040 <transform_short_int@plt>
mov    %ax,(%rbx)
mov    (%r15),%edi
movswl %ax,%r8d
lea    0xfa2(%rip),%rsi
mov    %r14,%rdx
mov    $0x33,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"[INFO](%s:%d:) dpi_c.compute_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 = [52 x i8] c"[INFO](%s:%d:) dpi_c.compute_shortint(): return %d\0A\00"
define void @compute_shortint(i16 signext %0, i16* %1) {
%3 = alloca i16
%4 = alloca i16*
store i16 %0, i16* %3
store i16* %1, i16** %4
%5 = load i32, i32* @stderr
%6 = load i16, i16* %3
%7 = sext i16 %6 to i32
%8 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 49, i32 %7)
%9 = load i16, i16* %3
%10 = call signext i16 @transform_short_int(i16 signext %9)
%11 = load i16*, i16** %4
store i16 %10, i16* %11
%12 = load i32, i32* @stderr
%13 = load i16*, i16** %4
%14 = load i16, i16* %13
%15 = sext i16 %14 to i32
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 51, i32 %15)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"[INFO](%s:%d:) dpi_c.compute_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 = [52 x i8] c"[INFO](%s:%d:) dpi_c.compute_shortint(): return %d\0A\00"
define void @compute_shortint(i16 signext %0, i16* nocapture writeonly %1) {
%3 = load i32, i32* @stderr
%4 = sext i16 %0 to i32
%5 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 49, i32 %4)
%6 = tail call signext i16 @transform_short_int(i16 signext %0)
store i16 %6, i16* %1
%7 = load i32, i32* @stderr
%8 = sext i16 %6 to i32
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([216 x i8], [216 x i8]* @.str.1, i64 0, i64 0), i32 51, i32 %8)
ret void
}