#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int parse_label(char *file, char *keyword, char *value) {
  int ii = 0, index = 0, scan_value;
  char id[512];
  FILE *fp;
  fp = fopen(file, "r");
  if (fp == NULL) {
    printf("\ncan't open the input file %s!\n", file);
    exit(1);
  }
  fscanf(fp, "%s", id);
  while (strcmp(id, "End") != 0) {
    if (strcmp(id, keyword) == 0) {
      fscanf(fp, "%s", id);
      fscanf(fp, "%s", id);
      strcpy(value, id);
      return (1);
    }
    fscanf(fp, "%s", id);
  }
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<parse_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
jne    11d4 <parse_label+0x64>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x238(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xe39(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x230(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1294 <parse_label+0x124>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1275 <parse_label+0x105>
mov    -0x238(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xde8(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x238(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xdce(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <parse_label+0x137>
mov    -0x238(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xd98(%rip),%rsi
call   1060 <fscanf@plt>
jmp    11ee <parse_label+0x7e>
mov    -0x238(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_label>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1268 <parse_label+0xf8>
mov    %rax,%r12
lea    0xe77(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rax,%rdi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1221 <parse_label+0xb1>
lea    0x10(%rsp),%rbx
lea    0xe47(%rip),%r13
lea    0xe43(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
test   %r14,%r14
je     122d <parse_label+0xbd>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11f0 <parse_label+0x80>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1256 <parse_label+0xe6>
lea    0xdee(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %r12,%rdi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd93(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"\0Acan't open the input file %s!\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"End\00"
define i32 @parse_label(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [512 x i8]
%12 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %12
%15 = load i32*, i32** %12
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %3
%22 = load i32*, i32** %12
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%24 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %44, %21
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %48
29: ; preds = %25
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%31 = load i8*, i8** %6
%32 = call i64 @strcmp(i8* %30, i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %44
34: ; preds = %29
%35 = load i32*, i32** %12
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%37 = call i32 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32*, i32** %12
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%40 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %7
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%43 = call i32 @strcpy(i8* %41, i8* %42)
store i32 1, i32* %4
br label %51
44: ; preds = %29
%45 = load i32*, i32** %12
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%47 = call i32 @fscanf(i32* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %46)
br label %25
48: ; preds = %25
%49 = load i32*, i32** %12
%50 = call i32 @fclose(i32* %49)
store i32 0, i32* %4
br label %51
51: ; preds = %48, %34
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"\0Acan't open the input file %s!\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"End\00"
define i32 @parse_label(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%13 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %11, %22
%16 = call i64 @strcmp(i8* %5, i8* %1)
%17 = icmp eq i64 %16, 0
%18 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br i1 %17, label %19, label %22
19: ; preds = %15
%20 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%21 = call i32 @strcpy(i8* %2, i8* %5)
br label %27
22: ; preds = %15
%23 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %15
25: ; preds = %22, %11
%26 = call i32 @fclose(i32* %6)
br label %27
27: ; preds = %25, %19
%28 = phi i32 [ 1, %19 ], [ 0, %25 ]
ret i32 %28
}