#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 pathhead {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ENOMEM;
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *qstring(struct pathhead *);
void showpath(struct pathhead *pathq) {
  char *s;
  if ((s = qstring(pathq)) == NULL) {
    errno = ENOMEM;
    err(1, "building path string");
  }
  printf("%s\n", s);
  free(s);
}


x86 assembly (clang, -O0):
<showpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <qstring@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1186 <showpath+0x46>
mov    0x2e76(%rip),%rax
mov    (%rax),%ecx
mov    0x2e65(%rip),%rax
mov    %ecx,(%rax)
mov    $0x1,%edi
lea    0xe7f(%rip),%rsi
call   1050 <err@plt>
mov    -0x10(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showpath>:
push   %rbx
call   1060 <qstring@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1171 <showpath+0x31>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    0x2e7a(%rip),%rcx
mov    %eax,(%rcx)
lea    0xe99(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.pathhead = type { i32 }
@ENOMEM = global i32 0
@errno = global i32 0
@.str = [21 x i8] c"building path string\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @showpath(%struct.pathhead* %0) {
%2 = alloca %struct.pathhead*
%3 = alloca i8*
store %struct.pathhead* %0, %struct.pathhead** %2
%4 = load %struct.pathhead*, %struct.pathhead** %2
%5 = call i8* @qstring(%struct.pathhead* %4)
store i8* %5, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @ENOMEM
store i32 %8, i32* @errno
%9 = call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %1
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
ret void
}

LLVM IR (-O2):
%struct.pathhead = type { i32 }
@ENOMEM = global i32 0
@errno = global i32 0
@.str = [21 x i8] c"building path string\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @showpath(%struct.pathhead* %0) {
%2 = tail call i8* @qstring(%struct.pathhead* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @ENOMEM
store i32 %5, i32* @errno
%6 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = tail call i32 @free(i8* %2)
ret void
}