#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
scalar_t__ get_app_directory(char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void test_get_app_directory() {
  char *expected = "/tmp/usercache/user/appcache/app_200906101234_0001";
  char *app_dir =
      (char *)get_app_directory("/tmp", "user", "app_200906101234_0001");
  if (strcmp(app_dir, expected) != 0) {
    printf("test_get_app_directory expected %s got %s\n", expected, app_dir);
    exit(1);
  }
  free(app_dir);
}


x86 assembly (clang, -O0):
<test_get_app_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xec9(%rip),%rdi
lea    0xec7(%rip),%rsi
lea    0xea5(%rip),%rdx
call   1050 <get_app_directory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11b6 <test_get_app_directory+0x66>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_app_directory>:
push   %rbx
lea    0xedb(%rip),%rdi
lea    0xed9(%rip),%rsi
lea    0xeb7(%rip),%rdx
call   1050 <get_app_directory@plt>
mov    %rax,%rbx
lea    0xe8b(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    118b <test_get_app_directory+0x3b>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
lea    0xeab(%rip),%rdi
lea    0xe67(%rip),%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"/tmp/usercache/user/appcache/app_200906101234_0001\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [5 x i8] c"user\00"
@.str.3 = [22 x i8] c"app_200906101234_0001\00"
@.str.4 = [43 x i8] c"test_get_app_directory expected %s got %s\0A\00"
define void @test_get_app_directory() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i64 @get_app_directory(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %1
%7 = call i64 @strcmp(i8* %5, i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i8*, i8** %2
%16 = call i32 @free(i8* %15)
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"/tmp/usercache/user/appcache/app_200906101234_0001\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [5 x i8] c"user\00"
@.str.3 = [22 x i8] c"app_200906101234_0001\00"
@.str.4 = [43 x i8] c"test_get_app_directory expected %s got %s\0A\00"
define void @test_get_app_directory() {
%1 = tail call i64 @get_app_directory(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 @free(i8* %2)
ret void
}