#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 fh_program {
  int dummy;
};
struct fh_input {
  int dummy;
};

/* Variables and functions */
int fh_compile_input(struct fh_program *, struct fh_input *);
struct fh_input *fh_open_input_file(char const *);
int /*<<< orphan*/ fh_set_error(struct fh_program *, char *, char const *);
int fh_compile_file(struct fh_program *prog, const char *filename) {
  struct fh_input *in = fh_open_input_file(filename);
  if (!in) {
    fh_set_error(prog, "can't open '%s'", filename);
    return -1;
  }
  return fh_compile_input(prog, in);
}


x86 assembly (clang, -O0):
<fh_compile_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fh_open_input_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1178 <fh_compile_file+0x48>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe99(%rip),%rsi
call   1050 <fh_set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <fh_compile_file+0x58>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <fh_compile_input@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fh_compile_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <fh_open_input_file@plt>
test   %rax,%rax
je     1159 <fh_compile_file+0x29>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fh_compile_input@plt>
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <fh_set_error@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.fh_program = type { i32 }
%struct.fh_input = type { i32 }
@.str = [16 x i8] c"can't open '%s'\00"
define i32 @fh_compile_file(%struct.fh_program* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.fh_program*
%5 = alloca i8*
%6 = alloca %struct.fh_input*
store %struct.fh_program* %0, %struct.fh_program** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call %struct.fh_input* @fh_open_input_file(i8* %7)
store %struct.fh_input* %8, %struct.fh_input** %6
%9 = load %struct.fh_input*, %struct.fh_input** %6
%10 = icmp ne %struct.fh_input* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load %struct.fh_program*, %struct.fh_program** %4
%13 = load i8*, i8** %5
%14 = call i32 @fh_set_error(%struct.fh_program* %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 -1, i32* %3
br label %19
15: ; preds = %2
%16 = load %struct.fh_program*, %struct.fh_program** %4
%17 = load %struct.fh_input*, %struct.fh_input** %6
%18 = call i32 @fh_compile_input(%struct.fh_program* %16, %struct.fh_input* %17)
store i32 %18, i32* %3
br label %19
19: ; preds = %15, %11
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.fh_program = type { i32 }
%struct.fh_input = type { i32 }
@.str = [16 x i8] c"can't open '%s'\00"
define i32 @fh_compile_file(%struct.fh_program* %0, i8* %1) {
%3 = tail call %struct.fh_input* @fh_open_input_file(i8* %1)
%4 = icmp eq %struct.fh_input* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fh_set_error(%struct.fh_program* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %9
7: ; preds = %2
%8 = tail call i32 @fh_compile_input(%struct.fh_program* %0, %struct.fh_input* %3)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %8, %7 ], [ -1, %5 ]
ret i32 %10
}