#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*/ free(char *);
char *product_file(char *);
scalar_t__ strcmp(char const *, char *);
int find_sync_dirs(const char *srcarg, char **android_srcdir_out,
                   char **data_srcdir_out) {
  char *android_srcdir, *data_srcdir;
  if (srcarg == NULL) {
    android_srcdir = product_file("system");
    data_srcdir = product_file("data");
  } else {
    if (strcmp(srcarg, "system") == 0) {
      android_srcdir = product_file("system");
      data_srcdir = NULL;
    } else if (strcmp(srcarg, "data") == 0) {
      android_srcdir = NULL;
      data_srcdir = product_file("data");
    } else {
      return 1;
    }
  }
  if (android_srcdir_out != NULL)
    *android_srcdir_out = android_srcdir;
  else
    free(android_srcdir);
  if (data_srcdir_out != NULL)
    *data_srcdir_out = data_srcdir;
  else
    free(data_srcdir);
  return 0;
}


x86 assembly (clang, -O0):
<find_sync_dirs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <find_sync_dirs+0x44>
lea    0xeaa(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,-0x28(%rbp)
lea    0xea1(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,-0x30(%rbp)
jmp    11f8 <find_sync_dirs+0xc8>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ab <find_sync_dirs+0x7b>
lea    0xe6b(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
jmp    11f3 <find_sync_dirs+0xc3>
mov    -0x10(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <find_sync_dirs+0xb2>
movq   $0x0,-0x28(%rbp)
lea    0xe33(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,-0x30(%rbp)
jmp    11ee <find_sync_dirs+0xbe>
movl   $0x1,-0x4(%rbp)
jmp    1247 <find_sync_dirs+0x117>
jmp    11f3 <find_sync_dirs+0xc3>
jmp    11f8 <find_sync_dirs+0xc8>
cmpq   $0x0,-0x18(%rbp)
je     1213 <find_sync_dirs+0xe3>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    121c <find_sync_dirs+0xec>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x20(%rbp)
je     1237 <find_sync_dirs+0x107>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1240 <find_sync_dirs+0x110>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_sync_dirs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
test   %rdi,%rdi
je     118b <find_sync_dirs+0x5b>
mov    %rdi,%rbx
lea    0xeb3(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bb <find_sync_dirs+0x8b>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11e9 <find_sync_dirs+0xb9>
lea    0xe8d(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,%r12
xor    %ebx,%ebx
test   %r15,%r15
jne    11ae <find_sync_dirs+0x7e>
jmp    11d2 <find_sync_dirs+0xa2>
lea    0xe6e(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,%rbx
lea    0xe66(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,%r12
test   %r15,%r15
je     11d2 <find_sync_dirs+0xa2>
mov    %rbx,(%r15)
test   %r14,%r14
je     11df <find_sync_dirs+0xaf>
mov    %r12,(%r14)
jmp    11e7 <find_sync_dirs+0xb7>
lea    0xe3e(%rip),%rdi
call   1040 <product_file@plt>
mov    %rax,%rbx
xor    %r12d,%r12d
test   %r15,%r15
jne    11ae <find_sync_dirs+0x7e>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
jne    11b6 <find_sync_dirs+0x86>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"system\00"
@.str.1 = [5 x i8] c"data\00"
define i32 @find_sync_dirs(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = call i8* @product_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %8
%14 = call i8* @product_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %9
br label %30
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i8* @product_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %8
store i8* null, i8** %9
br label %29
21: ; preds = %15
%22 = load i8*, i8** %5
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
store i8* null, i8** %8
%26 = call i8* @product_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %26, i8** %9
br label %28
27: ; preds = %21
store i32 1, i32* %4
br label %49
28: ; preds = %25
br label %29
29: ; preds = %28, %19
br label %30
30: ; preds = %29, %12
%31 = load i8**, i8*** %6
%32 = icmp ne i8** %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = load i8**, i8*** %6
store i8* %34, i8** %35
br label %39
36: ; preds = %30
%37 = load i8*, i8** %8
%38 = call i32 @free(i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load i8**, i8*** %7
%41 = icmp ne i8** %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i8*, i8** %9
%44 = load i8**, i8*** %7
store i8* %43, i8** %44
br label %48
45: ; preds = %39
%46 = load i8*, i8** %9
%47 = call i32 @free(i8* %46)
br label %48
48: ; preds = %45, %42
store i32 0, i32* %4
br label %49
49: ; preds = %48, %27
%50 = load i32, i32* %4
ret i32 %50
}

LLVM IR (-O2):
@.str = [7 x i8] c"system\00"
@.str.1 = [5 x i8] c"data\00"
define i32 @find_sync_dirs(i8* %0, i8** writeonly %1, i8** writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i8* @product_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @product_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %18
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i8* @product_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %18
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = tail call i8* @product_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %11, %16, %5
%19 = phi i8* [ %6, %5 ], [ %12, %11 ], [ null, %16 ]
%20 = phi i8* [ %7, %5 ], [ null, %11 ], [ %17, %16 ]
%21 = icmp eq i8** %1, null
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* %19, i8** %1
br label %25
23: ; preds = %18
%24 = tail call i32 @free(i8* %19)
br label %25
25: ; preds = %23, %22
%26 = icmp eq i8** %2, null
br i1 %26, label %28, label %27
27: ; preds = %25
store i8* %20, i8** %2
br label %30
28: ; preds = %25
%29 = tail call i32 @free(i8* %20)
br label %30
30: ; preds = %27, %28, %13
%31 = phi i32 [ 1, %13 ], [ 0, %28 ], [ 0, %27 ]
ret i32 %31
}