#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*/ *openPipe(char *, char *);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ stringEndsIn(char *, char *);
int /*<<< orphan*/ *writeZippedFile(char *, char);
FILE *svd_writeFile(char *fileName, char append) {
  if (!strcmp(fileName, "-"))
    return stdout;
  if (fileName[0] == '|')
    return openPipe(fileName + 1, "w");
  if (stringEndsIn(fileName, ".gz") || stringEndsIn(fileName, ".Z") ||
      stringEndsIn(fileName, ".bz") || stringEndsIn(fileName, ".bz2"))
    return writeZippedFile(fileName, append);
  return (append) ? fopen(fileName, "a") : fopen(fileName, "w");
}


x86 assembly (clang, -O0):
<svd_writeFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    118e <svd_writeFile+0x3e>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    127b <svd_writeFile+0x12b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
jne    11bb <svd_writeFile+0x6b>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xe55(%rip),%rsi
call   1070 <openPipe@plt>
mov    %rax,-0x8(%rbp)
jmp    127b <svd_writeFile+0x12b>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <stringEndsIn@plt>
cmp    $0x0,%rax
jne    1223 <svd_writeFile+0xd3>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1030 <stringEndsIn@plt>
cmp    $0x0,%rax
jne    1223 <svd_writeFile+0xd3>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1030 <stringEndsIn@plt>
cmp    $0x0,%rax
jne    1223 <svd_writeFile+0xd3>
mov    -0x10(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <stringEndsIn@plt>
cmp    $0x0,%rax
je     1239 <svd_writeFile+0xe9>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1040 <writeZippedFile@plt>
mov    %rax,-0x8(%rbp)
jmp    127b <svd_writeFile+0x12b>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     125f <svd_writeFile+0x10f>
mov    -0x10(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1273 <svd_writeFile+0x123>
mov    -0x10(%rbp),%rdi
lea    0xd98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svd_writeFile>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1186 <svd_writeFile+0x36>
cmpb   $0x7c,(%rbx)
jne    1197 <svd_writeFile+0x47>
add    $0x1,%rbx
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <openPipe@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <stringEndsIn@plt>
test   %rax,%rax
jne    11e7 <svd_writeFile+0x97>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1030 <stringEndsIn@plt>
test   %rax,%rax
jne    11e7 <svd_writeFile+0x97>
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
call   1030 <stringEndsIn@plt>
test   %rax,%rax
jne    11e7 <svd_writeFile+0x97>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1030 <stringEndsIn@plt>
test   %rax,%rax
je     11f9 <svd_writeFile+0xa9>
movsbl %bpl,%esi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <writeZippedFile@plt>
test   %bpl,%bpl
je     1207 <svd_writeFile+0xb7>
lea    0xe0f(%rip),%rsi
jmp    120e <svd_writeFile+0xbe>
lea    0xdf4(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <fopen@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c".gz\00"
@.str.3 = [3 x i8] c".Z\00"
@.str.4 = [4 x i8] c".bz\00"
@.str.5 = [5 x i8] c".bz2\00"
@.str.6 = [2 x i8] c"a\00"
define i32* @svd_writeFile(i8* %0, i8 signext %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
%6 = load i8*, i8** %4
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = load i32*, i32** @stdout
store i32* %10, i32** %3
br label %53
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 124
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i32* @openPipe(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %3
br label %53
21: ; preds = %11
%22 = load i8*, i8** %4
%23 = call i64 @stringEndsIn(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %37, label %25
25: ; preds = %21
%26 = load i8*, i8** %4
%27 = call i64 @stringEndsIn(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i64 @stringEndsIn(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = call i64 @stringEndsIn(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33, %29, %25, %21
%38 = load i8*, i8** %4
%39 = load i8, i8* %5
%40 = call i32* @writeZippedFile(i8* %38, i8 signext %39)
store i32* %40, i32** %3
br label %53
41: ; preds = %33
%42 = load i8, i8* %5
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %51
48: ; preds = %41
%49 = load i8*, i8** %4
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %48, %45
%52 = phi i32* [ %47, %45 ], [ %50, %48 ]
store i32* %52, i32** %3
br label %53
53: ; preds = %51, %37, %17, %9
%54 = load i32*, i32** %3
ret i32* %54
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c".gz\00"
@.str.3 = [3 x i8] c".Z\00"
@.str.4 = [4 x i8] c".bz\00"
@.str.5 = [5 x i8] c".bz2\00"
@.str.6 = [2 x i8] c"a\00"
define i32* @svd_writeFile(i8* %0, i8 signext %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load i32*, i32** @stdout
br label %33
7: ; preds = %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 124
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = tail call i32* @openPipe(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
13: ; preds = %7
%14 = tail call i64 @stringEndsIn(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = tail call i64 @stringEndsIn(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = tail call i64 @stringEndsIn(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i64 @stringEndsIn(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22, %19, %16, %13
%26 = tail call i32* @writeZippedFile(i8* %0, i8 signext %1)
br label %33
27: ; preds = %22
%28 = icmp eq i8 %1, 0
br i1 %28, label %31, label %29
29: ; preds = %27
%30 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %33
31: ; preds = %27
%32 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %29, %31, %25, %10, %5
%34 = phi i32* [ %12, %10 ], [ %26, %25 ], [ %6, %5 ], [ %30, %29 ], [ %32, %31 ]
ret i32* %34
}