#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 scanto(char *, int *, int);
int scan_any(char *str, int *pos, int toc) {
  int save = *pos;
  int value = scanto(str, pos, ';');
  if (value == 0) {
    *pos = save;
    value = scanto(str, pos, toc);
    if (str[*pos] != '\0')
      value = 0;
  }
  return value;
}


x86 assembly (clang, -O0):
<scan_any>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3b,%edx
call   1030 <scanto@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    118b <scan_any+0x7b>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <scanto@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1186 <scan_any+0x76>
movl   $0x0,-0x1c(%rbp)
jmp    118b <scan_any+0x7b>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_any>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%ebp
mov    $0x3b,%edx
call   1030 <scanto@plt>
test   %eax,%eax
jne    114f <scan_any+0x3f>
mov    %ebp,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <scanto@plt>
mov    %eax,%ecx
movslq (%rbx),%rdx
xor    %eax,%eax
cmpb   $0x0,(%r14,%rdx,1)
cmove  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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