#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*/ dbr_abort(int);
int /*<<< orphan*/ dbr_mesg(char *, char const *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char const *, char *);
FILE *start_pattern_output(const char *ofname) {
  FILE *f;
  if (!ofname || !*ofname || !strcmp(ofname, "-")) {
    f = stdout;
  } else {
    f = fopen(ofname, "w");
    if (!f) {
      dbr_mesg("Error: can not open file: %s\n", ofname);
      dbr_abort(1);
    }
  }
  fprintf(f, "#debyer-pattern ");
  return f;
}


x86 assembly (clang, -O0):
<start_pattern_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118d <start_pattern_output+0x3d>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     118d <start_pattern_output+0x3d>
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a0 <start_pattern_output+0x50>
mov    0x2e4c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    11de <start_pattern_output+0x8e>
mov    -0x8(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d9 <start_pattern_output+0x89>
mov    -0x8(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1050 <dbr_mesg@plt>
mov    $0x1,%edi
call   1060 <dbr_abort@plt>
jmp    11de <start_pattern_output+0x8e>
mov    -0x10(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_pattern_output>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11a8 <start_pattern_output+0x58>
mov    %rdi,%r14
cmpb   $0x0,(%rdi)
je     11a8 <start_pattern_output+0x58>
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a8 <start_pattern_output+0x58>
lea    0xe87(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b2 <start_pattern_output+0x62>
lea    0xe72(%rip),%rdi
mov    %r14,%rsi
call   1040 <dbr_mesg@plt>
mov    $0x1,%edi
call   1050 <dbr_abort@plt>
xor    %ebx,%ebx
jmp    11b2 <start_pattern_output+0x62>
mov    0x2e31(%rip),%rax
mov    (%rax),%rbx
lea    0xe69(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"Error: can not open file: %s\0A\00"
@.str.3 = [17 x i8] c"#debyer-pattern \00"
define i32* @start_pattern_output(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10, %6, %1
%15 = load i32*, i32** @stdout
store i32* %15, i32** %3
br label %26
16: ; preds = %10
%17 = load i8*, i8** %2
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %3
%19 = load i32*, i32** %3
%20 = icmp ne i32* %19, null
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = load i8*, i8** %2
%23 = call i32 @dbr_mesg(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @dbr_abort(i32 1)
br label %25
25: ; preds = %21, %16
br label %26
26: ; preds = %25, %14
%27 = load i32*, i32** %3
%28 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %3
ret i32* %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"Error: can not open file: %s\0A\00"
@.str.3 = [17 x i8] c"#debyer-pattern \00"
define i32* @start_pattern_output(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6, %3, %1
%10 = load i32*, i32** @stdout
br label %17
11: ; preds = %6
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 @dbr_mesg(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%16 = tail call i32 @dbr_abort(i32 1)
br label %17
17: ; preds = %11, %14, %9
%18 = phi i32* [ %12, %11 ], [ null, %14 ], [ %10, %9 ]
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 16, i64 1, i32* %18)
ret i32* %18
}