#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*/ expand(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char *s[] = {"a-z-",  "z-a-",  "-1-6-", "a-ee-a",
               "a-R-L", "1-9-1", "5-5",   NULL};
  char result[100];
  int i = 0;
  while (s[i]) {
    expand(result, s[i]);
    printf("Unexpanded: %s\n", s[i]);
    printf("Expanded  : %s\n", result);
    ++i;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c93(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xc4(%rbp)
movslq -0xc4(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
je     11cb <main+0x9b>
lea    -0xc0(%rbp),%rdi
movslq -0xc4(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1050 <expand@plt>
movslq -0xc4(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1161 <main+0x31>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xece(%rip),%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <expand@plt>
lea    0xee0(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xede(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe9a(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe77(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe55(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe34(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe12(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xdf0(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"a-z-\00"
@.str.1 = [5 x i8] c"z-a-\00"
@.str.2 = [6 x i8] c"-1-6-\00"
@.str.3 = [7 x i8] c"a-ee-a\00"
@.str.4 = [6 x i8] c"a-R-L\00"
@.str.5 = [6 x i8] c"1-9-1\00"
@.str.6 = [4 x i8] c"5-5\00"
@__const.main.s = [8 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* null]
@.str.7 = [16 x i8] c"Unexpanded: %s\0A\00"
@.str.8 = [16 x i8] c"Expanded : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8*]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [8 x i8*]* %2 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %12, %0
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %8
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %28
12: ; preds = %6
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @expand(i8* %13, i8* %17)
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %6
28: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"a-z-\00"
@.str.1 = [5 x i8] c"z-a-\00"
@.str.2 = [6 x i8] c"-1-6-\00"
@.str.3 = [7 x i8] c"a-ee-a\00"
@.str.4 = [6 x i8] c"a-R-L\00"
@.str.5 = [6 x i8] c"1-9-1\00"
@.str.6 = [4 x i8] c"5-5\00"
@.str.7 = [16 x i8] c"Unexpanded: %s\0A\00"
@.str.8 = [16 x i8] c"Expanded : %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%6 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%9 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%12 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%15 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%18 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%21 = call i32 @expand(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %2)
ret i32 0
}