#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*/ tmp2;
typedef int /*<<< orphan*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ my_getpass(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int client_get_passwd(char *buf) {
  int n;
  char tmp[256], tmp2[256];
  my_getpass("new password: ", tmp, sizeof(tmp));
  if (strlen(tmp) < 6) {
    printf("passwd length < 6!!\n");
    return 0;
  }
  my_getpass("password again: ", tmp2, sizeof(tmp2));
  n = strcmp(tmp, tmp2);
  strcpy(buf, tmp);
  memset(tmp, 0, sizeof(tmp));
  memset(tmp2, 0, sizeof(tmp2));
  if (n != 0) {
    printf("passwd not match!\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<client_get_passwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x120(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x100,%edx
call   1080 <my_getpass@plt>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jge    11b4 <client_get_passwd+0x54>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1241 <client_get_passwd+0xe1>
lea    -0x220(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x100,%edx
call   1080 <my_getpass@plt>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1070 <strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
je     123a <client_get_passwd+0xda>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1241 <client_get_passwd+0xe1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_get_passwd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%r14
lea    0xe89(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x100,%edx
call   1080 <my_getpass@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x6,%eax
jge    119d <client_get_passwd+0x3d>
lea    0xe97(%rip),%rdi
jmp    11fd <client_get_passwd+0x9d>
lea    0xe6b(%rip),%rdi
lea    0x100(%rsp),%r15
mov    %r15,%rsi
mov    $0x100,%edx
call   1080 <my_getpass@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
test   %ebp,%ebp
je     1206 <client_get_passwd+0xa6>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    120b <client_get_passwd+0xab>
mov    $0x1,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"new password: \00"
@.str.1 = [21 x i8] c"passwd length < 6!!\0A\00"
@.str.2 = [17 x i8] c"password again: \00"
@.str.3 = [19 x i8] c"passwd not match!\0A\00"
define i32 @client_get_passwd(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
store i8* %0, i8** %3
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i32 @my_getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %7, i32 256)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %32
14: ; preds = %1
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = call i32 @my_getpass(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 256)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcmp(i8* %17, i8* %18)
store i32 %19, i32* %4
%20 = load i8*, i8** %3
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 256)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i32 0, i32 256)
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %14
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %32
31: ; preds = %14
store i32 1, i32* %2
br label %32
32: ; preds = %31, %29, %12
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [15 x i8] c"new password: \00"
@.str.2 = [17 x i8] c"password again: \00"
@str = [18 x i8] c"passwd not match!\00"
@str.4 = [20 x i8] c"passwd length < 6!!\00"
define i32 @client_get_passwd(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @my_getpass(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %4, i32 256)
%7 = call i32 @strlen(i8* %4)
%8 = icmp slt i32 %7, 6
br i1 %8, label %16, label %9
9: ; preds = %1
%10 = call i32 @my_getpass(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 256)
%11 = call i32 @strcmp(i8* %4, i8* %5)
%12 = call i32 @strcpy(i8* %0, i8* %4)
%13 = call i32 @memset(i8* %4, i32 0, i32 256)
%14 = call i32 @memset(i8* %5, i32 0, i32 256)
%15 = icmp eq i32 %11, 0
br i1 %15, label %19, label %16
16: ; preds = %9, %1
%17 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0), %1 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0), %9 ]
%18 = call i32 @puts(i8* dereferenceable(1) %17)
br label %19
19: ; preds = %16, %9
%20 = phi i32 [ 1, %9 ], [ 0, %16 ]
ret i32 %20
}