#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 mx_strtoll(char *, long long *);
char *strchr(char *, char);
int strlen(char *);
int mx_strscan_ll(char **str, long long int *to) {
  long long int l;
  char *s;
  char *p;
  char o = 0;
  int res;
  s = *str;
  p = strchr(s, ' ');
  if (p) {
    o = *p;
    *p = 0;
    p++;
  } else {
    p = s + strlen(s);
  }
  res = mx_strtoll(s, &l);
  if (o)
    *(p - 1) = o;
  if (res == 0) {
    *to = l;
    *str = p;
  }
  return res;
}


x86 assembly (clang, -O0):
<mx_strscan_ll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x29(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118d <mx_strscan_ll+0x5d>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11ae <mx_strscan_ll+0x7e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <mx_strtoll@plt>
mov    %eax,-0x30(%rbp)
cmpb   $0x0,-0x29(%rbp)
je     11d2 <mx_strscan_ll+0xa2>
mov    -0x29(%rbp),%cl
mov    -0x28(%rbp),%rax
mov    %cl,-0x1(%rax)
cmpl   $0x0,-0x30(%rbp)
jne    11f2 <mx_strscan_ll+0xc2>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mx_strscan_ll>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     118c <mx_strscan_ll+0x5c>
mov    %rax,%rbx
mov    (%rax),%bpl
movb   $0x0,(%rax)
mov    %rax,%r13
add    $0x1,%r13
mov    %rsp,%rsi
mov    %r12,%rdi
call   1050 <mx_strtoll@plt>
test   %bpl,%bpl
je     1179 <mx_strscan_ll+0x49>
mov    %bpl,(%rbx)
test   %eax,%eax
je     11a9 <mx_strscan_ll+0x79>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   1030 <strlen@plt>
movslq %eax,%r13
add    %r12,%r13
mov    %rsp,%rsi
mov    %r12,%rdi
call   1050 <mx_strtoll@plt>
test   %eax,%eax
jne    117d <mx_strscan_ll+0x4d>
mov    (%rsp),%rcx
mov    %rcx,(%r14)
mov    %r13,(%r15)
jmp    117d <mx_strscan_ll+0x4d>

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

LLVM IR (-O2):
define i32 @mx_strscan_ll(i8** nocapture %0, i64* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = load i8*, i8** %0
%6 = tail call i8* @strchr(i8* dereferenceable(1) %5, i8 signext 32)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %5)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %5, i64 %10
%12 = call i32 @mx_strtoll(i8* %5, i64* %3)
br label %19
13: ; preds = %2
%14 = load i8, i8* %6
store i8 0, i8* %6
%15 = getelementptr inbounds i8, i8* %6, i64 1
%16 = call i32 @mx_strtoll(i8* %5, i64* %3)
%17 = icmp eq i8 %14, 0
br i1 %17, label %19, label %18
18: ; preds = %13
store i8 %14, i8* %6
br label %19
19: ; preds = %8, %18, %13
%20 = phi i32 [ %12, %8 ], [ %16, %18 ], [ %16, %13 ]
%21 = phi i8* [ %11, %8 ], [ %15, %18 ], [ %15, %13 ]
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load i64, i64* %3
store i64 %24, i64* %1
store i8* %21, i8** %0
br label %25
25: ; preds = %23, %19
ret i32 %20
}