#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*/ isdigit(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strtol(char *, char **, int);
int isImmediateAddressing(char *buff, int line) {
  char *rest;
  char asterisk = '#';
  while (isspace(*buff)) {
    buff++;
  }
  if (*buff != asterisk) {
    return 0;
  }
  buff++;
  if ((!isdigit(*buff)) && (*buff != '-') && (*buff != '+')) {
    printf("ERROR:line %d: unligal operend!!\n", line);
    return -1;
  }
  strtol(buff, &rest, 10);
  while (isspace(*rest))
    rest++;
  if (*rest != '\0')
    return -1;
  return 1;
}


x86 assembly (clang, -O0):
<isImmediateAddressing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movb   $0x23,-0x21(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     117a <isImmediateAddressing+0x3a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <isImmediateAddressing+0x13>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
je     1199 <isImmediateAddressing+0x59>
movl   $0x0,-0x4(%rbp)
jmp    1251 <isImmediateAddressing+0x111>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11f5 <isImmediateAddressing+0xb5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11f5 <isImmediateAddressing+0xb5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     11f5 <isImmediateAddressing+0xb5>
mov    -0x14(%rbp),%esi
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1251 <isImmediateAddressing+0x111>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     122e <isImmediateAddressing+0xee>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1207 <isImmediateAddressing+0xc7>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124a <isImmediateAddressing+0x10a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1251 <isImmediateAddressing+0x111>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isImmediateAddressing>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1050 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <isImmediateAddressing+0x10>
xor    %eax,%eax
cmpb   $0x23,-0x1(%rbx)
jne    11ab <isImmediateAddressing+0x6b>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11b2 <isImmediateAddressing+0x72>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    (%rsp),%rbx
nopl   0x0(%rax)
movsbl (%rbx),%edi
call   1050 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1190 <isImmediateAddressing+0x50>
xor    %eax,%eax
cmp    -0x1(%rbx),%al
sbb    %eax,%eax
or     $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%al
cmp    $0x2b,%al
je     1175 <isImmediateAddressing+0x35>
cmp    $0x2d,%al
je     1175 <isImmediateAddressing+0x35>
lea    0xe3d(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
jmp    11ab <isImmediateAddressing+0x6b>

LLVM IR (-O0):
@.str = [34 x i8] c"ERROR:line %d: unligal operend!!\0A\00"
define i32 @isImmediateAddressing(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8 35, i8* %7
br label %8
8: ; preds = %13, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = call i64 @isspace(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
br label %8
16: ; preds = %8
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i8, i8* %7
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %16
store i32 0, i32* %3
br label %62
24: ; preds = %16
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = call i32 @isdigit(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %24
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 45
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 43
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32, i32* %5
%43 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %42)
store i32 -1, i32* %3
br label %62
44: ; preds = %36, %31, %24
%45 = load i8*, i8** %4
%46 = call i32 @strtol(i8* %45, i8** %6, i32 10)
br label %47
47: ; preds = %52, %44
%48 = load i8*, i8** %6
%49 = load i8, i8* %48
%50 = call i64 @isspace(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %6
br label %47
55: ; preds = %47
%56 = load i8*, i8** %6
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %55
store i32 -1, i32* %3
br label %62
61: ; preds = %55
store i32 1, i32* %3
br label %62
62: ; preds = %61, %60, %41, %23
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [34 x i8] c"ERROR:line %d: unligal operend!!\0A\00"
define i32 @isImmediateAddressing(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = phi i8* [ %0, %2 ], [ %10, %5 ]
%7 = load i8, i8* %6
%8 = tail call i64 @isspace(i8 signext %7)
%9 = icmp eq i64 %8, 0
%10 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 35
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = load i8, i8* %10
%16 = tail call i32 @isdigit(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8, i8* %10
switch i8 %19, label %20 [
i8 45, label %22
i8 43, label %22
]
20: ; preds = %18
%21 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %35
22: ; preds = %18, %18, %14
%23 = call i32 @strtol(i8* %10, i8** %3, i32 10)
%24 = load i8*, i8** %3
br label %25
25: ; preds = %25, %22
%26 = phi i8* [ %30, %25 ], [ %24, %22 ]
%27 = load i8, i8* %26
%28 = tail call i64 @isspace(i8 signext %27)
%29 = icmp eq i64 %28, 0
%30 = getelementptr inbounds i8, i8* %26, i64 1
br i1 %29, label %31, label %25
31: ; preds = %25
%32 = load i8, i8* %26
%33 = icmp eq i8 %32, 0
%34 = select i1 %33, i32 1, i32 -1
br label %35
35: ; preds = %31, %11, %20
%36 = phi i32 [ -1, %20 ], [ 0, %11 ], [ %34, %31 ]
ret i32 %36
}