#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 */
struct type {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
FILE *m4open(char *ofname, struct type *tp) {
  char tmpfname[256];
  FILE *pfp;
  if (strcmp(ofname, "-") == 0)
    strcpy(tmpfname, "/usr/bin/m4");
  else
    sprintf(tmpfname, "%s > %s", "/usr/bin/m4", ofname);
  if ((pfp = popen(tmpfname, "w")) == NULL) {
    fprintf(stderr, "dbow error: ");
    perror(tmpfname);
    exit(1);
  }
  return (pfp);
}


x86 assembly (clang, -O0):
<m4open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <m4open+0x45>
lea    -0x110(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11d3 <m4open+0x63>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
lea    0xe47(%rip),%rsi
lea    0xe34(%rip),%rdx
call   1080 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    1222 <m4open+0xb2>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x110(%rbp),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x118(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m4open>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <m4open+0x37>
lea    0xe7b(%rip),%rsi
lea    0xe68(%rip),%rdx
mov    %rsp,%rdi
mov    %rbx,%rcx
call   1080 <sprintf@plt>
jmp    11b6 <m4open+0x46>
lea    0xe54(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xe59(%rip),%rsi
mov    %rsp,%rdi
call   1060 <popen@plt>
test   %rax,%rax
je     11d3 <m4open+0x63>
add    $0x100,%rsp
pop    %rbx
ret
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rsp,%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.type = type { i32 }
@.str = [2 x i8] c"-\00"
@.str.1 = [12 x i8] c"/usr/bin/m4\00"
@.str.2 = [8 x i8] c"%s > %s\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [13 x i8] c"dbow error: \00"
define i32* @m4open(i8* %0, %struct.type* %1) {
%3 = alloca i8*
%4 = alloca %struct.type*
%5 = alloca [256 x i8]
%6 = alloca i32*
store i8* %0, i8** %3
store %struct.type* %1, %struct.type** %4
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %17
13: ; preds = %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %10
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = call i32* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%25 = call i32 @perror(i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %17
%28 = load i32*, i32** %6
ret i32* %28
}

LLVM IR (-O2):
%struct.type = type { i32 }
@.str = [2 x i8] c"-\00"
@.str.1 = [12 x i8] c"/usr/bin/m4\00"
@.str.2 = [8 x i8] c"%s > %s\00"
@.str.3 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.4 = [13 x i8] c"dbow error: \00"
define noalias i32* @m4open(i8* %0, %struct.type* nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %7
%12 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @perror(i8* %4)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
ret i32* %12
}