#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 check_upper_case(char *);
int /*<<< orphan*/ convert_to_int(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int file_parse(char *path) {
  FILE *filed;
  char tmp[680];
  int test = 0;
  int ret = 0;
  printf("config file is: %s\n", path);
  filed = fopen(path, "r");
  if (filed != NULL) {
    while (fgets(tmp, 680, filed) != NULL) {
      ret = check_upper_case(tmp);
      if (ret != 0) {
        printf("Error!!!there is a upper case 'X' in config file \nLine: %s\n",
               tmp);
        break;
      } else
        convert_to_int(tmp);
    }
    fclose(filed);
    return 0;
  } else {
    printf("can not open file in:%s", path);
    return 0;
  }
}


x86 assembly (clang, -O0):
<file_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2d0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x2c4(%rbp)
movl   $0x0,-0x2c8(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1233 <file_parse+0xd3>
jmp    11b7 <file_parse+0x57>
lea    -0x2c0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2a8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     121e <file_parse+0xbe>
lea    -0x2c0(%rbp),%rdi
call   1080 <check_upper_case@plt>
mov    %eax,-0x2c8(%rbp)
cmpl   $0x0,-0x2c8(%rbp)
je     120d <file_parse+0xad>
lea    -0x2c0(%rbp),%rsi
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
jmp    121e <file_parse+0xbe>
lea    -0x2c0(%rbp),%rdi
call   1060 <convert_to_int@plt>
jmp    11b7 <file_parse+0x57>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    124a <file_parse+0xea>
mov    -0x10(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_parse>:
push   %r14
push   %rbx
sub    $0x2a8,%rsp
mov    %rdi,%rbx
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11db <file_parse+0x7b>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x2a8,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11fb <file_parse+0x9b>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <check_upper_case@plt>
test   %eax,%eax
jne    11ec <file_parse+0x8c>
mov    %rbx,%rdi
call   1060 <convert_to_int@plt>
mov    %rbx,%rdi
mov    $0x2a8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b0 <file_parse+0x50>
jmp    11fb <file_parse+0x9b>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1203 <file_parse+0xa3>
lea    0xe23(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x2a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"config file is: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Error!!!there is a upper case 'X' in config file \0ALine: %s\0A\00"
@.str.3 = [24 x i8] c"can not open file in:%s\00"
define i32 @file_parse(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [680 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %35
14: ; preds = %1
br label %15
15: ; preds = %31, %14
%16 = getelementptr inbounds [680 x i8], [680 x i8]* %5, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i32* @fgets(i8* %16, i32 680, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = getelementptr inbounds [680 x i8], [680 x i8]* %5, i64 0, i64 0
%22 = call i32 @check_upper_case(i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = getelementptr inbounds [680 x i8], [680 x i8]* %5, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %32
28: ; preds = %20
%29 = getelementptr inbounds [680 x i8], [680 x i8]* %5, i64 0, i64 0
%30 = call i32 @convert_to_int(i8* %29)
br label %31
31: ; preds = %28
br label %15
32: ; preds = %25, %15
%33 = load i32*, i32** %4
%34 = call i32 @fclose(i32* %33)
store i32 0, i32* %2
br label %38
35: ; preds = %1
%36 = load i8*, i8** %3
%37 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %36)
store i32 0, i32* %2
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [20 x i8] c"config file is: %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Error!!!there is a upper case 'X' in config file \0ALine: %s\0A\00"
@.str.3 = [24 x i8] c"can not open file in:%s\00"
define i32 @file_parse(i8* %0) {
%2 = alloca [680 x i8]
%3 = getelementptr inbounds [680 x i8], [680 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %1
%8 = call i32* @fgets(i8* %3, i32 680, i32* %5)
%9 = icmp eq i32* %8, null
br i1 %9, label %19, label %10
10: ; preds = %7, %15
%11 = call i32 @check_upper_case(i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %19
15: ; preds = %10
%16 = call i32 @convert_to_int(i8* %3)
%17 = call i32* @fgets(i8* %3, i32 680, i32* %5)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %10
19: ; preds = %15, %7, %13
%20 = call i32 @fclose(i32* %5)
br label %23
21: ; preds = %1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %23
23: ; preds = %21, %19
ret i32 0
}