#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);
int arg2code_modearg(char *str) {
  int code = -1;
  if (*str == '#') {
    code = 0;
    str++;
  } else if (*str == '@') {
    code = 2;
    str++;
  } else
    code = 1;
  if (!isdigit(*str) && (*str != '-' || !isdigit(*(str + 1))))
    code = -1;
  return code;
}


x86 assembly (clang, -O0):
<arg2code_modearg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    114b <arg2code_modearg+0x3b>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117f <arg2code_modearg+0x6f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1173 <arg2code_modearg+0x63>
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117a <arg2code_modearg+0x6a>
movl   $0x1,-0xc(%rbp)
jmp    117f <arg2code_modearg+0x6f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11c1 <arg2code_modearg+0xb1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11ba <arg2code_modearg+0xaa>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11c1 <arg2code_modearg+0xb1>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg2code_modearg>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x40,%al
je     112d <arg2code_modearg+0x1d>
mov    $0x1,%ebp
cmp    $0x23,%al
jne    1136 <arg2code_modearg+0x26>
add    $0x1,%rbx
xor    %ebp,%ebp
jmp    1136 <arg2code_modearg+0x26>
add    $0x1,%rbx
mov    $0x2,%ebp
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1159 <arg2code_modearg+0x49>
cmpb   $0x2d,(%rbx)
jne    1154 <arg2code_modearg+0x44>
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1159 <arg2code_modearg+0x49>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @arg2code_modearg(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 -1, i32* %3
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 35
br i1 %7, label %8, label %11
8: ; preds = %1
store i32 0, i32* %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
br label %21
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 64
br i1 %15, label %16, label %19
16: ; preds = %11
store i32 2, i32* %3
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
br label %20
19: ; preds = %11
store i32 1, i32* %3
br label %20
20: ; preds = %19, %16
br label %21
21: ; preds = %20, %8
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = call i32 @isdigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %21
%27 = load i8*, i8** %2
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 45
br i1 %30, label %37, label %31
31: ; preds = %26
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = call i32 @isdigit(i8 signext %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %31, %26
store i32 -1, i32* %3
br label %38
38: ; preds = %37, %31, %21
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @arg2code_modearg(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %7 [
i8 35, label %3
i8 64, label %5
]
3: ; preds = %1
%4 = getelementptr inbounds i8, i8* %0, i64 1
br label %7
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
br label %7
7: ; preds = %1, %5, %3
%8 = phi i8* [ %4, %3 ], [ %6, %5 ], [ %0, %1 ]
%9 = phi i32 [ 0, %3 ], [ 2, %5 ], [ 1, %1 ]
%10 = load i8, i8* %8
%11 = tail call i32 @isdigit(i8 signext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %7
%14 = load i8, i8* %8
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = load i8, i8* %17
%19 = tail call i32 @isdigit(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16, %13
br label %22
22: ; preds = %21, %16, %7
%23 = phi i32 [ %9, %7 ], [ -1, %21 ], [ %9, %16 ]
ret i32 %23
}