#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__ index(char *, char);
char getparm(char **S) {
  char N = 0;
  while (index("0123456789", **S)) {
    N %= 1000;
    N *= 10;
    N += *(*S)++ - '0';
  }
  if (**S == ';')
    (*S)++;
  return N;
}


x86 assembly (clang, -O0):
<getparm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
lea    0xed2(%rip),%rdi
movsbl (%rax),%esi
call   1030 <index@plt>
cmp    $0x0,%rax
je     1180 <getparm+0x70>
movsbl -0x9(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
imul   $0xa,%eax,%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl (%rax),%ecx
sub    $0x30,%ecx
movsbl -0x9(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x9(%rbp)
jmp    1120 <getparm+0x10>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    11a1 <getparm+0x91>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getparm>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rax
movsbl (%rax),%esi
lea    0xedc(%rip),%rdi
call   1030 <index@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     116b <getparm+0x5b>
lea    0xec9(%rip),%r14
nopw   0x0(%rax,%rax,1)
movzbl %bpl,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%ebp
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
add    (%rax),%bpl
add    $0xd0,%bpl
movsbl 0x1(%rax),%esi
mov    %r14,%rdi
call   1030 <index@plt>
test   %rax,%rax
jne    1140 <getparm+0x30>
mov    (%rbx),%rax
cmpb   $0x3b,(%rax)
jne    117a <getparm+0x6a>
add    $0x1,%rax
mov    %rax,(%rbx)
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
define signext i8 @getparm(i8** %0) {
%2 = alloca i8**
%3 = alloca i8
store i8** %0, i8*** %2
store i8 0, i8* %3
br label %4
4: ; preds = %10, %1
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = call i64 @index(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %4
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = srem i32 %12, 1000
%14 = trunc i32 %13 to i8
store i8 %14, i8* %3
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = mul nsw i32 %16, 10
%18 = trunc i32 %17 to i8
store i8 %18, i8* %3
%19 = load i8**, i8*** %2
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %19
%22 = load i8, i8* %20
%23 = sext i8 %22 to i32
%24 = sub nsw i32 %23, 48
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = add nsw i32 %26, %24
%28 = trunc i32 %27 to i8
store i8 %28, i8* %3
br label %4
29: ; preds = %4
%30 = load i8**, i8*** %2
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 59
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = load i8**, i8*** %2
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %36
br label %39
39: ; preds = %35, %29
%40 = load i8, i8* %3
ret i8 %40
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
define signext i8 @getparm(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = tail call i64 @index(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %13, %6 ], [ 0, %1 ]
%8 = mul i8 %7, 10
%9 = load i8*, i8** %0
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** %0
%11 = load i8, i8* %9
%12 = add i8 %8, -48
%13 = add i8 %12, %11
%14 = load i8, i8* %10
%15 = tail call i64 @index(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %6, %1
%18 = phi i8 [ 0, %1 ], [ %13, %6 ]
%19 = load i8*, i8** %0
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 59
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %23, i8** %0
br label %24
24: ; preds = %22, %17
ret i8 %18
}