#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 EXIT_SUCCESS;
char *extract_xml(char *);
int /*<<< orphan*/ free(char *);
char *line_reading(int);
int /*<<< orphan*/ printf(char *, ...);
char *strdup(char *);
int main(int argc, char **argv) {
  printf("Enter xml data: ");
  char *line = line_reading(50);
  char *copy = strdup(line);
  char *result = extract_xml(copy);
  if (result) {
    printf("%s\n", result);
    free(result);
  }
  free(copy);
  free(line);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x32,%edi
call   1060 <line_reading@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <extract_xml@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c2 <main+0x72>
mov    -0x28(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x32,%edi
call   1070 <line_reading@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <extract_xml@plt>
test   %rax,%rax
je     11ab <main+0x4b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter xml data: \00"
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i8* @line_reading(i32 50)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = call i8* @extract_xml(i8* %13)
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8*, i8** %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %8
%21 = call i32 @free(i8* %20)
br label %22
22: ; preds = %17, %2
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter xml data: \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @line_reading(i32 50)
%5 = tail call i8* @strdup(i8* %4)
%6 = tail call i8* @extract_xml(i8* %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* %6)
%10 = tail call i32 @free(i8* %6)
br label %11
11: ; preds = %8, %2
%12 = tail call i32 @free(i8* %5)
%13 = tail call i32 @free(i8* %4)
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}