#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 /*<<< orphan*/ mib_get(scalar_t__, void *);
int /*<<< orphan*/ mib_set(scalar_t__, void *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ writePasswdFile();
int /*<<< orphan*/ write_etcPassword();
int setAccountPassword(char *user, char *oldpasswd, char *newpasswd) {
  char usName[30];
  char oldMIBpass[30];
  int selnum = 0;
  mib_get(0 + 91, (void *)usName);
  if (!strcmp(user, usName)) {
    selnum = 1;
    goto check_oldpwd;
  }
  mib_get(0 + 38, (void *)usName);
  if (!strcmp(user, usName)) {
    selnum = 2;
    goto check_oldpwd;
  }
check_oldpwd:
  if (selnum == 0) {
    printf("username is not correct!\n");
    return -1;
  }
  if (selnum == 1) {
    if (!mib_get(0 + 92, (void *)oldMIBpass)) {
      printf("Get super user password from MIB database error!\n");
      return -1;
    }
  } else if (selnum == 2) {
    if (!mib_get(0 + 39, (void *)oldMIBpass)) {
      printf("Get user password from MIB database failed.\n");
      return -1;
    }
  }
  if (strcmp(oldpasswd, oldMIBpass) != 0) {
    printf("old password is not correct!\n");
    return -1;
  }
  if (selnum == 1) {
    if (!mib_set(0 + 92, (void *)newpasswd)) {
      printf("Set Super user password to MIB database failed.\n");
      return -1;
    }
  } else if (selnum == 2) {
    if (!mib_set(0 + 39, (void *)newpasswd)) {
      printf("Set user password to MIB database failed.\n");
      return -1;
    }
  }
  writePasswdFile();
  write_etcPassword();
  return 0;
}


x86 assembly (clang, -O0):
<setAccountPassword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x64(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x5b,%edi
call   1070 <mib_get@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <setAccountPassword+0x4c>
movl   $0x1,-0x64(%rbp)
jmp    11e2 <setAccountPassword+0x82>
lea    -0x40(%rbp),%rsi
mov    $0x26,%edi
call   1070 <mib_get@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <setAccountPassword+0x7d>
movl   $0x2,-0x64(%rbp)
jmp    11e2 <setAccountPassword+0x82>
jmp    11e2 <setAccountPassword+0x82>
cmpl   $0x0,-0x64(%rbp)
jne    1204 <setAccountPassword+0xa4>
lea    0xe0d(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
cmpl   $0x1,-0x64(%rbp)
jne    1242 <setAccountPassword+0xe2>
lea    -0x60(%rbp),%rsi
mov    $0x5c,%edi
call   1070 <mib_get@plt>
cmp    $0x0,%eax
jne    123d <setAccountPassword+0xdd>
lea    0xdee(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
jmp    1285 <setAccountPassword+0x125>
cmpl   $0x2,-0x64(%rbp)
jne    1280 <setAccountPassword+0x120>
lea    -0x60(%rbp),%rsi
mov    $0x27,%edi
call   1070 <mib_get@plt>
cmp    $0x0,%eax
jne    127b <setAccountPassword+0x11b>
lea    0xde2(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
jmp    1280 <setAccountPassword+0x120>
jmp    1285 <setAccountPassword+0x125>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12b4 <setAccountPassword+0x154>
lea    0xdd6(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
cmpl   $0x1,-0x64(%rbp)
jne    12f2 <setAccountPassword+0x192>
mov    -0x20(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <mib_set@plt>
cmp    $0x0,%eax
jne    12ed <setAccountPassword+0x18d>
lea    0xdbb(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
jmp    1335 <setAccountPassword+0x1d5>
cmpl   $0x2,-0x64(%rbp)
jne    1330 <setAccountPassword+0x1d0>
mov    -0x20(%rbp),%rsi
mov    $0x27,%edi
call   1040 <mib_set@plt>
cmp    $0x0,%eax
jne    132b <setAccountPassword+0x1cb>
lea    0xdae(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    134a <setAccountPassword+0x1ea>
jmp    1330 <setAccountPassword+0x1d0>
jmp    1335 <setAccountPassword+0x1d5>
mov    $0x0,%al
call   1030 <writePasswdFile@plt>
mov    $0x0,%al
call   1050 <write_etcPassword@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setAccountPassword>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x20(%rsp),%r12
mov    $0x5b,%edi
mov    %r12,%rsi
call   1070 <mib_get@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11c4 <setAccountPassword+0x64>
lea    0x20(%rsp),%r12
mov    $0x26,%edi
mov    %r12,%rsi
call   1070 <mib_get@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11ff <setAccountPassword+0x9f>
lea    0xf15(%rip),%rdi
jmp    1265 <setAccountPassword+0x105>
mov    %rsp,%rsi
mov    $0x5c,%edi
call   1070 <mib_get@plt>
test   %eax,%eax
je     1229 <setAccountPassword+0xc9>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1220 <setAccountPassword+0xc0>
mov    $0x5c,%edi
mov    %r14,%rsi
call   1050 <mib_set@plt>
test   %eax,%eax
jne    124c <setAccountPassword+0xec>
lea    0xe59(%rip),%rdi
jmp    1265 <setAccountPassword+0x105>
mov    %rsp,%rsi
mov    $0x27,%edi
call   1070 <mib_get@plt>
test   %eax,%eax
je     1232 <setAccountPassword+0xd2>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     123b <setAccountPassword+0xdb>
lea    0xe5f(%rip),%rdi
jmp    1265 <setAccountPassword+0x105>
lea    0xe73(%rip),%rdi
jmp    1265 <setAccountPassword+0x105>
lea    0xdc7(%rip),%rdi
jmp    1265 <setAccountPassword+0x105>
mov    $0x27,%edi
mov    %r14,%rsi
call   1050 <mib_set@plt>
test   %eax,%eax
je     125e <setAccountPassword+0xfe>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <writePasswdFile@plt>
xor    %eax,%eax
call   1060 <write_etcPassword@plt>
jmp    126f <setAccountPassword+0x10f>
lea    0xdc7(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"username is not correct!\0A\00"
@.str.1 = [50 x i8] c"Get super user password from MIB database error!\0A\00"
@.str.2 = [45 x i8] c"Get user password from MIB database failed.\0A\00"
@.str.3 = [30 x i8] c"old password is not correct!\0A\00"
@.str.4 = [49 x i8] c"Set Super user password to MIB database failed.\0A\00"
@.str.5 = [43 x i8] c"Set user password to MIB database failed.\0A\00"
define i32 @setAccountPassword(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [30 x i8]
%9 = alloca [30 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %10
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%12 = call i32 @mib_get(i64 91, i8* %11)
%13 = load i8*, i8** %5
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %3
store i32 1, i32* %10
br label %27
18: ; preds = %3
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%20 = call i32 @mib_get(i64 38, i8* %19)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %18
store i32 2, i32* %10
br label %27
26: ; preds = %18
br label %27
27: ; preds = %26, %25, %17
%28 = load i32, i32* %10
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
32: ; preds = %27
%33 = load i32, i32* %10
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%37 = call i32 @mib_get(i64 92, i8* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
41: ; preds = %35
br label %53
42: ; preds = %32
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%47 = call i32 @mib_get(i64 39, i8* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %45
%50 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
51: ; preds = %45
br label %52
52: ; preds = %51, %42
br label %53
53: ; preds = %52, %41
%54 = load i8*, i8** %6
%55 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%56 = call i64 @strcmp(i8* %54, i8* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
60: ; preds = %53
%61 = load i32, i32* %10
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load i8*, i8** %7
%65 = call i32 @mib_set(i64 92, i8* %64)
%66 = icmp ne i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %63
%68 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
69: ; preds = %63
br label %81
70: ; preds = %60
%71 = load i32, i32* %10
%72 = icmp eq i32 %71, 2
br i1 %72, label %73, label %80
73: ; preds = %70
%74 = load i8*, i8** %7
%75 = call i32 @mib_set(i64 39, i8* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %73
%78 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %4
br label %84
79: ; preds = %73
br label %80
80: ; preds = %79, %70
br label %81
81: ; preds = %80, %69
%82 = call i32 (...) @writePasswdFile()
%83 = call i32 (...) @write_etcPassword()
store i32 0, i32* %4
br label %84
84: ; preds = %81, %77, %67, %58, %49, %39, %30
%85 = load i32, i32* %4
ret i32 %85
}

LLVM IR (-O2):
@str = [44 x i8] c"Get user password from MIB database failed.\00"
@str.6 = [42 x i8] c"Set user password to MIB database failed.\00"
@str.7 = [48 x i8] c"Set Super user password to MIB database failed.\00"
@str.8 = [29 x i8] c"old password is not correct!\00"
@str.9 = [49 x i8] c"Get super user password from MIB database error!\00"
@str.10 = [25 x i8] c"username is not correct!\00"
define i32 @setAccountPassword(i8* %0, i8* %1, i8* %2) {
%4 = alloca [30 x i8]
%5 = alloca [30 x i8]
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%8 = call i32 @mib_get(i64 91, i8* %6)
%9 = call i64 @strcmp(i8* %0, i8* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = call i32 @mib_get(i64 38, i8* %6)
%13 = call i64 @strcmp(i8* %0, i8* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
br label %48
17: ; preds = %3
%18 = call i32 @mib_get(i64 92, i8* %7)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.9, i64 0, i64 0))
br label %48
22: ; preds = %11
%23 = call i32 @mib_get(i64 39, i8* %7)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %48
27: ; preds = %17
%28 = call i64 @strcmp(i8* %1, i8* %7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %35, label %33
30: ; preds = %22
%31 = call i64 @strcmp(i8* %1, i8* %7)
%32 = icmp eq i64 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %30, %27
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
br label %48
35: ; preds = %27
%36 = call i32 @mib_set(i64 92, i8* %2)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.7, i64 0, i64 0))
br label %48
40: ; preds = %30
%41 = call i32 @mib_set(i64 39, i8* %2)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
br label %48
45: ; preds = %40, %35
%46 = call i32 (...) @writePasswdFile()
%47 = call i32 (...) @write_etcPassword()
br label %48
48: ; preds = %45, %43, %38, %33, %25, %20, %15
%49 = phi i32 [ -1, %15 ], [ -1, %33 ], [ 0, %45 ], [ -1, %38 ], [ -1, %43 ], [ -1, %20 ], [ -1, %25 ]
ret i32 %49
}