#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 *);
scalar_t__ isdigit(char);
char *scan_octave(char *arg, int *octave) {
  char *p;
  p = arg + 1;
  if (isdigit(*p)) {
    *octave = atoi(p);
    while (isdigit(*p)) {
      p++;
    }
  }
  return p;
}


x86 assembly (clang, -O0):
<scan_octave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     118f <scan_octave+0x6f>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     118a <scan_octave+0x6a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1163 <scan_octave+0x43>
jmp    118f <scan_octave+0x6f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_octave>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x1(%rdi),%r15
movsbl 0x1(%rdi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1164 <scan_octave+0x44>
mov    %r15,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1150 <scan_octave+0x30>
jmp    1167 <scan_octave+0x47>
mov    %r15,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @scan_octave(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = call i64 @isdigit(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i32 @atoi(i8* %13)
%15 = load i32*, i32** %4
store i32 %14, i32* %15
br label %16
16: ; preds = %21, %12
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = call i64 @isdigit(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %16
24: ; preds = %16
br label %25
25: ; preds = %24, %2
%26 = load i8*, i8** %5
ret i8* %26
}

LLVM IR (-O2):
define i8* @scan_octave(i8* %0, i32* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
%5 = tail call i64 @isdigit(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = tail call i32 @atoi(i8* %3)
store i32 %8, i32* %1
br label %9
9: ; preds = %9, %7
%10 = phi i8* [ %3, %7 ], [ %14, %9 ]
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
%14 = getelementptr inbounds i8, i8* %10, i64 1
br i1 %13, label %15, label %9
15: ; preds = %9, %2
%16 = phi i8* [ %3, %2 ], [ %10, %9 ]
ret i8* %16
}