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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *next_line(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ process_parameter(char *, struct gges_parameters *);
scalar_t__ strlen(char *);
void parse_parameters(char *params_file, struct gges_parameters *params) {
  FILE *input;
  char *buffer, *line;
  size_t bufsz;
  input = fopen(params_file, "r");
  buffer = line = NULL;
  bufsz = 0;
  line = next_line(&buffer, &bufsz, input);
  while (!feof(input)) {
    if (strlen(line) > 0) {
      process_parameter(line, params);
    }
    line = next_line(&buffer, &bufsz, input);
  }
  fclose(input);
  free(buffer);
}


x86 assembly (clang, -O0):
<parse_parameters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <next_line@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11df <parse_parameters+0x6f>
jmp    1219 <parse_parameters+0xa9>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jle    11ff <parse_parameters+0x8f>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <process_parameter@plt>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <next_line@plt>
mov    %rax,-0x28(%rbp)
jmp    11c1 <parse_parameters+0x51>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_parameters>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
lea    0xe79(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1070 <next_line@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11de <parse_parameters+0x6e>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
lea    0x8(%rsp),%r13
jmp    120d <parse_parameters+0x9d>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1070 <next_line@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11bf <parse_parameters+0x4f>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
jle    11f0 <parse_parameters+0x80>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <process_parameter@plt>
jmp    11f0 <parse_parameters+0x80>

LLVM IR (-O0):
%struct.gges_parameters = type { i32 }
@.str = [2 x i8] c"r\00"
define void @parse_parameters(i8* %0, %struct.gges_parameters* %1) {
%3 = alloca i8*
%4 = alloca %struct.gges_parameters*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %3
store %struct.gges_parameters* %1, %struct.gges_parameters** %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
store i8* null, i8** %7
store i8* null, i8** %6
store i64 0, i64* %8
%11 = load i32*, i32** %5
%12 = call i8* @next_line(i8** %6, i64* %8, i32* %11)
store i8* %12, i8** %7
br label %13
13: ; preds = %26, %2
%14 = load i32*, i32** %5
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = call i64 @strlen(i8* %19)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = load %struct.gges_parameters*, %struct.gges_parameters** %4
%25 = call i32 @process_parameter(i8* %23, %struct.gges_parameters* %24)
br label %26
26: ; preds = %22, %18
%27 = load i32*, i32** %5
%28 = call i8* @next_line(i8** %6, i64* %8, i32* %27)
store i8* %28, i8** %7
br label %13
29: ; preds = %13
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
%32 = load i8*, i8** %6
%33 = call i32 @free(i8* %32)
ret void
}

LLVM IR (-O2):
%struct.gges_parameters = type { i32 }
@.str = [2 x i8] c"r\00"
define void @parse_parameters(i8* nocapture %0, %struct.gges_parameters* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
store i64 0, i64* %4
%8 = call i8* @next_line(i8** %3, i64* %4, i32* %7)
%9 = call i32 @feof(i32* %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2, %17
%12 = phi i8* [ %18, %17 ], [ %8, %2 ]
%13 = call i64 @strlen(i8* dereferenceable(1) %12)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @process_parameter(i8* %12, %struct.gges_parameters* %1)
br label %17
17: ; preds = %15, %11
%18 = call i8* @next_line(i8** %3, i64* %4, i32* %7)
%19 = call i32 @feof(i32* %7)
%20 = icmp eq i32 %19, 0
br i1 %20, label %11, label %21
21: ; preds = %17, %2
%22 = call i32 @fclose(i32* %7)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
ret void
}