#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 expand_range(char const *);
int /*<<< orphan*/ putchar(char const);
void expand(const char *str) {
  const char *processed_up_to = NULL;
  while (*str != '\0') {
    bool status = expand_range(str);
    if (status) {
      str += 2;
      processed_up_to = str;
    } else {
      if (!processed_up_to || str > processed_up_to)
        putchar(*str);
      str++;
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a9 <expand+0x89>
mov    -0x8(%rbp),%rdi
call   1040 <expand_range@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1173 <expand+0x53>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11a4 <expand+0x84>
cmpq   $0x0,-0x10(%rbp)
je     118c <expand+0x6c>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    1198 <expand+0x78>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <expand+0x14>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     117f <expand+0x5f>
mov    %rdi,%rbx
xor    %r14d,%r14d
jmp    1149 <expand+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmpb   $0x0,(%rbx)
je     117f <expand+0x5f>
mov    %rbx,%rdi
call   1040 <expand_range@plt>
test   %eax,%eax
je     1170 <expand+0x50>
add    $0x2,%rbx
mov    %rbx,%r14
cmpb   $0x0,(%rbx)
jne    1149 <expand+0x29>
jmp    117f <expand+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r14,%rbx
jbe    1140 <expand+0x20>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
jmp    1140 <expand+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @expand(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1, %18
%5 = phi i8* [ %20, %18 ], [ %0, %1 ]
%6 = phi i8* [ %19, %18 ], [ null, %1 ]
%7 = tail call i32 @expand_range(i8* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %5, i64 2
br label %18
11: ; preds = %4
%12 = icmp ugt i8* %5, %6
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = load i8, i8* %5
%15 = tail call i32 @putchar(i8 signext %14)
br label %16
16: ; preds = %11, %13
%17 = getelementptr inbounds i8, i8* %5, i64 1
br label %18
18: ; preds = %16, %9
%19 = phi i8* [ %10, %9 ], [ %6, %16 ]
%20 = phi i8* [ %10, %9 ], [ %17, %16 ]
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %4
23: ; preds = %18, %1
%24 = tail call i32 @putchar(i8 signext 10)
ret void
}