#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ process_args(char *);
void process_response_file(const char *file) {
  char str[2048];
  FILE *f = fopen(file, "r");
  if (!f) {
    perror(file);
    exit(-1);
  }
  while (fgets(str, sizeof str, f)) {
    process_args(str);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<process_response_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
jne    11a7 <process_response_file+0x47>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    11ac <process_response_file+0x4c>
lea    -0x810(%rbp),%rdi
mov    -0x818(%rbp),%rdx
mov    $0x800,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11df <process_response_file+0x7f>
lea    -0x810(%rbp),%rdi
call   1080 <process_args@plt>
jmp    11ac <process_response_file+0x4c>
mov    -0x818(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_response_file>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%rbx
lea    0xe8c(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d0 <process_response_file+0x70>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x800,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11bd <process_response_file+0x5d>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <process_args@plt>
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11a0 <process_response_file+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @process_response_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [2048 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @perror(i8* %10)
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %1
br label %14
14: ; preds = %19, %13
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%16 = load i32*, i32** %4
%17 = call i64 @fgets(i8* %15, i32 2048, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%21 = call i32 @process_args(i8* %20)
br label %14
22: ; preds = %14
%23 = load i32*, i32** %4
%24 = call i32 @fclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @process_response_file(i8* nocapture %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %3, i32 2048, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %12
9: ; preds = %1
%10 = tail call i32 @perror(i8* %0)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %6, %12
%13 = call i32 @process_args(i8* %3)
%14 = call i64 @fgets(i8* %3, i32 2048, i32* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %12
16: ; preds = %12, %6
%17 = call i32 @fclose(i32* %4)
ret void
}