#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 *, ...);
int main(int argc, char *argv[]) {
  char input_str[] = "-a-zA-Ga-b-c0-9";
  char output_str[1024] = {0};
  printf("\n---------------------------------------------------------");
  printf("\n- Exercise 03.03 from, The C Programming Language,      -");
  printf("\n- by Brian W. Kernighan and Dennis M. Ritchie, 2nd Ed., -");
  printf("\n- AT&T Bell Laboratories (Prentice Hall - 1988).        -");
  printf("\n---------------------------------------------------------\n\n");
  printf("This program takes a string that contains\n");
  printf("shorthand and expands it. The function that\n");
  printf("demonstrates this is expand(). The function\n");
  printf("allows for letters of either case and digits\n");
  printf("and handles cases like a-b-c, a-z0-9, and -a-z.\n\n");
  printf("Input String is:\n%s\n\n", input_str);
  expand(input_str, output_str);
  printf("Processed String is:\n%s\n\n", output_str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xff5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0x1015(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1050 <expand@plt>
lea    -0x420(%rbp),%rsi
lea    0x1006(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf84(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xfd2(%rip),%rdi
call   1030 <puts@plt>
lea    0xff2(%rip),%rdi
call   1030 <puts@plt>
lea    0x1012(%rip),%rdi
call   1030 <puts@plt>
lea    0x1033(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <expand@plt>
lea    0xf03(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.input_str = [16 x i8] c"-a-zA-Ga-b-c0-9\00"
@.str = [59 x i8] c"\0A---------------------------------------------------------\00"
@.str.1 = [59 x i8] c"\0A- Exercise 03.03 from, The C Programming Language, -\00"
@.str.2 = [59 x i8] c"\0A- by Brian W. Kernighan and Dennis M. Ritchie, 2nd Ed., -\00"
@.str.3 = [59 x i8] c"\0A- AT&T Bell Laboratories (Prentice Hall - 1988). -\00"
@.str.4 = [61 x i8] c"\0A---------------------------------------------------------\0A\0A\00"
@.str.5 = [43 x i8] c"This program takes a string that contains\0A\00"
@.str.6 = [45 x i8] c"shorthand and expands it. The function that\0A\00"
@.str.7 = [45 x i8] c"demonstrates this is expand(). The function\0A\00"
@.str.8 = [46 x i8] c"allows for letters of either case and digits\0A\00"
@.str.9 = [50 x i8] c"and handles cases like a-b-c, a-z0-9, and -a-z.\0A\0A\00"
@.str.10 = [22 x i8] c"Input String is:\0A%s\0A\0A\00"
@.str.11 = [26 x i8] c"Processed String is:\0A%s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [16 x i8]* %6 to i8*
%9 = bitcast [1024 x i8]* %7 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0))
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%24 = call i32 @expand(i8* %22, i8* %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@__const.main.input_str = [16 x i8] c"-a-zA-Ga-b-c0-9\00"
@.str = [59 x i8] c"\0A---------------------------------------------------------\00"
@.str.1 = [59 x i8] c"\0A- Exercise 03.03 from, The C Programming Language, -\00"
@.str.2 = [59 x i8] c"\0A- by Brian W. Kernighan and Dennis M. Ritchie, 2nd Ed., -\00"
@.str.3 = [59 x i8] c"\0A- AT&T Bell Laboratories (Prentice Hall - 1988). -\00"
@.str.10 = [22 x i8] c"Input String is:\0A%s\0A\0A\00"
@.str.11 = [26 x i8] c"Processed String is:\0A%s\0A\0A\00"
@str = [60 x i8] c"\0A---------------------------------------------------------\0A\00"
@str.12 = [42 x i8] c"This program takes a string that contains\00"
@str.13 = [44 x i8] c"shorthand and expands it. The function that\00"
@str.14 = [44 x i8] c"demonstrates this is expand(). The function\00"
@str.15 = [45 x i8] c"allows for letters of either case and digits\00"
@str.16 = [49 x i8] c"and handles cases like a-b-c, a-z0-9, and -a-z.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.12, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.13, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.14, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.16, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %5)
%18 = call i32 @expand(i8* %5, i8* %6)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %6)
ret i32 0
}