#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 */
scalar_t__ isspace(char);
int strlen(char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int getModo(char *command) {
  if (isspace(*(command + strlen(command) - 2))) {
    return *(command + strlen(command) - 1) - '0';
  }
  return strtol(command + strlen(command) - 2, NULL, 10);
}


x86 assembly (clang, -O0):
<getModo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
movsbl -0x2(%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1194 <getModo+0x64>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
movsbl -0x1(%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <getModo+0x93>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getModo>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
movsbl -0x2(%rbx,%rax,1),%edi
call   1040 <isspace@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
test   %r14,%r14
je     116d <getModo+0x3d>
movsbl -0x1(%rdi),%eax
add    $0xffffffd0,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
add    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
mov    $0xa,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strtol@plt>

LLVM IR (-O0):
define i32 @getModo(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -2
%10 = load i8, i8* %9
%11 = call i64 @isspace(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 48
store i32 %22, i32* %2
br label %31
23: ; preds = %1
%24 = load i8*, i8** %3
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -2
%30 = call i32 @strtol(i8* %29, i32* null, i32 10)
store i32 %30, i32* %2
br label %31
31: ; preds = %23, %13
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @getModo(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -2
%6 = load i8, i8* %5
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = tail call i32 @strlen(i8* %0)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
br i1 %8, label %17, label %12
12: ; preds = %1
%13 = getelementptr inbounds i8, i8* %11, i64 -1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = add nsw i32 %15, -48
br label %20
17: ; preds = %1
%18 = getelementptr inbounds i8, i8* %11, i64 -2
%19 = tail call i32 @strtol(i8* nocapture %18, i32* null, i32 10)
br label %20
20: ; preds = %17, %12
%21 = phi i32 [ %16, %12 ], [ %19, %17 ]
ret i32 %21
}