#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 */

/* Variables and functions */
int _tw2_getchar_encode_key(char *, char *, int);
int fio_write_member_key(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ str_cat(char *, char *);
int /*<<< orphan*/ time_get_sec();
char *uint_to_str(int /*<<< orphan*/, char *);
int tw2_member_key_input(char *fname, int flag) {
  char skey[1000], akey[80];
  int kc;
  skey[0] = '\0';
  if (flag == 1) {
    kc = _tw2_getchar_encode_key("", uint_to_str(time_get_sec(), akey), 0);
    str_cat(skey, akey);
    kc = _tw2_getchar_encode_key("Input email: ", akey, 1);
    str_cat(skey, akey);
    kc = _tw2_getchar_encode_key("Input phone: ", akey, 1);
    str_cat(skey, akey);
    kc = _tw2_getchar_encode_key("Input   key: ", akey, 1);
    str_cat(skey, akey);
  } else {
    kc = _tw2_getchar_encode_key("", uint_to_str(~0, akey), 0);
    str_cat(skey, akey);
  }
  if (kc) {
    kc = fio_write_member_key(fname, skey);
    if (kc && flag == 1)
      printf("Private key have written.\n");
  }
  return kc;
}


x86 assembly (clang, -O0):
<tw2_member_key_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x0,-0x400(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    125a <tw2_member_key_input+0xfa>
mov    $0x0,%al
call   1050 <time_get_sec@plt>
mov    %eax,%edi
lea    -0x450(%rbp),%rsi
call   1070 <uint_to_str@plt>
mov    %rax,%rsi
lea    0xea2(%rip),%rdi
xor    %edx,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,-0x454(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1060 <str_cat@plt>
lea    -0x450(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x1,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,-0x454(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1060 <str_cat@plt>
lea    -0x450(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x1,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,-0x454(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1060 <str_cat@plt>
lea    -0x450(%rbp),%rsi
lea    0xdea(%rip),%rdi
mov    $0x1,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,-0x454(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1060 <str_cat@plt>
jmp    1295 <tw2_member_key_input+0x135>
lea    -0x450(%rbp),%rsi
mov    $0xffffffff,%edi
call   1070 <uint_to_str@plt>
mov    %rax,%rsi
lea    0xdcf(%rip),%rdi
xor    %edx,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,-0x454(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1060 <str_cat@plt>
cmpl   $0x0,-0x454(%rbp)
je     12e0 <tw2_member_key_input+0x180>
mov    -0x8(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1080 <fio_write_member_key@plt>
mov    %eax,-0x454(%rbp)
cmpl   $0x0,-0x454(%rbp)
je     12db <tw2_member_key_input+0x17b>
cmpl   $0x1,-0xc(%rbp)
jne    12db <tw2_member_key_input+0x17b>
lea    0xd54(%rip),%rdi
call   1030 <printf@plt>
jmp    12e0 <tw2_member_key_input+0x180>
mov    -0x454(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tw2_member_key_input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x438,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
movb   $0x0,0x50(%rsp)
cmp    $0x1,%esi
jne    1204 <tw2_member_key_input+0xa4>
xor    %eax,%eax
call   1050 <time_get_sec@plt>
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1070 <uint_to_str@plt>
lea    0xe80(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1040 <_tw2_getchar_encode_key@plt>
lea    0x50(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <str_cat@plt>
lea    0xe44(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <str_cat@plt>
lea    0xe33(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <str_cat@plt>
lea    0xe22(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
jmp    121d <tw2_member_key_input+0xbd>
mov    %rsp,%rsi
mov    $0xffffffff,%edi
call   1070 <uint_to_str@plt>
lea    0xe03(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1040 <_tw2_getchar_encode_key@plt>
mov    %eax,%ebx
lea    0x50(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <str_cat@plt>
test   %ebx,%ebx
je     125b <tw2_member_key_input+0xfb>
lea    0x50(%rsp),%rsi
mov    %r14,%rdi
call   1080 <fio_write_member_key@plt>
mov    %eax,%ebx
cmp    $0x1,%ebp
jne    125d <tw2_member_key_input+0xfd>
test   %ebx,%ebx
je     125d <tw2_member_key_input+0xfd>
lea    0xdd6(%rip),%rdi
call   1030 <puts@plt>
jmp    125d <tw2_member_key_input+0xfd>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"Input email: \00"
@.str.2 = [14 x i8] c"Input phone: \00"
@.str.3 = [14 x i8] c"Input key: \00"
@.str.4 = [27 x i8] c"Private key have written.\0A\00"
define i32 @tw2_member_key_input(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca [80 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
store i8 0, i8* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %34
11: ; preds = %2
%12 = call i32 (...) @time_get_sec()
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%14 = call i8* @uint_to_str(i32 %12, i8* %13)
%15 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %14, i32 0)
store i32 %15, i32* %7
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%18 = call i32 @str_cat(i8* %16, i8* %17)
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%20 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 1)
store i32 %20, i32* %7
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%23 = call i32 @str_cat(i8* %21, i8* %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%25 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 1)
store i32 %25, i32* %7
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%28 = call i32 @str_cat(i8* %26, i8* %27)
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%30 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %29, i32 1)
store i32 %30, i32* %7
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%33 = call i32 @str_cat(i8* %31, i8* %32)
br label %41
34: ; preds = %2
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%36 = call i8* @uint_to_str(i32 -1, i8* %35)
%37 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %36, i32 0)
store i32 %37, i32* %7
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%40 = call i32 @str_cat(i8* %38, i8* %39)
br label %41
41: ; preds = %34, %11
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = load i8*, i8** %3
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%47 = call i32 @fio_write_member_key(i8* %45, i8* %46)
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %44
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53, %50, %44
br label %56
56: ; preds = %55, %41
%57 = load i32, i32* %7
ret i32 %57
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"Input email: \00"
@.str.2 = [14 x i8] c"Input phone: \00"
@.str.3 = [14 x i8] c"Input key: \00"
@str = [26 x i8] c"Private key have written.\00"
define i32 @tw2_member_key_input(i8* %0, i32 %1) {
%3 = alloca [1000 x i8]
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
%7 = icmp eq i32 %1, 1
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = tail call i32 (...) @time_get_sec()
%10 = call i8* @uint_to_str(i32 %9, i8* %6)
%11 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %10, i32 0)
%12 = call i32 @str_cat(i8* %5, i8* %6)
%13 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 1)
%14 = call i32 @str_cat(i8* %5, i8* %6)
%15 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32 1)
%16 = call i32 @str_cat(i8* %5, i8* %6)
%17 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 1)
br label %21
18: ; preds = %2
%19 = call i8* @uint_to_str(i32 -1, i8* %6)
%20 = call i32 @_tw2_getchar_encode_key(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %19, i32 0)
br label %21
21: ; preds = %18, %8
%22 = phi i32 [ %17, %8 ], [ %20, %18 ]
%23 = call i32 @str_cat(i8* %5, i8* %6)
%24 = icmp eq i32 %22, 0
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = call i32 @fio_write_member_key(i8* %0, i8* %5)
%27 = icmp ne i32 %26, 0
%28 = and i1 %7, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %25, %29, %21
%32 = phi i32 [ %26, %29 ], [ %26, %25 ], [ 0, %21 ]
ret i32 %32
}