#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 */
long EdrTypeSize(int, int);
long NativeTypeSize(int);
long ExternTypeSize(int type, int arch) {
  switch (arch) {
  case 1:
    return EdrTypeSize(type, 1);
    break;
  case 2:
    return EdrTypeSize(type, 2);
    break;
  case 3:
    return NativeTypeSize(type);
    break;
  case 4:
    return -1;
    break;
  default:
    return -1;
    break;
  }
}


x86 assembly (clang, -O0):
<ExternTypeSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11a1 <ExternTypeSize+0x81>
mov    -0x18(%rbp),%rax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1040 <EdrTypeSize@plt>
mov    %rax,-0x8(%rbp)
jmp    11a9 <ExternTypeSize+0x89>
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1040 <EdrTypeSize@plt>
mov    %rax,-0x8(%rbp)
jmp    11a9 <ExternTypeSize+0x89>
mov    -0xc(%rbp),%edi
call   1030 <NativeTypeSize@plt>
mov    %rax,-0x8(%rbp)
jmp    11a9 <ExternTypeSize+0x89>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11a9 <ExternTypeSize+0x89>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExternTypeSize>:
cmp    $0x3,%esi
je     1139 <ExternTypeSize+0x19>
cmp    $0x2,%esi
je     113e <ExternTypeSize+0x1e>
cmp    $0x1,%esi
jne    1148 <ExternTypeSize+0x28>
mov    $0x1,%esi
jmp    1040 <EdrTypeSize@plt>
jmp    1030 <NativeTypeSize@plt>
mov    $0x2,%esi
jmp    1040 <EdrTypeSize@plt>
mov    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
define i64 @ExternTypeSize(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %10
i32 3, label %13
i32 4, label %16
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = call i64 @EdrTypeSize(i32 %8, i32 1)
store i64 %9, i64* %3
br label %18
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i64 @EdrTypeSize(i32 %11, i32 2)
store i64 %12, i64* %3
br label %18
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call i64 @NativeTypeSize(i32 %14)
store i64 %15, i64* %3
br label %18
16: ; preds = %2
store i64 -1, i64* %3
br label %18
17: ; preds = %2
store i64 -1, i64* %3
br label %18
18: ; preds = %17, %16, %13, %10, %7
%19 = load i64, i64* %3
ret i64 %19
}

LLVM IR (-O2):
define i64 @ExternTypeSize(i32 %0, i32 %1) {
switch i32 %1, label %9 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
]
3: ; preds = %2
%4 = tail call i64 @EdrTypeSize(i32 %0, i32 1)
br label %9
5: ; preds = %2
%6 = tail call i64 @EdrTypeSize(i32 %0, i32 2)
br label %9
7: ; preds = %2
%8 = tail call i64 @NativeTypeSize(i32 %0)
br label %9
9: ; preds = %2, %7, %5, %3
%10 = phi i64 [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ -1, %2 ]
ret i64 %10
}