#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__ isDigit(char);
int length(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readWordFromCommand(char *, char *, int, char);
int /*<<< orphan*/ remove(char *, char);
void validateRm(char *params) {
  char param1[128] = {0};
  char param2[128] = {0};
  int i = 0;
  readWordFromCommand(param1, params, 0, ' ');
  i += length(param1) + 1;
  readWordFromCommand(param2, params, i, 0);
  if (length(param2) == 1 && isDigit(param2[0]) && param2[0] - '0' <= 1) {
    remove(param1, param2[0] - '0');
  } else {
    printf("Invalid arguments\n");
  }
}


x86 assembly (clang, -O0):
<validateRm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
movl   $0x0,-0x114(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
mov    $0x20,%ecx
call   1070 <readWordFromCommand@plt>
lea    -0x90(%rbp),%rdi
call   1040 <length@plt>
add    $0x1,%eax
add    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x114(%rbp),%edx
xor    %ecx,%ecx
call   1070 <readWordFromCommand@plt>
lea    -0x110(%rbp),%rdi
call   1040 <length@plt>
cmp    $0x1,%eax
jne    1245 <validateRm+0xe5>
movsbl -0x110(%rbp),%edi
call   1080 <isDigit@plt>
cmp    $0x0,%rax
je     1245 <validateRm+0xe5>
movsbl -0x110(%rbp),%eax
sub    $0x30,%eax
cmp    $0x1,%eax
jg     1245 <validateRm+0xe5>
lea    -0x90(%rbp),%rdi
movsbl -0x110(%rbp),%eax
sub    $0x30,%eax
movsbl %al,%esi
call   1030 <remove@plt>
jmp    1251 <validateRm+0xf1>
lea    0xdb4(%rip),%rdi
call   1050 <printf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validateRm>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x20,%ecx
call   1060 <readWordFromCommand@plt>
mov    %r14,%rdi
call   1040 <length@plt>
lea    0x1(%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1060 <readWordFromCommand@plt>
mov    %r14,%rdi
call   1040 <length@plt>
cmp    $0x1,%eax
jne    1232 <validateRm+0xe2>
movsbl (%rsp),%edi
call   1070 <isDigit@plt>
test   %rax,%rax
je     1232 <validateRm+0xe2>
mov    (%rsp),%al
cmp    $0x31,%al
jg     1232 <validateRm+0xe2>
add    $0xd0,%al
movsbl %al,%esi
lea    0x80(%rsp),%rdi
call   1030 <remove@plt>
jmp    123e <validateRm+0xee>
lea    0xdc7(%rip),%rdi
call   1050 <puts@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Invalid arguments\0A\00"
define void @validateRm(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = bitcast [128 x i8]* %3 to i8*
%7 = bitcast [128 x i8]* %4 to i8*
store i32 0, i32* %5
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i32 @readWordFromCommand(i8* %8, i8* %9, i32 0, i8 signext 32)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i32 @length(i8* %11)
%13 = add nsw i32 %12, 1
%14 = load i32, i32* %5
%15 = add nsw i32 %14, %13
store i32 %15, i32* %5
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = load i32, i32* %5
%19 = call i32 @readWordFromCommand(i8* %16, i8* %17, i32 %18, i8 signext 0)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%21 = call i32 @length(i8* %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %42
23: ; preds = %1
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%25 = load i8, i8* %24
%26 = call i64 @isDigit(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %23
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 48
%33 = icmp sle i32 %32, 1
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 48
%40 = trunc i32 %39 to i8
%41 = call i32 @remove(i8* %35, i8 signext %40)
br label %44
42: ; preds = %28, %23, %1
%43 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %34
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"Invalid arguments\00"
define void @validateRm(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @readWordFromCommand(i8* %4, i8* %0, i32 0, i8 signext 32)
%7 = call i32 @length(i8* %4)
%8 = add nsw i32 %7, 1
%9 = call i32 @readWordFromCommand(i8* %5, i8* %0, i32 %8, i8 signext 0)
%10 = call i32 @length(i8* %5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %22
12: ; preds = %1
%13 = load i8, i8* %5
%14 = call i64 @isDigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %12
%17 = load i8, i8* %5
%18 = icmp slt i8 %17, 50
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = add i8 %17, -48
%21 = call i32 @remove(i8* %4, i8 signext %20)
br label %24
22: ; preds = %16, %12, %1
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
ret void
}