#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 Get_grid_size(void *, int, int *);
int Get_var_grid(void *, char const *, int *);
int Get_var_type(void *, char const *, char *);
scalar_t__ strcmp(char *, char *);
int Get_var_nbytes(void *self, const char *name, int *nbytes) {
  int size = 0;
  int grid;
  char type[(2048)];
  *nbytes = -1;
  if (Get_var_grid(self, name, &grid) == (1))
    return (1);
  if (Get_grid_size(self, grid, &size) == (1))
    return (1);
  if (Get_var_type(self, name, type) == (1))
    return (1);
  if (strcmp(type, "int") == 0) {
    *nbytes = sizeof(int) * size;
    return (0);
  } else if (strcmp(type, "double") == 0) {
    *nbytes = sizeof(double) * size;
    return (0);
  } else {
    return (1);
  }
}


x86 assembly (clang, -O0):
<Get_var_nbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <Get_var_grid@plt>
cmp    $0x1,%eax
jne    118e <Get_var_nbytes+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    1255 <Get_var_nbytes+0x115>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x24(%rbp),%rdx
call   1040 <Get_grid_size@plt>
cmp    $0x1,%eax
jne    11b3 <Get_var_nbytes+0x73>
movl   $0x1,-0x4(%rbp)
jmp    1255 <Get_var_nbytes+0x115>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x830(%rbp),%rdx
call   1050 <Get_var_type@plt>
cmp    $0x1,%eax
jne    11dc <Get_var_nbytes+0x9c>
movl   $0x1,-0x4(%rbp)
jmp    1255 <Get_var_nbytes+0x115>
lea    -0x830(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <Get_var_nbytes+0xd5>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1255 <Get_var_nbytes+0x115>
lea    -0x830(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <Get_var_nbytes+0x10e>
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1255 <Get_var_nbytes+0x115>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_var_nbytes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x0,0x8(%rsp)
movl   $0xffffffff,(%rdx)
lea    0xc(%rsp),%rdx
call   1060 <Get_var_grid@plt>
mov    $0x1,%r15d
cmp    $0x1,%eax
je     11e6 <Get_var_nbytes+0xa6>
mov    0xc(%rsp),%esi
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
call   1040 <Get_grid_size@plt>
cmp    $0x1,%eax
je     11e6 <Get_var_nbytes+0xa6>
lea    0x10(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <Get_var_type@plt>
cmp    $0x1,%eax
je     11e6 <Get_var_nbytes+0xa6>
lea    0xe55(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d9 <Get_var_nbytes+0x99>
lea    0xe43(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11e6 <Get_var_nbytes+0xa6>
mov    0x8(%rsp),%eax
shl    $0x3,%eax
jmp    11e0 <Get_var_nbytes+0xa0>
mov    0x8(%rsp),%eax
shl    $0x2,%eax
mov    %eax,(%r14)
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"int\00"
@.str.1 = [7 x i8] c"double\00"
define i32 @Get_var_nbytes(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2048 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 0, i32* %8
%11 = load i32*, i32** %7
store i32 -1, i32* %11
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = call i32 @Get_var_grid(i8* %12, i8* %13, i32* %9)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 1, i32* %4
br label %51
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = load i32, i32* %9
%20 = call i32 @Get_grid_size(i8* %18, i32 %19, i32* %8)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 1, i32* %4
br label %51
23: ; preds = %17
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%27 = call i32 @Get_var_type(i8* %24, i8* %25, i8* %26)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 1, i32* %4
br label %51
30: ; preds = %23
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = mul i64 4, %36
%38 = trunc i64 %37 to i32
%39 = load i32*, i32** %7
store i32 %38, i32* %39
store i32 0, i32* %4
br label %51
40: ; preds = %30
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = mul i64 8, %46
%48 = trunc i64 %47 to i32
%49 = load i32*, i32** %7
store i32 %48, i32* %49
store i32 0, i32* %4
br label %51
50: ; preds = %40
store i32 1, i32* %4
br label %51
51: ; preds = %50, %44, %34, %29, %22, %16
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [4 x i8] c"int\00"
@.str.1 = [7 x i8] c"double\00"
define i32 @Get_var_nbytes(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2048 x i8]
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
store i32 -1, i32* %2
%10 = call i32 @Get_var_grid(i8* %0, i8* %1, i32* %5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %33, label %12
12: ; preds = %3
%13 = load i32, i32* %5
%14 = call i32 @Get_grid_size(i8* %0, i32 %13, i32* %4)
%15 = icmp eq i32 %14, 1
br i1 %15, label %33, label %16
16: ; preds = %12
%17 = call i32 @Get_var_type(i8* %0, i8* %1, i8* %9)
%18 = icmp eq i32 %17, 1
br i1 %18, label %33, label %19
19: ; preds = %16
%20 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %4
%24 = shl i32 %23, 2
br label %31
25: ; preds = %19
%26 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %4
%30 = shl i32 %29, 3
br label %31
31: ; preds = %22, %28
%32 = phi i32 [ %30, %28 ], [ %24, %22 ]
store i32 %32, i32* %2
br label %33
33: ; preds = %31, %25, %16, %12, %3
%34 = phi i32 [ 1, %3 ], [ 1, %12 ], [ 1, %16 ], [ 1, %25 ], [ 0, %31 ]
ret i32 %34
}