#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*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
void load_config(char *path, char *conf_name, char *conf) {
  int i = 0, j = 0;
  char str[300], param[300];
  FILE *fin;
  if ((fin = fopen(path, "r")) == NULL) {
    exit(1);
  }
  for (;;) {
    if (fgets(str, 300, fin) == NULL) {
      fclose(fin);
      exit(1);
    }
    if (!strncmp(str, conf_name, strlen(conf_name))) {
      while (str[i++] != '=') {
        ;
      }
      while (str[i] != '\n') {
        param[j++] = str[i++];
      }
      param[j] = '\0';
      strcpy(conf, param);
      fclose(fin);
      return;
    }
  }
  fclose(fin);
  exit(1);
}


x86 assembly (clang, -O0):
<load_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x288(%rbp)
cmp    $0x0,%rax
jne    11c0 <load_config+0x50>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11c5 <load_config+0x55>
lea    -0x150(%rbp),%rdi
mov    -0x288(%rbp),%rdx
mov    $0x12c,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    11fd <load_config+0x8d>
mov    -0x288(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x150(%rbp),%rax
mov    %rax,-0x298(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x290(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x298(%rbp),%rdi
mov    -0x290(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12dd <load_config+0x16d>
jmp    1242 <load_config+0xd2>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movsbl -0x150(%rbp,%rax,1),%eax
ff
cmp    $0x3d,%eax
je     1265 <load_config+0xf5>
jmp    1242 <load_config+0xd2>
jmp    126a <load_config+0xfa>
movslq -0x1c(%rbp),%rax
movsbl -0x150(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     12ac <load_config+0x13c>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
mov    -0x150(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
cltq
mov    %cl,-0x280(%rbp,%rax,1)
jmp    126a <load_config+0xfa>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x280(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x288(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x2a0,%rsp
pop    %rbp
ret
jmp    11c5 <load_config+0x55>

x86 assembly (clang, -O2):
<load_config>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x268,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125c <load_config+0xec>
mov    %rax,%r15
mov    %rsp,%r12
nop
mov    %r12,%rdi
mov    $0x12c,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1254 <load_config+0xe4>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11a0 <load_config+0x30>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x3d,(%rsp,%rcx,1)
lea    0x1(%rcx),%rcx
jne    11e0 <load_config+0x70>
mov    %ecx,%eax
mov    (%rsp,%rax,1),%al
cmp    $0xa,%al
jne    11f7 <load_config+0x87>
xor    %eax,%eax
jmp    1225 <load_config+0xb5>
mov    %ecx,%ecx
add    %rsp,%rcx
add    $0x1,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,0x130(%rsp,%rdx,1)
movzbl (%rcx,%rdx,1),%eax
add    $0x1,%rdx
cmp    $0xa,%al
jne    1210 <load_config+0xa0>
mov    %edx,%eax
movb   $0x0,0x130(%rsp,%rax,1)
lea    0x130(%rsp),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @load_config(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [300 x i8]
%10 = alloca [300 x i8]
%11 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %11
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
br label %18
18: ; preds = %71, %17
%19 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%20 = load i32*, i32** %11
%21 = call i32* @fgets(i8* %19, i32 300, i32* %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32*, i32** %11
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %18
%28 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = load i8*, i8** %5
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @strncmp(i8* %28, i8* %29, i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %71, label %34
34: ; preds = %27
br label %35
35: ; preds = %43, %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 61
br i1 %42, label %43, label %44
43: ; preds = %35
br label %35
44: ; preds = %35
br label %45
45: ; preds = %52, %44
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 10
br i1 %51, label %52, label %62
52: ; preds = %45
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds [300 x i8], [300 x i8]* %10, i64 0, i64 %60
store i8 %57, i8* %61
br label %45
62: ; preds = %45
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [300 x i8], [300 x i8]* %10, i64 0, i64 %64
store i8 0, i8* %65
%66 = load i8*, i8** %6
%67 = getelementptr inbounds [300 x i8], [300 x i8]* %10, i64 0, i64 0
%68 = call i32 @strcpy(i8* %66, i8* %67)
%69 = load i32*, i32** %11
%70 = call i32 @fclose(i32* %69)
ret void
71: ; preds = %27
br label %18
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @load_config(i8* nocapture %0, i8* %1, i8* %2) {
%4 = alloca [300 x i8]
%5 = alloca [300 x i8]
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3, %18
%13 = call i32* @fgets(i8* %6, i32 300, i32* %8)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @fclose(i32* %8)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = call i32 @strlen(i8* %1)
%20 = call i32 @strncmp(i8* %6, i8* %1, i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %18, %22
%23 = phi i64 [ %24, %22 ], [ 0, %18 ]
%24 = add nuw i64 %23, 1
%25 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 %23
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 61
br i1 %27, label %28, label %22
28: ; preds = %22
%29 = and i64 %24, 4294967295
%30 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %45, label %33
33: ; preds = %28, %33
%34 = phi i64 [ %38, %33 ], [ 0, %28 ]
%35 = phi i64 [ %37, %33 ], [ %29, %28 ]
%36 = phi i8 [ %41, %33 ], [ %31, %28 ]
%37 = add nuw i64 %35, 1
%38 = add nuw i64 %34, 1
%39 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %34
store i8 %36, i8* %39
%40 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 %37
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 10
br i1 %42, label %43, label %33
43: ; preds = %33
%44 = and i64 %38, 4294967295
br label %45
45: ; preds = %43, %28
%46 = phi i64 [ 0, %28 ], [ %44, %43 ]
%47 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %46
store i8 0, i8* %47
%48 = call i32 @strcpy(i8* %2, i8* %7)
%49 = call i32 @fclose(i32* %8)
ret void
}