#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 *);
char *get_app_log_directory(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void test_get_app_log_dir() {
  char *expected = "/tmp"
                   "/test-container-executor"
                   "/logs/userlogs/app_200906101234_0001";
  char *logdir = get_app_log_directory("/tmp"
                                       "/test-container-executor"
                                       "/logs/userlogs",
                                       "app_200906101234_0001");
  if (strcmp(logdir, expected) != 0) {
    printf("Fail get_app_log_dir got %s expected %s\n", logdir, expected);
    exit(1);
  }
  free(logdir);
}


x86 assembly (clang, -O0):
<test_get_app_log_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xed7(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1070 <get_app_log_directory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11af <test_get_app_log_dir+0x5f>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_app_log_dir>:
push   %rbx
lea    0xee9(%rip),%rdi
lea    0xecc(%rip),%rsi
call   1070 <get_app_log_directory@plt>
mov    %rax,%rbx
lea    0xe92(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1184 <test_get_app_log_dir+0x34>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
lea    0xee1(%rip),%rdi
lea    0xe6e(%rip),%rdx
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"/tmp/test-container-executor/logs/userlogs/app_200906101234_0001\00"
@.str.1 = [43 x i8] c"/tmp/test-container-executor/logs/userlogs\00"
@.str.2 = [22 x i8] c"app_200906101234_0001\00"
@.str.3 = [41 x i8] c"Fail get_app_log_dir got %s expected %s\0A\00"
define void @test_get_app_log_dir() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i8* @get_app_log_directory(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %1
%6 = call i64 @strcmp(i8* %4, i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = load i8*, i8** %1
%11 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %10)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"/tmp/test-container-executor/logs/userlogs/app_200906101234_0001\00"
@.str.1 = [43 x i8] c"/tmp/test-container-executor/logs/userlogs\00"
@.str.2 = [22 x i8] c"app_200906101234_0001\00"
@.str.3 = [41 x i8] c"Fail get_app_log_dir got %s expected %s\0A\00"
define void @test_get_app_log_dir() {
%1 = tail call i8* @get_app_log_directory(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @free(i8* %1)
ret void
}