#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 */
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getchar();
int /*<<< orphan*/ input_token(char *);
int /*<<< orphan*/ output_line(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char token[100];
  char repeat[100];
  if (access("token.txt", 0))
    printf("You don't have token, please set it:");
  else {
    printf("You have a token, will you change it (y/n):");
    if (getchar() != 'y') {
      printf("bye~\n");
      return 0;
    }
    printf("Please set it:");
  }
  while (1) {
    input_token(token);
    printf("Repeat it:");
    input_token(repeat);
    if (strcmp(token, repeat)) {
      printf("they are not same, please set it again:");
      continue;
    }
    break;
  }
  FILE *out = fopen("token.txt", "w");
  output_line(out, token);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
xor    %esi,%esi
call   1090 <access@plt>
cmp    $0x0,%rax
je     11bb <main+0x3b>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
jmp    11fe <main+0x7e>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0x79,%eax
je     11f2 <main+0x72>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1291 <main+0x111>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <main+0x83>
lea    -0x70(%rbp),%rdi
call   1070 <input_token@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1070 <input_token@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     124f <main+0xcf>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <main+0x83>
jmp    1254 <main+0xd4>
lea    0xda5(%rip),%rdi
lea    0xe41(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <output_line@plt>
mov    -0xe8(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe5b(%rip),%rdi
xor    %esi,%esi
call   10a0 <access@plt>
test   %rax,%rax
je     11ba <main+0x2a>
lea    0xe52(%rip),%rdi
jmp    11dc <main+0x4c>
lea    0xe6e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x79,%al
jne    128b <main+0xfb>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <input_token@plt>
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <input_token@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1260 <main+0xd0>
lea    0xe59(%rip),%r14
mov    %rsp,%r12
lea    0xe44(%rip),%r15
lea    0x70(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
call   1080 <input_token@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <input_token@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1230 <main+0xa0>
lea    0xd99(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1090 <output_line@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1297 <main+0x107>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"token.txt\00"
@.str.1 = [37 x i8] c"You don't have token, please set it:\00"
@.str.2 = [44 x i8] c"You have a token, will you change it (y/n):\00"
@.str.3 = [6 x i8] c"bye~\0A\00"
@.str.4 = [15 x i8] c"Please set it:\00"
@.str.5 = [11 x i8] c"Repeat it:\00"
@.str.6 = [40 x i8] c"they are not same, please set it again:\00"
@.str.7 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i64 @access(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %18
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 121
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %39
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16, %7
br label %19
19: ; preds = %18, %29
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 @input_token(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = call i32 @input_token(i8* %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
br label %19
31: ; preds = %19
br label %32
32: ; preds = %31
%33 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %33, i32** %4
%34 = load i32*, i32** %4
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%36 = call i32 @output_line(i32* %34, i8* %35)
%37 = load i32*, i32** %4
%38 = call i32 @fclose(i32* %37)
store i32 0, i32* %1
br label %39
39: ; preds = %32, %14
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [10 x i8] c"token.txt\00"
@.str.1 = [37 x i8] c"You don't have token, please set it:\00"
@.str.2 = [44 x i8] c"You have a token, will you change it (y/n):\00"
@.str.4 = [15 x i8] c"Please set it:\00"
@.str.5 = [11 x i8] c"Repeat it:\00"
@.str.6 = [40 x i8] c"they are not same, please set it again:\00"
@.str.7 = [2 x i8] c"w\00"
@str = [5 x i8] c"bye~\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @access(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 121
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %32
13: ; preds = %7, %0
%14 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %7 ]
%15 = tail call i32 @printf(i8* dereferenceable(1) %14)
%16 = call i32 @input_token(i8* %3)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @input_token(i8* %4)
%19 = call i64 @strcmp(i8* %3, i8* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %13, %21
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @input_token(i8* %3)
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @input_token(i8* %4)
%26 = call i64 @strcmp(i8* %3, i8* %4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %21
28: ; preds = %21, %13
%29 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 @output_line(i32* %29, i8* %3)
%31 = call i32 @fclose(i32* %29)
br label %32
32: ; preds = %28, %11
ret i32 0
}