#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 *cdio_abspath(char *, char *);
char *cdio_dirname(char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
int main(int argc, const char *argv[]) {
  const char *cue_filename[] = {"/tmp/foo.bar", "foo.bar"};
  const char *expect[] = {"/tmp/baz", "./baz"};
  int rc = 0;
  int i;
  for (i = 0; i < 2; i++) {
    char *dirname = cdio_dirname(cue_filename[i]);
    char *dest = cdio_abspath(dirname, "baz");
    if (0 != strcmp(expect[i], dest)) {
      fprintf(stderr, "Incorrect: expecting %s, got %s.\n", expect[i], dest);
      rc = i + 1;
    }
    free(dirname);
    free(dest);
  }
  exit(rc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c73(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c6d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c6a(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x2,-0x38(%rbp)
jge    124b <main+0xeb>
movslq -0x38(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
call   1060 <cdio_dirname@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1070 <cdio_abspath@plt>
mov    %rax,-0x48(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     122b <main+0xcb>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
mov    -0x48(%rbp),%rcx
lea    0xdff(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b0 <main+0x50>
mov    -0x34(%rbp),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xe95(%rip),%rdi
call   1060 <cdio_dirname@plt>
mov    %rax,%rbx
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
call   1070 <cdio_abspath@plt>
mov    %rax,%rbp
lea    0xe81(%rip),%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11c1 <main+0x61>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
lea    0xe5a(%rip),%rdx
mov    %rbp,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xe2d(%rip),%rdi
call   1060 <cdio_dirname@plt>
mov    %rax,%rbx
lea    0xe31(%rip),%rsi
mov    %rax,%rdi
call   1070 <cdio_abspath@plt>
mov    %rax,%rbp
lea    0xe1d(%rip),%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     122b <main+0xcb>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
lea    0xdf9(%rip),%rdx
mov    %rbp,%rcx
call   1050 <fprintf@plt>
mov    $0x2,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14d,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/foo.bar\00"
@.str.1 = [8 x i8] c"foo.bar\00"
@__const.main.cue_filename = [2 x i8*] [i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [9 x i8] c"/tmp/baz\00"
@.str.3 = [6 x i8] c"./baz\00"
@__const.main.expect = [2 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [4 x i8] c"baz\00"
@stderr = global i32 0
@.str.5 = [34 x i8] c"Incorrect: expecting %s, got %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca [2 x i8*]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [2 x i8*]* %6 to i8*
%13 = bitcast [2 x i8*]* %7 to i8*
store i32 0, i32* %8
store i32 0, i32* %9
br label %14
14: ; preds = %47, %2
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %50
17: ; preds = %14
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i8* @cdio_dirname(i8* %21)
store i8* %22, i8** %10
%23 = load i8*, i8** %10
%24 = call i8* @cdio_abspath(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i8* %24, i8** %11
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = load i8*, i8** %11
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp ne i64 0, %30
br i1 %31, label %32, label %42
32: ; preds = %17
%33 = load i32, i32* @stderr
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = load i8*, i8** %11
%39 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %37, i8* %38)
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %42
42: ; preds = %32, %17
%43 = load i8*, i8** %10
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %11
%46 = call i32 @free(i8* %45)
br label %47
47: ; preds = %42
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %14
50: ; preds = %14
%51 = load i32, i32* %8
%52 = call i32 @exit(i32 %51)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/foo.bar\00"
@.str.1 = [8 x i8] c"foo.bar\00"
@.str.2 = [9 x i8] c"/tmp/baz\00"
@.str.3 = [6 x i8] c"./baz\00"
@.str.4 = [4 x i8] c"baz\00"
@stderr = global i32 0
@.str.5 = [34 x i8] c"Incorrect: expecting %s, got %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @cdio_dirname(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @cdio_abspath(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %10
10: ; preds = %7, %2
%11 = phi i32 [ 1, %7 ], [ 0, %2 ]
%12 = tail call i32 @free(i8* %3)
%13 = tail call i32 @free(i8* %4)
%14 = tail call i8* @cdio_dirname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i8* @cdio_abspath(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %21
21: ; preds = %18, %10
%22 = phi i32 [ 2, %18 ], [ %11, %10 ]
%23 = tail call i32 @free(i8* %14)
%24 = tail call i32 @free(i8* %15)
%25 = tail call i32 @exit(i32 %22)
unreachable
}