#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 *getMiddleString(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void testGetString(void) {
  char *ret = NULL;
  char *in;
  char out[256];
  in = "/2011-12-03-08-42-03-733/module1_Unit1.swf";
  printf("in : %s\n", in);
  ret = getMiddleString(in, out);
  if (ret) {
    printf("out : %s\n", ret);
  } else {
    printf("out : get string failed!\n");
  }
  in = "/favicon.ico";
  printf("in : %s\n", in);
  ret = getMiddleString(in, out);
  if (ret) {
    printf("out : %s\n", ret);
  } else {
    printf("out : get string failed!\n");
  }
}


x86 assembly (clang, -O0):
<testGetString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <getMiddleString@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1186 <testGetString+0x66>
mov    -0x8(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <testGetString+0x74>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <getMiddleString@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e7 <testGetString+0xc7>
mov    -0x8(%rbp),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <testGetString+0xd5>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGetString>:
push   %rbx
sub    $0x100,%rsp
lea    0xeec(%rip),%rdi
lea    0xeba(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <getMiddleString@plt>
test   %rax,%rax
je     1173 <testGetString+0x43>
lea    0xecd(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117f <testGetString+0x4f>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0xeb1(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <getMiddleString@plt>
test   %rax,%rax
je     11ba <testGetString+0x8a>
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c6 <testGetString+0x96>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"/2011-12-03-08-42-03-733/module1_Unit1.swf\00"
@.str.1 = [9 x i8] c"in : %s\0A\00"
@.str.2 = [10 x i8] c"out : %s\0A\00"
@.str.3 = [26 x i8] c"out : get string failed!\0A\00"
@.str.4 = [13 x i8] c"/favicon.ico\00"
define void @testGetString() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [256 x i8]
store i8* null, i8** %1
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i8* @getMiddleString(i8* %6, i8* %7)
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i8*, i8** %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %2
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %2
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = call i8* @getMiddleString(i8* %19, i8* %20)
store i8* %21, i8** %1
%22 = load i8*, i8** %1
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i8*, i8** %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %29
27: ; preds = %16
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"/2011-12-03-08-42-03-733/module1_Unit1.swf\00"
@.str.1 = [9 x i8] c"in : %s\0A\00"
@.str.2 = [10 x i8] c"out : %s\0A\00"
@.str.4 = [13 x i8] c"/favicon.ico\00"
@str.5 = [25 x i8] c"out : get string failed!\00"
define void @testGetString() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @getMiddleString(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%12 = call i8* @getMiddleString(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %18
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
ret void
}