#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 /*<<< orphan*/ assert(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
char *strchr(char *, char);
void cut_and_print(char *string, char delimiter, char opt_short) {
  char *p, *s;
  assert(string);
  p = s = string;
  printf("%s", string);
  while ((p = strchr(p, delimiter))) {
    putchar(' ');
    while (s < p)
      putchar(*(s++));
    p++;
    s = (opt_short) ? p : string;
  }
  printf(" %s", s);
}


x86 assembly (clang, -O0):
<cut_and_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1206 <cut_and_print+0xc6>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11cb <cut_and_print+0x8b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    11a1 <cut_and_print+0x61>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movsbl -0xa(%rbp),%eax
cmp    $0x0,%eax
je     11f1 <cut_and_print+0xb1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11f9 <cut_and_print+0xb9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    117c <cut_and_print+0x3c>
mov    -0x20(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cut_and_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
mov    %esi,%ebp
mov    %rdi,%r15
call   1060 <assert@plt>
lea    0xea1(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e6 <cut_and_print+0xa6>
mov    %rax,%r13
movsbl %bpl,%r12d
mov    %r15,%rbp
jmp    11b3 <cut_and_print+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
cmpb   $0x0,0x4(%rsp)
mov    %r13,%rbp
cmove  %r15,%rbp
mov    %r13,%rdi
mov    %r12d,%esi
call   1040 <strchr@plt>
mov    %rax,%r13
test   %rax,%rax
je     11e9 <cut_and_print+0xa9>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    %r13,%rbp
jae    1190 <cut_and_print+0x50>
mov    %r13,%rbx
sub    %rbp,%rbx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%rbp,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    11d0 <cut_and_print+0x90>
jmp    1190 <cut_and_print+0x50>
mov    %r15,%rbp
lea    0xe10(%rip),%rdi
mov    %rbp,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c" %s\00"
define void @cut_and_print(i8* %0, i8 signext %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%9 = load i8*, i8** %4
%10 = call i32 @assert(i8* %9)
%11 = load i8*, i8** %4
store i8* %11, i8** %8
store i8* %11, i8** %7
%12 = load i8*, i8** %4
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %40, %3
%15 = load i8*, i8** %7
%16 = load i8, i8* %5
%17 = call i8* @strchr(i8* %15, i8 signext %16)
store i8* %17, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %42
19: ; preds = %14
%20 = call i32 @putchar(i8 signext 32)
br label %21
21: ; preds = %25, %19
%22 = load i8*, i8** %8
%23 = load i8*, i8** %7
%24 = icmp ult i8* %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %8
%28 = load i8, i8* %26
%29 = call i32 @putchar(i8 signext %28)
br label %21
30: ; preds = %21
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %7
%33 = load i8, i8* %6
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = load i8*, i8** %7
br label %40
38: ; preds = %30
%39 = load i8*, i8** %4
br label %40
40: ; preds = %38, %36
%41 = phi i8* [ %37, %36 ], [ %39, %38 ]
store i8* %41, i8** %8
br label %14
42: ; preds = %14
%43 = load i8*, i8** %8
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c" %s\00"
define void @cut_and_print(i8* %0, i8 signext %1, i8 signext %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %31, label %8
8: ; preds = %3
%9 = icmp eq i8 %2, 0
br label %10
10: ; preds = %8, %26
%11 = phi i8* [ %6, %8 ], [ %29, %26 ]
%12 = phi i8* [ %0, %8 ], [ %28, %26 ]
%13 = tail call i32 @putchar(i8 signext 32)
%14 = icmp ult i8* %12, %11
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = ptrtoint i8* %12 to i64
%17 = ptrtoint i8* %11 to i64
%18 = sub i64 %17, %16
%19 = getelementptr i8, i8* %12, i64 %18
br label %20
20: ; preds = %15, %20
%21 = phi i8* [ %22, %20 ], [ %12, %15 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %21
%24 = tail call i32 @putchar(i8 signext %23)
%25 = icmp eq i8* %22, %19
br i1 %25, label %26, label %20
26: ; preds = %20, %10
%27 = getelementptr inbounds i8, i8* %11, i64 1
%28 = select i1 %9, i8* %0, i8* %27
%29 = tail call i8* @strchr(i8* dereferenceable(1) %27, i8 signext %1)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %10
31: ; preds = %26, %3
%32 = phi i8* [ %0, %3 ], [ %28, %26 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
ret void
}