#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 */
struct session {
  int dummy;
};

/* Variables and functions */
scalar_t__ isdigit(char);
int /*<<< orphan*/ pop_call();
int /*<<< orphan*/ push_call(char *, char *, struct session *);
int /*<<< orphan*/ sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ write_mud(struct session *, char *);
void process_speedwalk(char *cp, struct session *ses) {
  char sc[2];
  int loopcnt, i;
  push_call("do_speedwalk(%s,%p)", cp, ses);
  for (sc[1] = 0; *cp; cp++) {
    if (isdigit(*cp)) {
      sscanf(cp, "%d%c", &loopcnt, sc);
      for (i = 0; i < loopcnt; i++) {
        write_mud(ses, sc);
      }
      while (*cp != sc[0]) {
        cp++;
      }
    } else {
      sc[0] = *cp;
      write_mud(ses, sc);
    }
  }
  pop_call();
  return;
}


x86 assembly (clang, -O0):
<process_speedwalk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe91(%rip),%rdi
call   1060 <push_call@plt>
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     123b <process_speedwalk+0xeb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     120f <process_speedwalk+0xbf>
mov    -0x8(%rbp),%rdi
lea    -0x12(%rbp),%rcx
lea    0xe6a(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e1 <process_speedwalk+0x91>
mov    -0x10(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1030 <write_mud@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ba <process_speedwalk+0x6a>
jmp    11e6 <process_speedwalk+0x96>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
je     120a <process_speedwalk+0xba>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e6 <process_speedwalk+0x96>
jmp    1225 <process_speedwalk+0xd5>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1030 <write_mud@plt>
jmp    122a <process_speedwalk+0xda>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <process_speedwalk+0x28>
mov    $0x0,%al
call   1070 <pop_call@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_speedwalk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <push_call@plt>
movb   $0x0,0x3(%rsp)
mov    (%rbx),%al
test   %al,%al
je     121e <process_speedwalk+0xce>
lea    0x2(%rsp),%r15
lea    0xe86(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11bc <process_speedwalk+0x6c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%al
mov    %al,0x2(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <write_mud@plt>
mov    0x1(%rbx),%al
add    $0x1,%rbx
test   %al,%al
je     121e <process_speedwalk+0xce>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     11a0 <process_speedwalk+0x50>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1050 <sscanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1204 <process_speedwalk+0xb4>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <write_mud@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11f0 <process_speedwalk+0xa0>
mov    0x2(%rsp),%al
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rcx
nop
lea    0x1(%rcx),%rbx
cmp    %al,0x1(%rcx)
mov    %rbx,%rcx
jne    1210 <process_speedwalk+0xc0>
jmp    11b1 <process_speedwalk+0x61>
xor    %eax,%eax
call   1070 <pop_call@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.session = type { i32 }
@.str = [20 x i8] c"do_speedwalk(%s,%p)\00"
@.str.1 = [5 x i8] c"%d%c\00"
define void @process_speedwalk(i8* %0, %struct.session* %1) {
%3 = alloca [2 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @push_call(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0, %struct.session* %1)
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
store i8 0, i8* %8
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %41, label %11
11: ; preds = %2, %36
%12 = phi i8 [ %39, %36 ], [ %9, %2 ]
%13 = phi i8* [ %38, %36 ], [ %0, %2 ]
%14 = call i64 @isdigit(i8 signext %12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %33, label %16
16: ; preds = %11
%17 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i8* %5)
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %22, %16
%21 = load i8, i8* %5
br label %28
22: ; preds = %16, %22
%23 = phi i32 [ %25, %22 ], [ 0, %16 ]
%24 = call i32 @write_mud(%struct.session* %1, i8* %5)
%25 = add nuw nsw i32 %23, 1
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %22, label %20
28: ; preds = %28, %20
%29 = phi i8* [ %32, %28 ], [ %13, %20 ]
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, %21
%32 = getelementptr inbounds i8, i8* %29, i64 1
br i1 %31, label %36, label %28
33: ; preds = %11
%34 = load i8, i8* %13
store i8 %34, i8* %5
%35 = call i32 @write_mud(%struct.session* %1, i8* %5)
br label %36
36: ; preds = %28, %33
%37 = phi i8* [ %13, %33 ], [ %29, %28 ]
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %41, label %11
41: ; preds = %36, %2
%42 = call i32 (...) @pop_call()
ret void
}