#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 const *, char *);
char *cdio_dirname(char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, 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;
  char *dest;
  int i;
  for (i = 0; i < 2; i++) {
    const char *dirname = cdio_dirname(cue_filename[i]);
    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;
    }
  }
  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    0x2c83(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c80(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c7d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c7a(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    122e <main+0xde>
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
call   1050 <cdio_dirname@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1060 <cdio_abspath@plt>
mov    %rax,-0x40(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     121b <main+0xcb>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
mov    -0x40(%rbp),%rcx
lea    0xe0f(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1220 <main+0xd0>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a0 <main+0x50>
mov    -0x34(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1050 <cdio_dirname@plt>
lea    0xeb2(%rip),%rsi
mov    %rax,%rdi
call   1060 <cdio_abspath@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11ab <main+0x5b>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
lea    0xe6f(%rip),%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    $0x1,%ebp
lea    0xe53(%rip),%rdi
call   1050 <cdio_dirname@plt>
lea    0xe5a(%rip),%rsi
mov    %rax,%rdi
call   1060 <cdio_abspath@plt>
mov    %rax,%rbx
lea    0xe46(%rip),%rdi
mov    %rax,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1201 <main+0xb1>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
lea    0xe22(%rip),%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    $0x2,%ebp
mov    %ebp,%edi
call   1070 <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 i8*
%10 = alloca i32
%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* %10
br label %14
14: ; preds = %43, %2
%15 = load i32, i32* %10
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %46
17: ; preds = %14
%18 = load i32, i32* %10
%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** %11
%23 = load i8*, i8** %11
%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** %9
%25 = load i32, i32* %10
%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** %9
%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* %10
%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** %9
%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* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %42
42: ; preds = %32, %17
br label %43
43: ; preds = %42
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %14
46: ; preds = %14
%47 = load i32, i32* %8
%48 = call i32 @exit(i32 %47)
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 i8* @cdio_dirname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i8* @cdio_abspath(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, 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* %13)
br label %19
19: ; preds = %16, %10
%20 = phi i32 [ 2, %16 ], [ %11, %10 ]
%21 = tail call i32 @exit(i32 %20)
unreachable
}