#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 */
char *strchr(char *, char const);
char **toc_parse_args(char *str, const int maxargs, const char sep) {
  static char *args[256];
  int curarg = 0;
  char *colon;
  while ((curarg < (maxargs - 1)) && (curarg < 256) &&
         ((colon = strchr(str, sep)) != NULL)) {
    args[curarg++] = str;
    *colon = 0;
    str = colon + 1;
  }
  args[curarg++] = str;
  args[curarg] = NULL;
  return (args);
}


x86 assembly (clang, -O0):
<toc_parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x21(%rbp)
jge    116e <toc_parse_args+0x5e>
xor    %eax,%eax
cmpl   $0x100,-0x14(%rbp)
mov    %al,-0x21(%rbp)
jge    116e <toc_parse_args+0x5e>
mov    -0x8(%rbp),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117e <toc_parse_args+0x6e>
jmp    11b3 <toc_parse_args+0xa3>
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %eax,%rcx
lea    0x2ea9(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112b <toc_parse_args+0x1b>
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %eax,%rcx
lea    0x2e74(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movslq -0x14(%rbp),%rcx
lea    0x2e65(%rip),%rax
movq   $0x0,(%rax,%rcx,8)
lea    0x2e56(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toc_parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
xor    %r15d,%r15d
cmp    $0x2,%esi
jl     1182 <toc_parse_args+0x72>
add    $0xfffffffe,%esi
cmp    $0xff,%esi
mov    $0xff,%r15d
cmovb  %esi,%r15d
add    $0x1,%r15d
lea    0x2eff(%rip),%rbx
xor    %ebp,%ebp
movsbl %dl,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117f <toc_parse_args+0x6f>
add    $0x1,%rbp
mov    %r12,(%rbx)
movb   $0x0,(%rax)
add    $0x1,%rax
add    $0x8,%rbx
mov    %rax,%r12
cmp    %rbp,%r15
jne    1150 <toc_parse_args+0x40>
mov    %rax,%r12
jmp    1182 <toc_parse_args+0x72>
mov    %ebp,%r15d
mov    %r15d,%ecx
lea    0x2eb4(%rip),%rax
mov    %r12,(%rax,%rcx,8)
movq   $0x0,0x8(%rax,%rcx,8)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@toc_parse_args.args = internal global [256 x i8*] zeroinitializer
define i8** @toc_parse_args(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i32 0, i32* %7
br label %9
9: ; preds = %24, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i8, i8* %6
%20 = call i8* @strchr(i8* %18, i8 signext %19)
store i8* %20, i8** %8
%21 = icmp ne i8* %20, null
br label %22
22: ; preds = %17, %14, %9
%23 = phi i1 [ false, %14 ], [ false, %9 ], [ %21, %17 ]
br i1 %23, label %24, label %33
24: ; preds = %22
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %28
store i8* %25, i8** %29
%30 = load i8*, i8** %8
store i8 0, i8* %30
%31 = load i8*, i8** %8
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %4
br label %9
33: ; preds = %22
%34 = load i8*, i8** %4
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %37
store i8* %34, i8** %38
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %40
store i8* null, i8** %41
ret i8** getelementptr inbounds ([256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 0)
}

LLVM IR (-O2):
@toc_parse_args.args = internal global [256 x i8*] zeroinitializer
define i8** @toc_parse_args(i8* %0, i32 %1, i8 signext %2) {
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = add nsw i32 %1, -2
%7 = call i32 @llvm.umin.i32(i32 %6, i32 255)
%8 = add nuw nsw i32 %7, 1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %5, %15
%11 = phi i64 [ 0, %5 ], [ %16, %15 ]
%12 = phi i8* [ %0, %5 ], [ %18, %15 ]
%13 = tail call i8* @strchr(i8* dereferenceable(1) %12, i8 signext %2)
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = add nuw nsw i64 %11, 1
%17 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %11
store i8* %12, i8** %17
store i8 0, i8* %13
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = icmp eq i64 %16, %9
br i1 %19, label %22, label %10
20: ; preds = %10
%21 = trunc i64 %11 to i32
br label %22
22: ; preds = %15, %20, %3
%23 = phi i32 [ 0, %3 ], [ %21, %20 ], [ %8, %15 ]
%24 = phi i8* [ %0, %3 ], [ %12, %20 ], [ %18, %15 ]
%25 = add nuw nsw i32 %23, 1
%26 = zext i32 %23 to i64
%27 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %26
store i8* %24, i8** %27
%28 = zext i32 %25 to i64
%29 = getelementptr inbounds [256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 %28
store i8* null, i8** %29
ret i8** getelementptr inbounds ([256 x i8*], [256 x i8*]* @toc_parse_args.args, i64 0, i64 0)
}