#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 */
struct ut_nm_result_s {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(void *);
char *ut_dump_nm_output(char const *);
struct ut_nm_result_s *ut_parse_nm_output(char const *);
struct ut_nm_result_s *ut_nm(char const *filename) {
  char const *str = NULL;
  struct ut_nm_result_s *res = NULL;
  if ((str = ut_dump_nm_output(filename)) == NULL) {
    return (NULL);
  }
  res = ut_parse_nm_output(str);
  free((void *)str);
  return (res);
}


x86 assembly (clang, -O0):
<ut_nm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ut_dump_nm_output@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1170 <ut_nm+0x40>
movq   $0x0,-0x8(%rbp)
jmp    118e <ut_nm+0x5e>
mov    -0x18(%rbp),%rdi
call   1050 <ut_parse_nm_output@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ut_nm>:
push   %r14
push   %rbx
push   %rax
call   1040 <ut_dump_nm_output@plt>
test   %rax,%rax
je     1159 <ut_nm+0x29>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <ut_parse_nm_output@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
jmp    115b <ut_nm+0x2b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ut_nm_result_s = type { i32 }
define %struct.ut_nm_result_s* @ut_nm(i8* %0) {
%2 = alloca %struct.ut_nm_result_s*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.ut_nm_result_s*
store i8* %0, i8** %3
store i8* null, i8** %4
store %struct.ut_nm_result_s* null, %struct.ut_nm_result_s** %5
%6 = load i8*, i8** %3
%7 = call i8* @ut_dump_nm_output(i8* %6)
store i8* %7, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store %struct.ut_nm_result_s* null, %struct.ut_nm_result_s** %2
br label %16
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call %struct.ut_nm_result_s* @ut_parse_nm_output(i8* %11)
store %struct.ut_nm_result_s* %12, %struct.ut_nm_result_s** %5
%13 = load i8*, i8** %4
%14 = call i32 @free(i8* %13)
%15 = load %struct.ut_nm_result_s*, %struct.ut_nm_result_s** %5
store %struct.ut_nm_result_s* %15, %struct.ut_nm_result_s** %2
br label %16
16: ; preds = %10, %9
%17 = load %struct.ut_nm_result_s*, %struct.ut_nm_result_s** %2
ret %struct.ut_nm_result_s* %17
}

LLVM IR (-O2):
%struct.ut_nm_result_s = type { i32 }
define %struct.ut_nm_result_s* @ut_nm(i8* %0) {
%2 = tail call i8* @ut_dump_nm_output(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call %struct.ut_nm_result_s* @ut_parse_nm_output(i8* %2)
%6 = tail call i32 @free(i8* %2)
br label %7
7: ; preds = %1, %4
%8 = phi %struct.ut_nm_result_s* [ %5, %4 ], [ null, %1 ]
ret %struct.ut_nm_result_s* %8
}