#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 simple_strtol(char *, char **, int /*<<< orphan*/);
int get_option(char **str, int *pint) {
  char *cur = *str;
  if (!cur || !(*cur))
    return 0;
  *pint = simple_strtol(cur, str, 0);
  if (cur == *str)
    return 0;
  if (**str == ',') {
    (*str)++;
    return 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1143 <get_option+0x33>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    114f <get_option+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <get_option+0xa7>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <simple_strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1183 <get_option+0x73>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <get_option+0xa7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    11b0 <get_option+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11b7 <get_option+0xa7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbp
xor    %r14d,%r14d
test   %rbp,%rbp
je     1161 <get_option+0x51>
cmpb   $0x0,0x0(%rbp)
je     1161 <get_option+0x51>
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r14d,%r14d
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <simple_strtol@plt>
mov    %eax,(%r15)
mov    (%rbx),%rax
cmp    %rax,%rbp
je     1161 <get_option+0x51>
mov    $0x1,%r14d
cmpb   $0x2c,(%rax)
jne    1161 <get_option+0x51>
add    $0x1,%rax
mov    %rax,(%rbx)
mov    $0x2,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_option(i8** %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
store i8** %0, i8*** %4
store i32* %1, i32** %5
%7 = load i8**, i8*** %4
%8 = load i8*, i8** %7
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11, %2
store i32 0, i32* %3
br label %37
16: ; preds = %11
%17 = load i8*, i8** %6
%18 = load i8**, i8*** %4
%19 = call i32 @simple_strtol(i8* %17, i8** %18, i32 0)
%20 = load i32*, i32** %5
store i32 %19, i32* %20
%21 = load i8*, i8** %6
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = icmp eq i8* %21, %23
br i1 %24, label %25, label %26
25: ; preds = %16
store i32 0, i32* %3
br label %37
26: ; preds = %16
%27 = load i8**, i8*** %4
%28 = load i8*, i8** %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 44
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i8**, i8*** %4
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %33
store i32 2, i32* %3
br label %37
36: ; preds = %26
store i32 1, i32* %3
br label %37
37: ; preds = %36, %32, %25, %15
%38 = load i32, i32* %3
ret i32 %38
}

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