#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 *data(char *, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ *segment_tag(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
void print_parsed(char *s) {
  char tagbuf[4];
  if (segment_tag(s, tagbuf) == NULL) {
    fprintf(stderr, "segment tag returned an error\n");
    exit(1);
  }
  if (strcmp(tagbuf, "UNA") != 0) {
    printf("%s\n", tagbuf);
    int element = 0;
    char *p;
    while ((p = data(s, element, 0)) != NULL) {
      printf("   %s\n", p);
      free(p);
      int component = 1;
      while ((p = data(s, element, component)) != NULL) {
        printf("     %s\n", p);
        free(p);
        ++component;
      }
      ++element;
    }
  }
}


x86 assembly (clang, -O0):
<print_parsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <segment_tag@plt>
cmp    $0x0,%rax
jne    11b2 <print_parsed+0x42>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0xc(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1276 <print_parsed+0x106>
lea    -0xc(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
xor    %edx,%edx
call   1070 <data@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1271 <print_parsed+0x101>
mov    -0x18(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <data@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1263 <print_parsed+0xf3>
mov    -0x18(%rbp),%rsi
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121f <print_parsed+0xaf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e3 <print_parsed+0x73>
jmp    1276 <print_parsed+0x106>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_parsed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0x4(%rsp),%rsi
call   1080 <segment_tag@plt>
test   %rax,%rax
je     127c <print_parsed+0x10c>
lea    0xe87(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     126d <print_parsed+0xfd>
lea    0xe76(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <printf@plt>
xor    %r13d,%r13d
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <data@plt>
test   %rax,%rax
je     126d <print_parsed+0xfd>
mov    %rax,%rbx
lea    0xe47(%rip),%r14
lea    0xe3e(%rip),%r15
jmp    1209 <print_parsed+0x99>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
mov    %r12,%rdi
mov    %r13d,%esi
xor    %edx,%edx
call   1070 <data@plt>
mov    %rax,%rbx
test   %rax,%rax
je     126d <print_parsed+0xfd>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
call   1070 <data@plt>
test   %rax,%rax
je     11f0 <print_parsed+0x80>
mov    %rax,%rbp
mov    $0x2,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1070 <data@plt>
mov    %rax,%rbp
add    $0x1,%ebx
test   %rax,%rax
jne    1240 <print_parsed+0xd0>
jmp    11f0 <print_parsed+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xd74(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"segment tag returned an error\0A\00"
@.str.1 = [4 x i8] c"UNA\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [7 x i8] c" %s\0A\00"
@.str.4 = [9 x i8] c" %s\0A\00"
define void @print_parsed(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%9 = call i32* @segment_tag(i8* %7, i8* %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %1
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 0, i32* %4
br label %22
22: ; preds = %45, %19
%23 = load i8*, i8** %2
%24 = load i32, i32* %4
%25 = call i8* @data(i8* %23, i32 %24, i32 0)
store i8* %25, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %48
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
store i32 1, i32* %6
br label %32
32: ; preds = %38, %27
%33 = load i8*, i8** %2
%34 = load i32, i32* %4
%35 = load i32, i32* %6
%36 = call i8* @data(i8* %33, i32 %34, i32 %35)
store i8* %36, i8** %5
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i8*, i8** %5
%40 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %5
%42 = call i32 @free(i8* %41)
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %32
45: ; preds = %32
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %22
48: ; preds = %22
br label %49
49: ; preds = %48, %15
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"segment tag returned an error\0A\00"
@.str.1 = [4 x i8] c"UNA\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [7 x i8] c" %s\0A\00"
@.str.4 = [9 x i8] c" %s\0A\00"
define void @print_parsed(i8* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32* @segment_tag(i8* %0, i8* %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %36, label %13
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%15 = call i8* @data(i8* %0, i32 0, i32 0)
%16 = icmp eq i8* %15, null
br i1 %16, label %36, label %17
17: ; preds = %13, %32
%18 = phi i8* [ %34, %32 ], [ %15, %13 ]
%19 = phi i32 [ %33, %32 ], [ 0, %13 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%21 = call i32 @free(i8* %18)
%22 = call i8* @data(i8* %0, i32 %19, i32 1)
%23 = icmp eq i8* %22, null
br i1 %23, label %32, label %24
24: ; preds = %17, %24
%25 = phi i8* [ %30, %24 ], [ %22, %17 ]
%26 = phi i32 [ %29, %24 ], [ 1, %17 ]
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%28 = call i32 @free(i8* %25)
%29 = add nuw nsw i32 %26, 1
%30 = call i8* @data(i8* %0, i32 %19, i32 %29)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %24
32: ; preds = %24, %17
%33 = add nuw nsw i32 %19, 1
%34 = call i8* @data(i8* %0, i32 %33, i32 0)
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %17
36: ; preds = %32, %13, %10
ret void
}