#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*/ pmesg(int, char *, int, char *);
int oph_iob_read_as_numeric(const char *bin_val, void **num,
                            unsigned int num_type) {
  if (!bin_val) {
    pmesg(1,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/OphidiaBigData/ophidia-io-server/refs/"
          "heads/master/src/common/oph-lib-binary-io.c",
          84, "No data to read");
    return 3;
  }
  switch (num_type) {
  case 5:
    *(long long **)num = (long long *)bin_val;
    break;
  case 1:
    *(int **)num = (int *)bin_val;
    break;
  case 6:
    *(short **)num = (short *)bin_val;
    break;
  case 2:
    *(float **)num = (float *)bin_val;
    break;
  case 3:
    *(double **)num = (double *)bin_val;
    break;
  case 7:
  case 4:
    *(char **)num = (char *)bin_val;
    break;
  default:
    pmesg(1,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/OphidiaBigData/ophidia-io-server/refs/"
          "heads/master/src/common/oph-lib-binary-io.c",
          108, "Numerical type not recognized");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<oph_iob_read_as_numeric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1157 <oph_iob_read_as_numeric+0x47>
mov    $0x1,%edi
lea    0xee2(%rip),%rsi
mov    $0x54,%edx
lea    0xf82(%rip),%rcx
call   1030 <pmesg@plt>
movl   $0x3,-0x4(%rbp)
jmp    1210 <oph_iob_read_as_numeric+0x100>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x6,%eax
ja     11e0 <oph_iob_read_as_numeric+0xd0>
mov    -0x28(%rbp),%rax
lea    0xe89(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1209 <oph_iob_read_as_numeric+0xf9>
mov    $0x1,%edi
lea    0xe30(%rip),%rsi
mov    $0x6c,%edx
lea    0xee0(%rip),%rcx
call   1030 <pmesg@plt>
movl   $0x1,-0x4(%rbp)
jmp    1210 <oph_iob_read_as_numeric+0x100>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oph_iob_read_as_numeric>:
push   %rbx
test   %rdi,%rdi
je     1135 <oph_iob_read_as_numeric+0x25>
add    $0xffffffff,%edx
cmp    $0x6,%edx
ja     115b <oph_iob_read_as_numeric+0x4b>
lea    0xedb(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %rdi,(%rsi)
xor    %ebx,%ebx
jmp    1157 <oph_iob_read_as_numeric+0x47>
lea    0xee0(%rip),%rsi
lea    0xf85(%rip),%rcx
mov    $0x1,%edi
mov    $0x54,%edx
call   1030 <pmesg@plt>
mov    $0x3,%ebx
mov    %ebx,%eax
pop    %rbx
ret
lea    0xeba(%rip),%rsi
lea    0xf6f(%rip),%rcx
mov    $0x1,%ebx
mov    $0x1,%edi
mov    $0x6c,%edx
call   1030 <pmesg@plt>
jmp    1157 <oph_iob_read_as_numeric+0x47>

LLVM IR (-O0):
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OphidiaBigData/ophidia-io-server/refs/heads/master/src/common/oph-lib-binary-io.c\00"
@.str.1 = [16 x i8] c"No data to read\00"
@.str.2 = [30 x i8] c"Numerical type not recognized\00"
define i32 @oph_iob_read_as_numeric(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @pmesg(i32 1, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 84, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 3, i32* %4
br label %45
12: ; preds = %3
%13 = load i32, i32* %7
switch i32 %13, label %42 [
i32 5, label %14
i32 1, label %19
i32 6, label %24
i32 2, label %29
i32 3, label %34
i32 7, label %39
i32 4, label %39
]
14: ; preds = %12
%15 = load i8*, i8** %5
%16 = bitcast i8* %15 to i64*
%17 = load i8**, i8*** %6
%18 = bitcast i8** %17 to i64**
store i64* %16, i64** %18
br label %44
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = bitcast i8* %20 to i32*
%22 = load i8**, i8*** %6
%23 = bitcast i8** %22 to i32**
store i32* %21, i32** %23
br label %44
24: ; preds = %12
%25 = load i8*, i8** %5
%26 = bitcast i8* %25 to i16*
%27 = load i8**, i8*** %6
%28 = bitcast i8** %27 to i16**
store i16* %26, i16** %28
br label %44
29: ; preds = %12
%30 = load i8*, i8** %5
%31 = bitcast i8* %30 to float*
%32 = load i8**, i8*** %6
%33 = bitcast i8** %32 to float**
store float* %31, float** %33
br label %44
34: ; preds = %12
%35 = load i8*, i8** %5
%36 = bitcast i8* %35 to double*
%37 = load i8**, i8*** %6
%38 = bitcast i8** %37 to double**
store double* %36, double** %38
br label %44
39: ; preds = %12, %12
%40 = load i8*, i8** %5
%41 = load i8**, i8*** %6
store i8* %40, i8** %41
br label %44
42: ; preds = %12
%43 = call i32 @pmesg(i32 1, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 108, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %45
44: ; preds = %39, %34, %29, %24, %19, %14
store i32 0, i32* %4
br label %45
45: ; preds = %44, %42, %10
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OphidiaBigData/ophidia-io-server/refs/heads/master/src/common/oph-lib-binary-io.c\00"
@.str.1 = [16 x i8] c"No data to read\00"
@.str.2 = [30 x i8] c"Numerical type not recognized\00"
define i32 @oph_iob_read_as_numeric(i8* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @pmesg(i32 1, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 84, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %16
7: ; preds = %3
switch i32 %2, label %14 [
i32 5, label %8
i32 1, label %9
i32 6, label %10
i32 2, label %11
i32 3, label %12
i32 7, label %13
i32 4, label %13
]
8: ; preds = %7
store i8* %0, i8** %1
br label %16
9: ; preds = %7
store i8* %0, i8** %1
br label %16
10: ; preds = %7
store i8* %0, i8** %1
br label %16
11: ; preds = %7
store i8* %0, i8** %1
br label %16
12: ; preds = %7
store i8* %0, i8** %1
br label %16
13: ; preds = %7, %7
store i8* %0, i8** %1
br label %16
14: ; preds = %7
%15 = tail call i32 @pmesg(i32 1, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 108, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %8, %9, %10, %11, %12, %13, %14, %5
%17 = phi i32 [ 1, %14 ], [ 3, %5 ], [ 0, %13 ], [ 0, %12 ], [ 0, %11 ], [ 0, %10 ], [ 0, %9 ], [ 0, %8 ]
ret i32 %17
}