#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
scalar_t__ strstr(char *, char *);
FILE *Log_destToFile(char *dest) {
  FILE *file = NULL;
  if (strcmp(dest, "stdout") == 0)
    file = stdout;
  else if (strcmp(dest, "stderr") == 0)
    file = stderr;
  else {
    if (strstr(dest, "FFDC"))
      file = fopen(dest, "ab");
    else
      file = fopen(dest, "wb");
  }
  return file;
}


x86 assembly (clang, -O0):
<Log_destToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1171 <Log_destToFile+0x41>
mov    0x2e73(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    11ef <Log_destToFile+0xbf>
mov    -0x8(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <Log_destToFile+0x6e>
mov    0x2e4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    11ea <Log_destToFile+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11d1 <Log_destToFile+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
jmp    11e5 <Log_destToFile+0xb5>
mov    -0x8(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
jmp    11ea <Log_destToFile+0xba>
jmp    11ef <Log_destToFile+0xbf>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Log_destToFile>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1176 <Log_destToFile+0x46>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117f <Log_destToFile+0x4f>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     118b <Log_destToFile+0x5b>
lea    0xe9f(%rip),%rsi
jmp    1192 <Log_destToFile+0x62>
mov    0x2e5b(%rip),%rax
jmp    1186 <Log_destToFile+0x56>
mov    0x2e5a(%rip),%rax
mov    (%rax),%rax
pop    %rbx
ret
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <fopen@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"stdout\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"stderr\00"
@stderr = global i32* null
@.str.2 = [5 x i8] c"FFDC\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [3 x i8] c"wb\00"
define i32* @Log_destToFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %3
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32*, i32** @stdout
store i32* %8, i32** %3
br label %27
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32*, i32** @stderr
store i32* %14, i32** %3
br label %26
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = call i64 @strstr(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %2
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %3
br label %25
22: ; preds = %15
%23 = load i8*, i8** %2
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %24, i32** %3
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25, %13
br label %27
27: ; preds = %26, %7
%28 = load i32*, i32** %3
ret i32* %28
}

LLVM IR (-O2):
@.str = [7 x i8] c"stdout\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"stderr\00"
@stderr = global i32* null
@.str.2 = [5 x i8] c"FFDC\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [3 x i8] c"wb\00"
define i32* @Log_destToFile(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load i32*, i32** @stdout
br label %18
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i32*, i32** @stderr
br label %18
11: ; preds = %6
%12 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %9, %16, %14, %4
%19 = phi i32* [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %17, %16 ]
ret i32* %19
}