#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(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ set_posword(char *);
int sscanf(char *, char *, char *, char *);
scalar_t__ strcasecmp(char *, char *);
int script_config_read(char *cfgName) {
  int i;
  char line[1024], w1[1024], w2[1024];
  FILE *fp;
  fp = fopen(cfgName, "r");
  if (fp == NULL) {
    printf("file not found: %s\n", cfgName);
    return 1;
  }
  while (fgets(line, 1020, fp)) {
    if (line[0] == '/' && line[1] == '/')
      continue;
    i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
    if (i != 2)
      continue;
    if (strcasecmp(w1, "refine_posword") == 0) {
      set_posword(w2);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<script_config_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xc28(%rbp)
cmpq   $0x0,-0xc28(%rbp)
jne    11c0 <script_config_read+0x50>
mov    -0x10(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1280 <script_config_read+0x110>
jmp    11c5 <script_config_read+0x55>
lea    -0x420(%rbp),%rdi
mov    -0xc28(%rbp),%rdx
mov    $0x3fc,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     126d <script_config_read+0xfd>
movsbl -0x420(%rbp),%eax
cmp    $0x2f,%eax
jne    120c <script_config_read+0x9c>
movsbl -0x41f(%rbp),%eax
cmp    $0x2f,%eax
jne    120c <script_config_read+0x9c>
jmp    11c5 <script_config_read+0x55>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rdx
lea    -0xc20(%rbp),%rcx
lea    0xdee(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
je     123f <script_config_read+0xcf>
jmp    11c5 <script_config_read+0x55>
lea    -0x820(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1268 <script_config_read+0xf8>
lea    -0xc20(%rbp),%rdi
call   1090 <set_posword@plt>
jmp    11c5 <script_config_read+0x55>
mov    -0xc28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<script_config_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
mov    %rdi,%rbp
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     123e <script_config_read+0xce>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x3fc,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1232 <script_config_read+0xc2>
mov    %rsp,%r14
lea    0xe57(%rip),%r15
lea    0x800(%rsp),%r12
lea    0x400(%rsp),%r13
lea    0xe4e(%rip),%rbp
jmp    11f5 <script_config_read+0x85>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x3fc,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1232 <script_config_read+0xc2>
cmpb   $0x2f,(%rsp)
jne    1202 <script_config_read+0x92>
cmpb   $0x2f,0x1(%rsp)
je     11e0 <script_config_read+0x70>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    11e0 <script_config_read+0x70>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11e0 <script_config_read+0x70>
mov    %r13,%rdi
call   1090 <set_posword@plt>
jmp    11e0 <script_config_read+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1252 <script_config_read+0xe2>
lea    0xdbd(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"file not found: %s\0A\00"
@.str.2 = [14 x i8] c"%[^:]: %[^\0D\0A]\00"
@.str.3 = [15 x i8] c"refine_posword\00"
define i32 @script_config_read(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32*
store i8* %0, i8** %3
%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** %8
%11 = load i32*, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 1, i32* %2
br label %52
16: ; preds = %1
br label %17
17: ; preds = %48, %40, %32, %16
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %8
%20 = call i64 @fgets(i8* %18, i32 1020, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %49
22: ; preds = %17
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 47
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 47
br i1 %31, label %32, label %33
32: ; preds = %27
br label %17
33: ; preds = %27, %22
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%37 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %36)
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 2
br i1 %39, label %40, label %41
40: ; preds = %33
br label %17
41: ; preds = %33
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%43 = call i64 @strcasecmp(i8* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%47 = call i32 @set_posword(i8* %46)
br label %48
48: ; preds = %45, %41
br label %17
49: ; preds = %17
%50 = load i32*, i32** %8
%51 = call i32 @fclose(i32* %50)
store i32 0, i32* %2
br label %52
52: ; preds = %49, %13
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"file not found: %s\0A\00"
@.str.2 = [14 x i8] c"%[^:]: %[^\0D\0A]\00"
@.str.3 = [15 x i8] c"refine_posword\00"
define i32 @script_config_read(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, 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 %15, label %10
10: ; preds = %1
%11 = call i64 @fgets(i8* %5, i32 1020, i32* %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %10
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1
br label %17
15: ; preds = %1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %36
17: ; preds = %13, %31
%18 = load i8, i8* %5
%19 = icmp eq i8 %18, 47
%20 = load i8, i8* %14
%21 = icmp eq i8 %20, 47
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %31, label %23
23: ; preds = %17
%24 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %7)
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @set_posword(i8* %7)
br label %31
31: ; preds = %26, %29, %17, %23
%32 = call i64 @fgets(i8* %5, i32 1020, i32* %8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %17
34: ; preds = %31, %10
%35 = call i32 @fclose(i32* %8)
br label %36
36: ; preds = %34, %15
%37 = phi i32 [ 1, %15 ], [ 0, %34 ]
ret i32 %37
}