#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen_path(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main() {
  FILE *f;
  char buffer[1024];
  char *filename = "sql_parameter_file.dat";
  f = fopen_path(filename, "r");
  if (!f) {
    fprintf(stderr, "Error: cannot find file = %s\n", filename);
  }
  while (fgets(buffer, 1023, f))
    printf("%s", buffer);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen_path@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <main+0x5e>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x418(%rbp),%rdx
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11b3 <main+0x63>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11ea <main+0x9a>
lea    -0x410(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11b3 <main+0x63>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xe9d(%rip),%rdi
lea    0xead(%rip),%rsi
call   1070 <fopen_path@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1193 <main+0x43>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
lea    0xe72(%rip),%rdx
call   1060 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x3ff,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e0 <main+0x90>
lea    0xe88(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"sql_parameter_file.dat\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Error: cannot find file = %s\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %4
%6 = call i32* @fopen_path(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %4
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %9, %0
br label %14
14: ; preds = %19, %13
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = load i32*, i32** %2
%17 = call i64 @fgets(i8* %15, i32 1023, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %14
22: ; preds = %14
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"sql_parameter_file.dat\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Error: cannot find file = %s\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen_path(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = call i64 @fgets(i8* %2, i32 1023, i32* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8, %11
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%13 = call i64 @fgets(i8* %2, i32 1023, i32* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11, %8
%16 = call i32 @fclose(i32* %3)
ret i32 0
}