#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 *dirname(char *);
int /*<<< orphan*/ printf(char *, char const *, char const *, char *);
int strcmp(char *, char const *);
char *strdupa(char const *);
int test(const char *input, const char *result) {
  int retval;
  char *cp;
  cp = strdupa(input);
  cp = dirname(cp);
  retval = strcmp(cp, result);
  if (retval)
    printf("dirname(\"%s\") should be \"%s\", but is \"%s\"\n", input, result,
           cp);
  return retval;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdupa@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <dirname@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119c <test+0x5c>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <strdupa@plt>
mov    %rax,%rdi
call   1040 <dirname@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1183 <test+0x43>
lea    0xe8b(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"dirname(\22%s\22) should be \22%s\22, but is \22%s\22\0A\00"
define i32 @test(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @strdupa(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = call i8* @dirname(i8* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i8*, i8** %4
%13 = call i32 @strcmp(i8* %11, i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18, i8* %19)
br label %21
21: ; preds = %16, %2
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
@.str = [43 x i8] c"dirname(\22%s\22) should be \22%s\22, but is \22%s\22\0A\00"
define i32 @test(i8* %0, i8* %1) {
%3 = tail call i8* @strdupa(i8* %0)
%4 = tail call i8* @dirname(i8* %3)
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(1) %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %4)
br label %9
9: ; preds = %7, %2
ret i32 %5
}