#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__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
char *readline(int /*<<< orphan*/ *);
char *strdup(char *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ *strstr(char *, char *);
char *build_tag(const char *path) {
  FILE *file = fopen(path, "r");
  if (file == NULL) {
    return NULL;
  }
  for (int i = 0; i < 10; i++) {
    char *line = readline(file);
    if (line == NULL) {
      if (feof(file) != 0) {
        break;
      }
      fclose(file);
      return NULL;
    }
    if (strstr(line, "+build") == NULL) {
      free(line);
      continue;
    }
    if (strncmp(line, "//", 2) != 0) {
      free(line);
      continue;
    }
    char *data = line + 2;
    char *d = data;
    size_t len = strlen(data);
    for (size_t i = 0; i < len; i++) {
      if (d[i] == ' ') {
        (void)*data++;
      } else {
        break;
      }
    }
    if (strncmp(data, "+build", 6) == 0) {
      char *new = strdup(data);
      free(line);
      fclose(file);
      return new;
    }
    free(line);
  }
  fclose(file);
  return "";
}


x86 assembly (clang, -O0):
<build_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c8 <build_tag+0x38>
movq   $0x0,-0x8(%rbp)
jmp    1362 <build_tag+0x1d2>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    134e <build_tag+0x1be>
mov    -0x18(%rbp),%rdi
call   1070 <readline@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    121f <build_tag+0x8f>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1209 <build_tag+0x79>
jmp    134e <build_tag+0x1be>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    1362 <build_tag+0x1d2>
mov    -0x28(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
jne    1247 <build_tag+0xb7>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    1340 <build_tag+0x1b0>
mov    -0x28(%rbp),%rdi
lea    0xdb7(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1274 <build_tag+0xe4>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    1340 <build_tag+0x1b0>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    12ec <build_tag+0x15c>
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    12d1 <build_tag+0x141>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12d6 <build_tag+0x146>
jmp    12ec <build_tag+0x15c>
jmp    12db <build_tag+0x14b>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    129d <build_tag+0x10d>
mov    -0x30(%rbp),%rdi
lea    0xd0b(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1337 <build_tag+0x1a7>
mov    -0x30(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1362 <build_tag+0x1d2>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cf <build_tag+0x3f>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xcad(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_tag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     1288 <build_tag+0xf8>
mov    %rax,%r14
lea    0xe45(%rip),%r15
lea    0xe45(%rip),%r12
jmp    11fb <build_tag+0x6b>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     129f <build_tag+0x10f>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r13d
cmp    $0xa,%r13d
je     1279 <build_tag+0xe9>
mov    %r14,%rdi
call   1070 <readline@plt>
test   %rax,%rax
je     126c <build_tag+0xdc>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     11e9 <build_tag+0x59>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    11e9 <build_tag+0x59>
mov    %rbx,%rbp
add    $0x2,%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
test   %rax,%rax
je     11d0 <build_tag+0x40>
mov    %rax,%rcx
add    %rbp,%rax
nopw   0x0(%rax,%rax,1)
cmpb   $0x20,0x0(%rbp)
jne    11d0 <build_tag+0x40>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rcx
jne    1250 <build_tag+0xc0>
mov    %rax,%rbp
jmp    11d0 <build_tag+0x40>
mov    %r14,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     129a <build_tag+0x10a>
lea    0xd8b(%rip),%r13
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
jmp    1280 <build_tag+0xf0>
mov    %rbp,%rdi
call   10a0 <strdup@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1280 <build_tag+0xf0>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"+build\00"
@.str.2 = [3 x i8] c"//\00"
@.str.3 = [1 x i8] zeroinitializer
define i8* @build_tag(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
store i8* %0, i8** %3
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %1
store i8* null, i8** %2
br label %95
17: ; preds = %1
store i32 0, i32* %5
br label %18
18: ; preds = %89, %17
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %92
21: ; preds = %18
%22 = load i32*, i32** %4
%23 = call i8* @readline(i32* %22)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %21
%27 = load i32*, i32** %4
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %92
31: ; preds = %26
%32 = load i32*, i32** %4
%33 = call i32 @fclose(i32* %32)
store i8* null, i8** %2
br label %95
34: ; preds = %21
%35 = load i8*, i8** %6
%36 = call i32* @strstr(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
br label %89
41: ; preds = %34
%42 = load i8*, i8** %6
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %6
%47 = call i32 @free(i8* %46)
br label %89
48: ; preds = %41
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 2
store i8* %50, i8** %7
%51 = load i8*, i8** %7
store i8* %51, i8** %8
%52 = load i8*, i8** %7
%53 = call i64 @strlen(i8* %52)
store i64 %53, i64* %9
store i64 0, i64* %10
br label %54
54: ; preds = %71, %48
%55 = load i64, i64* %10
%56 = load i64, i64* %9
%57 = icmp ult i64 %55, %56
br i1 %57, label %58, label %74
58: ; preds = %54
%59 = load i8*, i8** %8
%60 = load i64, i64* %10
%61 = getelementptr inbounds i8, i8* %59, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %69
65: ; preds = %58
%66 = load i8*, i8** %7
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %7
%68 = load i8, i8* %66
br label %70
69: ; preds = %58
br label %74
70: ; preds = %65
br label %71
71: ; preds = %70
%72 = load i64, i64* %10
%73 = add i64 %72, 1
store i64 %73, i64* %10
br label %54
74: ; preds = %69, %54
%75 = load i8*, i8** %7
%76 = call i64 @strncmp(i8* %75, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %86
78: ; preds = %74
%79 = load i8*, i8** %7
%80 = call i8* @strdup(i8* %79)
store i8* %80, i8** %11
%81 = load i8*, i8** %6
%82 = call i32 @free(i8* %81)
%83 = load i32*, i32** %4
%84 = call i32 @fclose(i32* %83)
%85 = load i8*, i8** %11
store i8* %85, i8** %2
br label %95
86: ; preds = %74
%87 = load i8*, i8** %6
%88 = call i32 @free(i8* %87)
br label %89
89: ; preds = %86, %45, %38
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 1
store i32 %91, i32* %5
br label %18
92: ; preds = %30, %18
%93 = load i32*, i32** %4
%94 = call i32 @fclose(i32* %93)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %95
95: ; preds = %92, %78, %31, %16
%96 = load i8*, i8** %2
ret i8* %96
}

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