#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int parse_steps_R(char *arg, int *steps_p, int *step_num_p) {
  *step_num_p = strlen(arg);
  printf("steps count: %d\n", *step_num_p);
  if (*step_num_p <= 12 && *step_num_p >= 4) {
    int i;
    for (i = 0; i < *step_num_p; i++) {
      char step = arg[i];
      if (step >= '0' && step <= '7') {
        char step_string[2] = {step, '\0'};
        steps_p[i] = atoi(step_string);
      } else if (step >= 'a' && step <= 'd') {
        steps_p[i] = step - 89;
      } else {
        printf("step #%d is wrong. Exiting...\n\n", i);
        exit(1);
      }
      printf("step %d = %u\n", i, steps_p[i]);
    }
  } else {
    printf("steps count not between 4 and 12. Exiting...\n\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_steps_R>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0xc,(%rax)
jg     1276 <parse_steps_R+0x136>
mov    -0x18(%rbp),%rax
cmpl   $0x4,(%rax)
jl     1276 <parse_steps_R+0x136>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1271 <parse_steps_R+0x131>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x30,%eax
jl     11f6 <parse_steps_R+0xb6>
movsbl -0x1d(%rbp),%eax
cmp    $0x37,%eax
jg     11f6 <parse_steps_R+0xb6>
mov    -0x1d(%rbp),%al
mov    %al,-0x1f(%rbp)
movb   $0x0,-0x1e(%rbp)
lea    -0x1f(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1247 <parse_steps_R+0x107>
movsbl -0x1d(%rbp),%eax
cmp    $0x61,%eax
jl     1227 <parse_steps_R+0xe7>
movsbl -0x1d(%rbp),%eax
cmp    $0x64,%eax
jg     1227 <parse_steps_R+0xe7>
movsbl -0x1d(%rbp),%edx
sub    $0x59,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1242 <parse_steps_R+0x102>
mov    -0x1c(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1247 <parse_steps_R+0x107>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <parse_steps_R+0x5a>
jmp    128e <parse_steps_R+0x14e>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_steps_R>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,(%r12)
lea    0xe8c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%eax
add    $0xfffffffc,%eax
cmp    $0x8,%eax
ja     121e <parse_steps_R+0xce>
lea    0x6(%rsp),%r13
lea    0xe98(%rip),%rbp
xor    %ebx,%ebx
jmp    11d0 <parse_steps_R+0x80>
nopl   (%rax)
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    %eax,(%r14,%rbx,4)
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq (%r12),%rax
cmp    %rax,%rbx
jge    11f3 <parse_steps_R+0xa3>
movzbl (%r15,%rbx,1),%eax
mov    %eax,%ecx
and    $0xf8,%cl
cmp    $0x30,%cl
je     11a0 <parse_steps_R+0x50>
lea    -0x61(%rax),%ecx
cmp    $0x3,%cl
ja     1204 <parse_steps_R+0xb4>
movsbl %al,%edx
add    $0xffffffa7,%edx
mov    %edx,(%r14,%rbx,4)
jmp    11b7 <parse_steps_R+0x67>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe06(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"steps count: %d\0A\00"
@.str.1 = [32 x i8] c"step #%d is wrong. Exiting...\0A\0A\00"
@.str.2 = [14 x i8] c"step %d = %u\0A\00"
@.str.3 = [47 x i8] c"steps count not between 4 and 12. Exiting...\0A\0A\00"
define i32 @parse_steps_R(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca [2 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = load i32*, i32** %6
store i32 %11, i32* %12
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %6
%17 = load i32, i32* %16
%18 = icmp sle i32 %17, 12
br i1 %18, label %19, label %85
19: ; preds = %3
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = icmp sge i32 %21, 4
br i1 %22, label %23, label %85
23: ; preds = %19
store i32 0, i32* %7
br label %24
24: ; preds = %81, %23
%25 = load i32, i32* %7
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %84
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
store i8 %34, i8* %8
%35 = load i8, i8* %8
%36 = sext i8 %35 to i32
%37 = icmp sge i32 %36, 48
br i1 %37, label %38, label %52
38: ; preds = %29
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp sle i32 %40, 55
br i1 %41, label %42, label %52
42: ; preds = %38
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%44 = load i8, i8* %8
store i8 %44, i8* %43
%45 = getelementptr inbounds i8, i8* %43, i64 1
store i8 0, i8* %45
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%47 = call i32 @atoi(i8* %46)
%48 = load i32*, i32** %5
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
store i32 %47, i32* %51
br label %73
52: ; preds = %38, %29
%53 = load i8, i8* %8
%54 = sext i8 %53 to i32
%55 = icmp sge i32 %54, 97
br i1 %55, label %56, label %68
56: ; preds = %52
%57 = load i8, i8* %8
%58 = sext i8 %57 to i32
%59 = icmp sle i32 %58, 100
br i1 %59, label %60, label %68
60: ; preds = %56
%61 = load i8, i8* %8
%62 = sext i8 %61 to i32
%63 = sub nsw i32 %62, 89
%64 = load i32*, i32** %5
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
store i32 %63, i32* %67
br label %72
68: ; preds = %56, %52
%69 = load i32, i32* %7
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %60
br label %73
73: ; preds = %72, %42
%74 = load i32, i32* %7
%75 = load i32*, i32** %5
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %75, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %79)
br label %81
81: ; preds = %73
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %24
84: ; preds = %24
br label %88
85: ; preds = %19, %3
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %84
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"steps count: %d\0A\00"
@.str.1 = [32 x i8] c"step #%d is wrong. Exiting...\0A\0A\00"
@.str.2 = [14 x i8] c"step %d = %u\0A\00"
@str = [46 x i8] c"steps count not between 4 and 12. Exiting...\0A\00"
define i32 @parse_steps_R(i8* %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca [2 x i8]
%5 = tail call i32 @strlen(i8* %0)
store i32 %5, i32* %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %2
%8 = add i32 %7, -4
%9 = icmp ult i32 %8, 9
br i1 %9, label %10, label %42
10: ; preds = %3
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
br label %13
13: ; preds = %10, %33
%14 = phi i64 [ 0, %10 ], [ %37, %33 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = and i8 %16, -8
%19 = icmp eq i8 %18, 48
br i1 %19, label %20, label %23
20: ; preds = %13
store i8 %16, i8* %11
store i8 0, i8* %12
%21 = call i32 @atoi(i8* %11)
%22 = getelementptr inbounds i32, i32* %1, i64 %14
store i32 %21, i32* %22
br label %33
23: ; preds = %13
%24 = add i8 %16, -97
%25 = icmp ult i8 %24, 4
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = add nsw i32 %17, -89
%28 = getelementptr inbounds i32, i32* %1, i64 %14
store i32 %27, i32* %28
br label %33
29: ; preds = %23
%30 = trunc i64 %14 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %26, %20
%34 = phi i32 [ %27, %26 ], [ %21, %20 ]
%35 = trunc i64 %14 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %34)
%37 = add nuw nsw i64 %14, 1
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %13, label %41
41: ; preds = %33
ret i32 0
42: ; preds = %3
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
}