#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 getword(char *, int);
scalar_t__ is_c_type(char *, char **);
int readvar(char *var, int maxlen) {
  char *types[] = {"short", "int", "float", "double", "void"};
  char word[maxlen];
  while (getword(word, maxlen) > 0) {
    if (is_c_type(word, types)) {
      return getword(var, maxlen);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readvar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb2(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <getword@plt>
cmp    $0x0,%eax
jle    11eb <readvar+0xcb>
mov    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <is_c_type@plt>
cmp    $0x0,%rax
je     11e6 <readvar+0xc6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <getword@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    11f9 <readvar+0xd9>
jmp    119f <readvar+0x7f>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readvar>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
mov    %rsp,%r13
lea    0xebf(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    %esi,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x50(%rbp),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <getword@plt>
test   %eax,%eax
jle    11bc <readvar+0x9c>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <is_c_type@plt>
test   %rax,%rax
je     1190 <readvar+0x70>
mov    %r14,%rdi
mov    %r15d,%esi
call   1040 <getword@plt>
jmp    11be <readvar+0x9e>
xor    %eax,%eax
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"short\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"float\00"
@.str.3 = [7 x i8] c"double\00"
@.str.4 = [5 x i8] c"void\00"
define i32 @readvar(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [5 x i8*]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = bitcast [5 x i8*]* %6 to i8*
%11 = bitcast i8* %10 to [5 x i8*]*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8** %16
%17 = load i32, i32* %5
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %7
%20 = alloca i8, i64 %18
store i64 %18, i64* %8
br label %21
21: ; preds = %33, %2
%22 = load i32, i32* %5
%23 = call i32 @getword(i8* %20, i32 %22)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 0
%27 = call i64 @is_c_type(i8* %20, i8** %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = call i32 @getword(i8* %30, i32 %31)
store i32 %32, i32* %3
store i32 1, i32* %9
br label %35
33: ; preds = %25
br label %21
34: ; preds = %21
store i32 0, i32* %3
store i32 1, i32* %9
br label %35
35: ; preds = %34, %29
%36 = load i8*, i8** %7
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"short\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"float\00"
@.str.3 = [7 x i8] c"double\00"
@.str.4 = [5 x i8] c"void\00"
define i32 @readvar(i8* %0, i32 %1) {
%3 = alloca [5 x i8*]
%4 = bitcast [5 x i8*]* %3 to i8*
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %9
%10 = zext i32 %1 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
br label %13
13: ; preds = %16, %2
%14 = call i32 @getword(i8* %12, i32 %1)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = call i64 @is_c_type(i8* %12, i8** %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %16
%20 = call i32 @getword(i8* %0, i32 %1)
br label %21
21: ; preds = %13, %19
%22 = phi i32 [ %20, %19 ], [ 0, %13 ]
ret i32 %22
}