#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 */
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ sb;

/* Variables and functions */
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ run_command(char *, int, char **);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ unlink(char *);
void initpasswd(void) {
  struct stat sb;
  memset(&sb, 0, sizeof(sb));
  if (stat(".needpwchange", &sb) != 0)
    return;
  printf("Password change required.  Please change your password now!\n");
  printf("Enter your current password first and you will be prompted\n");
  printf("for a new password after.\n");
  printf("\n");
  do {
    char *cmd[] = {"passwd", NULL};
    if (run_command(cmd[0], 1, cmd) == 0)
      unlink(".needpwchange");
    memset(&sb, 0, sizeof(sb));
  } while (stat(".needpwchange", &sb) == 0);
}


x86 assembly (clang, -O0):
<initpasswd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    0xe91(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     1187 <initpasswd+0x37>
jmp    121f <initpasswd+0xcf>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    0x2c52(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c4f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rdx
mov    $0x1,%esi
call   1070 <run_command@plt>
cmp    $0x0,%rax
jne    11f5 <initpasswd+0xa5>
lea    0xe10(%rip),%rdi
call   1030 <unlink@plt>
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    0xdf4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
je     11b7 <initpasswd+0x67>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initpasswd>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
call   1070 <stat@plt>
test   %rax,%rax
je     119f <initpasswd+0x3f>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe6f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1050 <puts@plt>
lea    0xece(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe3a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe20(%rip),%r12
lea    0x8(%rsp),%rbx
jmp    120f <initpasswd+0xaf>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1060 <memset@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <stat@plt>
test   %rax,%rax
jne    1193 <initpasswd+0x33>
movaps 0x2bfa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1080 <run_command@plt>
test   %rax,%rax
jne    11f0 <initpasswd+0x90>
mov    %r12,%rdi
call   1040 <unlink@plt>
jmp    11f0 <initpasswd+0x90>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [14 x i8] c".needpwchange\00"
@.str.1 = [61 x i8] c"Password change required. Please change your password now!\0A\00"
@.str.2 = [60 x i8] c"Enter your current password first and you will be prompted\0A\00"
@.str.3 = [27 x i8] c"for a new password after.\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [7 x i8] c"passwd\00"
@__const.initpasswd.cmd = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* null]
define void @initpasswd() {
%1 = alloca %struct.stat
%2 = alloca [2 x i8*]
%3 = call i32 @memset(%struct.stat* %1, i32 0, i32 4)
%4 = call i64 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
br label %26
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %23, %7
%13 = bitcast [2 x i8*]* %2 to i8*
%14 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%17 = call i64 @run_command(i8* %15, i32 1, i8** %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %12
%22 = call i32 @memset(%struct.stat* %1, i32 0, i32 4)
br label %23
23: ; preds = %21
%24 = call i64 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %12, label %26
26: ; preds = %6, %23
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [14 x i8] c".needpwchange\00"
@.str.5 = [7 x i8] c"passwd\00"
@__const.initpasswd.cmd = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* null]
@str = [60 x i8] c"Password change required. Please change your password now!\00"
@str.6 = [59 x i8] c"Enter your current password first and you will be prompted\00"
@str.7 = [26 x i8] c"for a new password after.\00"
define void @initpasswd() {
%1 = alloca %struct.stat
%2 = alloca [2 x i8*]
%3 = bitcast %struct.stat* %1 to i8*
%4 = call i32 @memset(%struct.stat* %1, i32 0, i32 4)
%5 = call i64 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 @putchar(i32 10)
%12 = bitcast [2 x i8*]* %2 to i8*
%13 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
br label %14
14: ; preds = %19, %7
%15 = call i64 @run_command(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 1, i8** %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = call i32 @memset(%struct.stat* %1, i32 0, i32 4)
%21 = call i64 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %14, label %23
23: ; preds = %19, %0
ret void
}