#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 commitChanges();
int /*<<< orphan*/ getpass(char *);
int /*<<< orphan*/ printf(char *);
int set_password(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *cryptmode, password2[128], password1[128];
  for (;;) {
    strcpy(password1, getpass("Enter new Unix password: "));
    strcpy(password2, getpass("Re-enter new Unix password: "));
    if (strcmp(password1, password2) == 0) {
      if (-1 == set_password("root", password1))
        printf("Unable to write password file\n");
      else if (-1 == commitChanges())
        printf("Unable to commit new password file\n");
      else
        return 0;
      break;
    } else
      printf("Password not matched, try again.\n");
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    0xe72(%rip),%rdi
call   1070 <getpass@plt>
mov    -0x130(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    0xe64(%rip),%rdi
call   1070 <getpass@plt>
mov    -0x128(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1256 <main+0xf6>
lea    -0x120(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1050 <set_password@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1219 <main+0xb9>
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
jmp    1251 <main+0xf1>
mov    $0x0,%al
call   1080 <commitChanges@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1240 <main+0xe0>
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
jmp    124c <main+0xec>
movl   $0x0,-0x4(%rbp)
jmp    126e <main+0x10e>
jmp    1251 <main+0xf1>
jmp    1267 <main+0x107>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
jmp    1179 <main+0x19>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
lea    0xe89(%rip),%rdi
call   1070 <getpass@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    0xe8a(%rip),%rdi
call   1070 <getpass@plt>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     121c <main+0xbc>
lea    0xe7e(%rip),%r14
lea    0xe3b(%rip),%r15
mov    %rsp,%r13
lea    0xe4b(%rip),%r12
lea    0x80(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1070 <getpass@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1070 <getpass@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
lea    0xe14(%rip),%rdi
mov    %rsp,%rsi
call   1050 <set_password@plt>
cmp    $0xffffffff,%eax
je     1247 <main+0xe7>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <commitChanges@plt>
cmp    $0xffffffff,%eax
jne    1258 <main+0xf8>
lea    0xe18(%rip),%rdi
jmp    124e <main+0xee>
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter new Unix password: \00"
@.str.1 = [29 x i8] c"Re-enter new Unix password: \00"
@.str.2 = [5 x i8] c"root\00"
@.str.3 = [31 x i8] c"Unable to write password file\0A\00"
@.str.4 = [36 x i8] c"Unable to commit new password file\0A\00"
@.str.5 = [34 x i8] c"Password not matched, try again.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %36, %2
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%11 = call i32 @getpass(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @strcpy(i8* %10, i32 %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%14 = call i32 @getpass(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @strcpy(i8* %13, i32 %14)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%18 = call i64 @strcmp(i8* %16, i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %9
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%22 = call i32 @set_password(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = icmp eq i32 -1, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %33
26: ; preds = %20
%27 = call i32 (...) @commitChanges()
%28 = icmp eq i32 -1, %27
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %32
31: ; preds = %26
store i32 0, i32* %3
br label %38
32: ; preds = %29
br label %33
33: ; preds = %32, %24
br label %37
34: ; preds = %9
%35 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34
br label %9
37: ; preds = %33
store i32 1, i32* %3
br label %38
38: ; preds = %37, %31
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter new Unix password: \00"
@.str.1 = [29 x i8] c"Re-enter new Unix password: \00"
@.str.2 = [5 x i8] c"root\00"
@str = [33 x i8] c"Password not matched, try again.\00"
@str.6 = [35 x i8] c"Unable to commit new password file\00"
@str.7 = [30 x i8] c"Unable to write password file\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i32 @getpass(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcpy(i8* %6, i32 %7)
%9 = call i32 @getpass(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strcpy(i8* %5, i32 %9)
%11 = call i64 @strcmp(i8* %6, i8* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %19, %2
%14 = call i32 @set_password(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%15 = icmp eq i32 %14, -1
br i1 %15, label %27, label %16
16: ; preds = %13
%17 = call i32 (...) @commitChanges()
%18 = icmp eq i32 %17, -1
br i1 %18, label %27, label %30
19: ; preds = %2, %19
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%21 = call i32 @getpass(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @strcpy(i8* %6, i32 %21)
%23 = call i32 @getpass(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @strcpy(i8* %5, i32 %23)
%25 = call i64 @strcmp(i8* %6, i8* %5)
%26 = icmp eq i64 %25, 0
br i1 %26, label %13, label %19
27: ; preds = %16, %13
%28 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0), %13 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0), %16 ]
%29 = call i32 @puts(i8* dereferenceable(1) %28)
br label %30
30: ; preds = %27, %16
%31 = phi i32 [ 0, %16 ], [ 1, %27 ]
ret i32 %31
}