#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*/ configfile_handle_line(char *, char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ str_empty(char *);
int /*<<< orphan*/ str_removenl(char *);
scalar_t__ str_starts(char *, char *);
char *str_tabval(char *, int);
char *strtok(char *, char *);
void configfile_parse(FILE *config_file) {
  if (!config_file)
    return;
  int buffer_size = 128;
  char buffer[buffer_size];
  char *arg = NULL;
  char *val = NULL;
  char *comment_character = "#";
  char *config_delim = " ";
  while (fgets(buffer, buffer_size, config_file) != NULL) {
    if (str_starts(buffer, comment_character) || str_empty(buffer))
      continue;
    str_removenl(buffer);
    val = str_tabval(buffer, buffer_size);
    arg = strtok(buffer, config_delim);
    configfile_handle_line(arg, val);
  }
}


x86 assembly (clang, -O0):
<configfile_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118c <configfile_parse+0x1c>
jmp    126b <configfile_parse+0xfb>
movl   $0x80,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe30(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1264 <configfile_parse+0xf4>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <str_starts@plt>
cmp    $0x0,%rax
jne    1223 <configfile_parse+0xb3>
mov    -0x48(%rbp),%rdi
call   1050 <str_empty@plt>
cmp    $0x0,%rax
je     1228 <configfile_parse+0xb8>
jmp    11df <configfile_parse+0x6f>
mov    -0x48(%rbp),%rdi
call   1030 <str_removenl@plt>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1090 <str_tabval@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <configfile_handle_line@plt>
jmp    11df <configfile_parse+0x6f>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configfile_parse>:
test   %rdi,%rdi
je     1234 <configfile_parse+0xc4>
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsp,-0x30(%rbp)
mov    %rsp,%rbx
add    $0xffffffffffffff80,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1222 <configfile_parse+0xb2>
lea    0xe4c(%rip),%r15
lea    0xe47(%rip),%r12
jmp    11d5 <configfile_parse+0x65>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1222 <configfile_parse+0xb2>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <str_starts@plt>
test   %rax,%rax
jne    11c0 <configfile_parse+0x50>
mov    %rbx,%rdi
call   1050 <str_empty@plt>
test   %rax,%rax
jne    11c0 <configfile_parse+0x50>
mov    %rbx,%rdi
call   1030 <str_removenl@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
call   1090 <str_tabval@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
mov    %r13,%rsi
call   1040 <configfile_handle_line@plt>
jmp    11c0 <configfile_parse+0x50>
mov    -0x30(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
@.str.1 = [2 x i8] c" \00"
define void @configfile_parse(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32* %0, i32** %2
%10 = load i32*, i32** %2
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
br label %42
13: ; preds = %1
store i32 128, i32* %3
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %4
%17 = alloca i8, i64 %15
store i64 %15, i64* %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %18
18: ; preds = %31, %30, %13
%19 = load i32, i32* %3
%20 = load i32*, i32** %2
%21 = call i32* @fgets(i8* %17, i32 %19, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %40
23: ; preds = %18
%24 = load i8*, i8** %8
%25 = call i64 @str_starts(i8* %17, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = call i64 @str_empty(i8* %17)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27, %23
br label %18
31: ; preds = %27
%32 = call i32 @str_removenl(i8* %17)
%33 = load i32, i32* %3
%34 = call i8* @str_tabval(i8* %17, i32 %33)
store i8* %34, i8** %7
%35 = load i8*, i8** %9
%36 = call i8* @strtok(i8* %17, i8* %35)
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = call i32 @configfile_handle_line(i8* %37, i8* %38)
br label %18
40: ; preds = %18
%41 = load i8*, i8** %4
br label %42
42: ; preds = %40, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
@.str.1 = [2 x i8] c" \00"
define void @configfile_parse(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %24, label %3
3: ; preds = %1
%4 = tail call i8* @llvm.stacksave()
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = call i32* @fgets(i8* %6, i32 128, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %23, label %9
9: ; preds = %3, %15
%10 = call i64 @str_starts(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i64 @str_empty(i8* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9, %12, %18
%16 = call i32* @fgets(i8* %6, i32 128, i32* %0)
%17 = icmp eq i32* %16, null
br i1 %17, label %23, label %9
18: ; preds = %12
%19 = call i32 @str_removenl(i8* %6)
%20 = call i8* @str_tabval(i8* %6, i32 128)
%21 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @configfile_handle_line(i8* %21, i8* %20)
br label %15
23: ; preds = %15, %3
br label %24
24: ; preds = %1, %23
ret void
}