#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 str_test(char *, char const *);
char *str_next_token(char **line, const char *fmt) {
  int b;
  char *s = *line;
  if (!*line)
    return 0;
  while (((b = str_test(*line, fmt)) == 0) && (**line))
    (*line)++;
  if (b) {
    if (**line) {
      **line = 0;
      *line += b;
    }
    return s;
  }
  *line = s;
  return 0;
}


x86 assembly (clang, -O0):
<str_next_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1146 <str_next_token+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11fb <str_next_token+0xeb>
jmp    114b <str_next_token+0x3b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <str_test@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    1181 <str_next_token+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1191 <str_next_token+0x81>
jmp    11a4 <str_next_token+0x94>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    114b <str_next_token+0x3b>
cmpl   $0x0,-0x1c(%rbp)
je     11e8 <str_next_token+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     11db <str_next_token+0xcb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fb <str_next_token+0xeb>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_next_token>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%r14
test   %r14,%r14
je     115f <str_next_token+0x4f>
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %r14,%rdi
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1030 <str_test@plt>
test   %eax,%eax
jne    114d <str_next_token+0x3d>
mov    (%rbx),%rdi
cmpb   $0x0,(%rdi)
je     1164 <str_next_token+0x54>
add    $0x1,%rdi
mov    %rdi,(%rbx)
jmp    1130 <str_next_token+0x20>
mov    (%rbx),%rcx
cmpb   $0x0,(%rcx)
je     116d <str_next_token+0x5d>
movb   $0x0,(%rcx)
cltq
add    (%rbx),%rax
jmp    116a <str_next_token+0x5a>
xor    %r14d,%r14d
jmp    116d <str_next_token+0x5d>
mov    %r14,%rax
xor    %r14d,%r14d
mov    %rax,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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