#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int getline(char **, int *, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void id_check(char *id) {
  FILE *fin = fopen("variables.txt", "r");
  char *line = NULL;
  int nbytes = 10;
  int a = getline(&line, &nbytes, fin);
  int flag = 0;
  int len = strlen(line);
  line[len - 1] = '\0';
  while (a != -1) {
    if (strcmp(id, line) == 0) {
      flag = 1;
      break;
    }
    a = getline(&line, &nbytes, fin);
    len = strlen(line);
    line[len - 1] = '\0';
  }
  fclose(fin);
  if (flag != 1) {
    FILE *fin = fopen("variables.txt", "a");
    fprintf(fin, "%s\n", id);
    fclose(fin);
  }
  return;
}


x86 assembly (clang, -O0):
<id_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0xffffffff,-0x20(%rbp)
je     122d <id_check+0xcd>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <id_check+0x97>
movl   $0x1,-0x24(%rbp)
jmp    122d <id_check+0xcd>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11ca <id_check+0x6a>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x1,-0x24(%rbp)
je     1274 <id_check+0x114>
lea    0xdb9(%rip),%rdi
lea    0xdc2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdac(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id_check>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xe8a(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
movl   $0xa,0xc(%rsp)
mov    %rsp,%rdi
lea    0xc(%rsp),%rsi
mov    %rax,%rdx
call   1080 <getline@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1040 <strlen@plt>
mov    (%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
cmp    $0xffffffff,%ebp
je     120a <id_check+0xaa>
mov    %rsp,%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     123a <id_check+0xda>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <getline@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1040 <strlen@plt>
mov    (%rsp),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
cmp    $0xffffffff,%ebp
jne    11d0 <id_check+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xde7(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xde3(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"variables.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @id_check(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %3
store i8* null, i8** %4
store i32 10, i32* %5
%11 = load i32*, i32** %3
%12 = call i32 @getline(i8** %4, i32* %5, i32* %11)
store i32 %12, i32* %6
store i32 0, i32* %7
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %8
%15 = load i8*, i8** %4
%16 = load i32, i32* %8
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %29, %1
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %39
23: ; preds = %20
%24 = load i8*, i8** %2
%25 = load i8*, i8** %4
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 1, i32* %7
br label %39
29: ; preds = %23
%30 = load i32*, i32** %3
%31 = call i32 @getline(i8** %4, i32* %5, i32* %30)
store i32 %31, i32* %6
%32 = load i8*, i8** %4
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %8
%34 = load i8*, i8** %4
%35 = load i32, i32* %8
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 0, i8* %38
br label %20
39: ; preds = %28, %20
%40 = load i32*, i32** %3
%41 = call i32 @fclose(i32* %40)
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 1
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %45, i32** %9
%46 = load i32*, i32** %9
%47 = load i8*, i8** %2
%48 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load i32*, i32** %9
%50 = call i32 @fclose(i32* %49)
br label %51
51: ; preds = %44, %39
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"variables.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @id_check(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%6 = bitcast i32* %3 to i8*
store i32 10, i32* %3
%7 = call i32 @getline(i8** %2, i32* %3, i32* %4)
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = load i8*, i8** %2
%11 = add nsw i32 %9, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8 0, i8* %13
%14 = icmp eq i32 %7, -1
br i1 %14, label %28, label %15
15: ; preds = %1, %19
%16 = load i8*, i8** %2
%17 = call i64 @strcmp(i8* %0, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %15
%20 = call i32 @getline(i8** %2, i32* %3, i32* %4)
%21 = load i8*, i8** %2
%22 = call i32 @strlen(i8* %21)
%23 = load i8*, i8** %2
%24 = add nsw i32 %22, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
%27 = icmp eq i32 %20, -1
br i1 %27, label %28, label %15
28: ; preds = %19, %1
%29 = call i32 @fclose(i32* %4)
%30 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %32
32: ; preds = %15, %28
%33 = phi i32* [ %30, %28 ], [ %4, %15 ]
%34 = call i32 @fclose(i32* %33)
ret void
}