#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;
char transform_char(char const);
void compute_byte(const char i_value, char *result) {
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.compute_byte(): received value %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",
      36, (int)(i_value));
  *result = transform_char(i_value);
  fprintf(
      stderr,
      "[INFO](%s:%d:) "
      "dpi_c.compute_byte(): return value %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",
      38, (int)(*result));
}


x86 assembly (clang, -O0):
<compute_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
movsbl -0x1(%rbp),%r8d
lea    0xeb9(%rip),%rsi
lea    0xeea(%rip),%rdx
mov    $0x24,%ecx
call   1040 <fprintf@plt>
movsbl -0x1(%rbp),%edi
call   1030 <transform_char@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movsbl (%rax),%r8d
lea    0xf8f(%rip),%rsi
lea    0xeb0(%rip),%rdx
mov    $0x26,%ecx
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_byte>:
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    0xef4(%rip),%r14
mov    %r14,%rdx
mov    $0x24,%ecx
mov    %ebp,%r8d
call   1040 <fprintf@plt>
mov    %ebp,%edi
call   1030 <transform_char@plt>
mov    %al,(%rbx)
mov    (%r15),%edi
movsbl %al,%r8d
lea    0xfa5(%rip),%rsi
mov    %r14,%rdx
mov    $0x26,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

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

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